Skip to main content
Inspiring
January 14, 2009
Question

Setfocus() on Flash form.

  • January 14, 2009
  • 2 replies
  • 1125 views
I have an app developed in flash forms, I am trying to make changes and add validations.
on one of the input forms I am trying to pass focus back to the input form when validation fails. This is not working see below. I have used the setfocus() and focus() for the Action script and nothing seems to be working.
This topic has been closed for replies.

2 replies

Inspiring
January 14, 2009
> desc.setFocus();
It works fine for me in a simple button onClick test. Maybe the field is not in scope? Shot in the dark here, but any change if you:

1. Try calling desc.setFocus(); outside your anonymous function.
2. Try using _root.desc.setFocus()

umuayoAuthor
Inspiring
January 14, 2009
It is still hanging the browser. The prompt for the error is working only you can not click the OK button to close it, like it is opening lots of Ok buttons in an infinit loop. Below is the entire Action script. I am validating the strings entered. Its called from the onblur event of the form
Participating Frequently
January 14, 2009
try moving the function from onblur to the input's in the form (eg: onKeyUp)
as this does not work (stripped down version)

<cfsavecontent variable="check2">
alert("does this work");
_root.desc.setFocus();
</cfsavecontent>

<cfform format="flash" skin="haloblue" width="300" height="200" onblur="#check2#">
<cfformgroup type="horizontal" id="myUID">
<cfinput name="UserID" width="200" maxlength="50" value="" type="text">
<cfinput name="UserID2" width="200" maxlength="50" value="" type="text" >
<cfinput name="UserID3" width="200" maxlength="50" value="" type="text" >
</cfformgroup>
</cfform>

but this does


<cfsavecontent variable="check2">
alert("does this work");
_root.desc.setFocus();
</cfsavecontent>




<cfform format="flash" skin="haloblue" width="300" height="200">
<cfformgroup type="horizontal" id="myUID">
<cfinput name="UserID" width="200" maxlength="50" value="" type="text" onkeyup="#check2#">
<cfinput name="UserID2" width="200" maxlength="50" value="" type="text" onkeyup="#check2#">
<cfinput name="UserID3" width="200" maxlength="50" value="" type="text" onkeyup="#check2#">
</cfformgroup>
</cfform>
Participating Frequently
January 14, 2009
try Selection.setFocus("textFieldToReturnTo");
umuayoAuthor
Inspiring
January 14, 2009
I tried that also and it hung my Browser, like its on an infinite loop.