Solved

Focus and Function keys

Posted on 2002-04-04
11
380 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
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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now