Focus and Function keys

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
LVL 2
muraliramAsked:
Who is Participating?
 
rootdirConnect With a Mentor Commented:
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
 
mousefistCommented:
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
 
jeffbeasleyCommented:
Simple Question I know.......

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

Jeff
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
muraliramAuthor Commented:
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
 
ZefferCommented:
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
 
rootdirCommented:
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
 
muraliramAuthor Commented:
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
 
rootdirCommented:
I will check
0
 
rootdirCommented:
For above code you have to use flash mx new version of flash and see
0
 
OBCTCommented:
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
All Courses

From novice to tech pro — start learning today.