Solved

Help with SetFocus

Posted on 2004-09-02
4
238 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now