Solved

Help with SetFocus

Posted on 2004-09-02
4
242 Views
Last Modified: 2012-06-27

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);
  }
 }
}




0
Comment
Question by:juststeve
  • 3
4 Comments
 
LVL 7

Expert Comment

by:fixitben
ID: 11967693


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
0
 
LVL 7

Expert Comment

by:fixitben
ID: 11967701
also I placed the Name box inside a Movie so that way you can see it with it inside of a movie too.

Fixitben
0
 

Author Comment

by:juststeve
ID: 11971057
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.
0
 
LVL 7

Accepted Solution

by:
fixitben earned 500 total points
ID: 11976781
juststeve

Can you post your fla Mine worked fine when I posted it.  I do have a version of email valdation it is on the on(release) of the submit it checks for a @ and . if neither are there then it will post please enter email.  the reason It the name thing keeps coming up is cause I moved the text box of the name inside a movie for you to see and didn't update the AS valdation for name.  And are you publishing it as AS 1 or 2?  

Trying publishing it as AS1 and see if it works or vise versa I did mine in AS 2 and it works on my end.


Here are the files again with the swf so you can see it does work  And I moved the text boxes all of the text boxes in side the movie clip and the main submit button. I also added some more buttons to show you how you can set the focus anywhere just click on the buttons in the midddle and you will see.   http://theyac.org/experts/email.zip

Fixitben
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

840 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