Solved

Help with SetFocus

Posted on 2004-09-02
4
239 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
YouTube Link 10 353
Embedded Webpage Videos don't auto play on Windows 7 1 104
EMET 5.2 / Adobe Flash 2 229
How do I have music file play continuously on a website? 6 102
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,…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
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.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

910 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

21 Experts available now in Live!

Get 1:1 Help Now