Link to home
Start Free TrialLog in
Avatar of juststeve
juststeve

asked on

Help with SetFocus


I'm trying to implement a strategy where if a user does not enter a valid email format to my V2 textinput component the focus returns to that textinput field and forces the user to re-enter or accept the entry 'NONE'.

I've been able to get everything to work except the setFocus. Specifically, since this statement correctly sets the text value of the textinput:
 >myLogin.textInput_mc.email.text = "NONE";

it sure seems like this line should move focus to that same field.
 >myLogin.textInput_mc.focusManager.setFocus(myLogin.textInput_mc.email);

I don't get an error or anything...focus simply continues to the next textinput field instead of returning to the email textinput field.

emailListener.handleEvent = function(eventObj) {  if (eventObj.type == "focusIn")  {
  //formatting stuff
  myLogin.instructions_txt.text = "Enter email or 'NONE'.";  } else if (eventObj.type == "focusOut"){
  //formatting stuff
  if (!utils.ValidEmail(myLogin.textInput_mc.email.text) ||
       myLogin.textInput_mc.email.text<>"NONE")
  {
   myLogin.instructions_txt.text = "Want 'NONE'?";
   myLogin.textInput_mc.email.text = "NONE";
   myLogin.textInput_mc.focusManager.setFocus(myLogin.textInput_mc.email);
  }
 }
}




Avatar of fixitben
fixitben



Ok  if you are testing this inside of flash like when you press ctrl + Enter then THe set focus doesn't work there. It only will show up when you are doing it straight from the swf.  Also I beleive you need quotes around the "myLogin.textInput_mc.email" Like Below and not all the stuff before just this.

Selection.setFocus("myLogin.textInput_mc.email");


Another Thing Make sure that you are pointing to the instance name and not the var so email should be the instance name of the text box and your var should be some thing else like email2.  Here is a link to my file That I created it also has tabindexing in it.  Http://theyac.org/experts/email.fla

Fixitben
also I placed the Name box inside a Movie so that way you can see it with it inside of a movie too.

Fixitben
Avatar of juststeve

ASKER

Thankx much Ben but I haven't been able to get the setFocus to work either in my own movie. I've published your FLA, dropped the swf on a browser window and don't see any automated focus no matter if i tab through the controls or hit submit...and Name will never get focus via tab...and Submit will always respond with 'Please Enter Your Name' prompt ....even if filled. I don't see any email format validation at all.

I have a feeling the fact that I'm defining all this stuff in a class file is also complicating matters.
ASKER CERTIFIED SOLUTION
Avatar of fixitben
fixitben

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial