Rich Rodecker’s blog on flash, flex, actionscript, javascript, and php, with a dash of randomness
focusManager
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;
| Print article | This entry was posted by flashape on September 27, 2004 at 10:59 am, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 7 years ago
thank you. this was driving me batty as well.