Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with SetFocus

Posted on 2004-09-02
4
Medium Priority
?
247 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 2000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses

963 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