Solved

Focus and Function keys

Posted on 2002-04-04
11
421 Views
Last Modified: 2012-06-21
Friends....,

1.           I have embedded a flash movie on to a web page. I have a text field(edit field ) in the first frame. When i load the HTML although i have the cursor blinking on the text fieldiam not able to typeon to it. I think the focus is not on the movie.what can i do for it?
         
2. Can i detect function key press(F1,F2 etc)in Flash. if not directly can i detect ity in Javascript and sendit to flash?

Please give me an answer as soon as possible. Very very Urgent!!!!!...

Murali
0
Comment
Question by:muraliram
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 2

Expert Comment

by:mousefist
ID: 6922004
the focus is pretty easy, read this:
http://www.macromedia.com/support/flash/ts/documents/set_focus.htm

the function keys are available through the Key.getCode object ... check this one out:
http://www.macromedia.com/support/flash/action_scripts/objects/key_object.html

the function keys are:
F1=112
F2=113
F3=114
F4=115
F5=116
F6=117
F7=118
F8=119
F9=120
F10=121
F11=122
F12=123

don't think that works for mac users, though.  if you're using mx, you can add a listener, which would work a little more nicely than the the onEnterFrame event they suggest in that technote.  

m!
0
 
LVL 3

Expert Comment

by:jeffbeasley
ID: 6924377
Simple Question I know.......

Did you choose input text on your "text options" palet

Jeff
0
 
LVL 2

Author Comment

by:muraliram
ID: 6924779
Friends,

       The movie is embedded in an HTML page.so what happens is that in my Flash Movie i have written an action for the Key F5 in a frame. But however when i play this by embedding this in an HTML page when i press the key F5 the browser( IE) refreshes. The action should take place when i press F5.How this can be done?

The focus problem has been solved. Thanks.

Murali
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:Zeffer
ID: 6935640
Try changing the key to 5 instead of F5.
F5 must be a priority over the action you have written for the movie,as far as the browser is concerned.

Z
0
 
LVL 6

Expert Comment

by:rootdir
ID: 6990194
I am just giving this code for F5 you have to write code for other keys. May be this code is too late for you.

You can detect F5 function key in javascript and pass parameter to flash like this

1. create "Movie1.swf" flash movie. Create "text" as dynamic textbox. Get that textbox on stage. Save movie and Publish.

1. Add this javascript code to your Movie1.html page

<script language = "javascript">
<!--
function JavaToFlash()
{
         // Here you can set any variable from flash like as "text"
         window.document.JavaScript1.SetVariable("text", "Function key F5 is pressed");
}

document.onkeydown = function()
{

        if(window.event && window.event.keyCode == 116)
        {
            // Capture and remap F5
            window.event.keyCode = 505;
        }

        if(window.event && window.event.keyCode == 505)
        {
            // New action for F5
           JavaToFlash();
           return false;
           // Must return false or the browser will refresh anyway
     }
}
//-->
</script>

2. insert follwing code in to your html page

<OBJECT classid= "clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/ flash/swflash.cab#version=4,0,2,0" ID=JavaScript1 WIDTH=550 HEIGHT=400> <PARAM NAME=movie VALUE="Movie1.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED name="JavaScript1" src="Movie1.swf" quality=high bgcolor=#FFFFFF WIDTH=550 HEIGHT=400 swLiveconnect=true TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED> </OBJECT>

It is imperative that all three locations(1. ID=JavaScript1, 2. name="JavaScript1" and, 3. swLiveconnect=true) the <object> ID parameter, the <embed> name parameter and the object specification are identical for this to work in both Netscape and IE. Also note the presence of the "swLiveConnect=true" parameter, this is also necessary for use with the Flash Plug-In for Netscape.

That's it.

You will get what you are looking for

Cheers,

RootDir
0
 
LVL 2

Author Comment

by:muraliram
ID: 6996553
I think If I have focus set on to the movie then the it won't come to document.onkeydown. The Flash Plugin will directly pass thhe key to browser. Can u pls try this after clicking on teh movie area. U can see this not working. I think so.
0
 
LVL 6

Expert Comment

by:rootdir
ID: 6997239
I will check
0
 
LVL 6

Accepted Solution

by:
rootdir earned 300 total points
ID: 6997392
Hay I havn't tryed this code, but you can try inside flash movie. Try to get more info in Key.addListener. May be you will find some way.

myListener = new Object();
myListener.onKeyDown = function () {
  trace ("You pressed a key.");
}
Key.addListener(myListener);

RootDir
0
 
LVL 6

Expert Comment

by:rootdir
ID: 6997436
For above code you have to use flash mx new version of flash and see
0
 
LVL 9

Expert Comment

by:OBCT
ID: 10311597
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept rootdir's comment as answer.

Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

OBCT
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question