Selection.setFocus

Hi when using Selection.setFocus in my main timeline it won´t work. The curser goes to the selected textfield but it won´t accept any typing until I click it with the mouse.

In another forum I read tha I have to set the focus to Flash to get the setFocus action to work.

That one flew right over my head :wink: does anybody have any similar experience and how did you solve it?

well, the textfield has focus inside the flash movie, but the flash movie doesnt have focus inside the HTML document… to solve this you need to set focus to the movie when the page loads. so, add something like this to a script tag in the head:


function focusFlash() {
  myFlashMovie.focus();
}

and add an onLoad event to your body, like this:

onLoad="focusFlash()"

oh, replace ‘myFlashMovie’ with your movie’s name.

edit errr, cant post html code in a code tag?

GREAT!!!

THX
Very helpful :slight_smile:

Hmm I tried it and tried it again and search for answers but sorry to bug you again can´t find the answer (-:

Using this code in my html page can anyone see what´s wrong with it…

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
function focusFlash() {
  setFocus.swf.focus();
}

</script>
</head>

<body onLoad="focusFlash()">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="550" height="400">
  <param name="movie" value="setFocus.swf">
  <param name="quality" value="high">
  <embed src="setFocus.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed></object>

</body>
</html>

i’m having the same problem.

how do i make the script work
here’s how my script looks in the HTML



<SCRIPT LANGUAGE="java script">
function focusFlash() {
  peoplesearch.swf.focus();
}

</script>

drop the ‘.swf’ :slight_smile:
setFocus.focus(); would work.
and so would peoplesearch.focus();

**** I must be missing something I can´t get it to work.

Attaching file and hoping someone has the time to check them for error :hangover:

ah, you need the ‘name’ attribute in the <object> and <embed> tags… add this:

name = "setFocus"

i assumed you were using flash’s generated tags which add that automatically.

still doesn’t work :frowning:


<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html;  charset=ISO-8859-1">
<TITLE>peoplesearch</TITLE>

<SCRIPT LANGUAGE="java script">
function focusFlash() {
  peoplesearch.focus();
}

</script>


</HEAD>
<BODY bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="focusFlash()">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="490" height="120" name = "setFocus">
  <param name=movie value="peoplesearch.swf">
  <param name=quality value=high>
  <embed src="peoplesearch.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="490" height="120" name = "setFocus">
  </embed> 
</object> 
</BODY>
</HTML>

i am sofa king we todd did

Unfortunatly same here :cyclops:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<SCRIPT LANGUAGE="java script">
function focusFlash() {
  setFocus.focus();
}
</script>

</head>

<body onLoad="focusFlash()">


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="550" height="400" name = "setFocus">
  <param name="movie" value="setFocus.swf">
  <param name="quality" value="high">
  <embed src="setFocus.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" name = "setFocus" type="application/x-shockwave-flash" width="550" height="400"></embed></object>

</body>
</html>

ok, lemme explain it a little further… what appears as the “name” of the flash movie object, should appear in the script before the “.focus()” method. shuga, if your script refers to ‘peoplesearch’ your movie’s name should also be ‘peoplesearch’.

and i think that script doesnt work for you mooler because “java script” is not a valid language! its “JavaScript”, no space…

Stupid me :slight_smile:

Now it works just great thx a million for your patiance brainy!!!

haha, any time :smiley:

i’m off work today so i won’t be able to see if it works till monday. the name of my movie is peoplesearch.swf and aside from that i don’t see anything wrong with my code. but i guess i’ll check on monday … thanks for the help

additionally i tried setting the tabIndex in flash but that didn’t help to do anything but make it so my other buttons didn’t respond to tabbing

i guess when you set a tab index you have to then specify all buttons in the movie in their order of importance

Hi again brainy hope you can help me with this one as well.

The focus works great but after filling in that textfield and using Tab the curser jumps to the url textfield of the browser insted of the next textfield in flash.

This code is in the same frame as the textfields (it´s a form)

[AS]
name_txt.tabIndex = 1;
email_txt.tabIndex = 2;
adress_txt.tabIndex = 3;
comments_txt.tabIndex = 4;
send_btn.tabIndex = 5;
Selection.setFocus(name_txt);
[/AS]

Do you see any errors?
As before it works fine as a stand alone movie but in the browser it does not?
THX

hmm. i guess this is cause explorer is catching the TAB click and not sending it to the flash movie… im not sure there’s a way to get that to work…