Skip to Content »

FlashApe » focusManager

 focusManager

  • September 27th, 2004
  • 10:59 am

Im pretty much still getting my feet wet with mx04, so this has probbaly been blogged about before. I was creating a couple of text fields, username/password, for a login form, and trying to use onKillFocus to replace the text in a text field if the user left the text field blank.

The problem I was running into was that after you clicked off the text field, the focus would immediately be reset to the text field that you were trying to click out of. I was trying everything, even try to manually set a new focues using Selection.setFocus(), but it will still snap right back to the text field.

Turns out I had a component in my library that i was experimenting with early on and forgot about (i never really use mm’s components). mx04 components use a new class called FocusManager. From the help:

bq. You can use the Focus Manager to specify the order in which components receive focus when a user presses the Tab key to navigate in an application. You can also use the FocusManager class to set a button in your document that receives keyboard input when a user presses Enter (Windows) or Return (Macintosh).

That was throwing a monkey wrench into my whole onKillFocus for the text fields. I just removed the component fromt he library, and everythign was fine. also, you can manually turn off the focus manager with:

bc[as]. focusManager.enabled = false;

1 Person had this to say...

Gravatar
  • john
  • May 30th, 2006
  • 1:19 pm

thank you. this was driving me batty as well.

Want your say?

* Required fields. Your e-mail address will not be published on this site


You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>