Setting the Tab Order of TLFTextFields
July 7th, 2010 by
Adrian Parr
I have just spent ages trying to set the tabIndex order of a bunch of TLFTextFields in Flash CS5. With the old Classic TextFields you would have done something along the lines of …
holder_mc.tf2.tabIndex = 2;
holder_mc.tf3.tabIndex = 3;
holder_mc.tf4.tabIndex = 4;
holder_mc.tf5.tabIndex = 5;
But with the new TLFTextFields this doesn’t work. You can’t just set the tabIndex property of the TLFTextField directly. When you do, it just doesn’t work.
Then I stumbled across this little bit of info in the docs …
So, for my simple example above to work with TLFTextFields instead of Classic TextFields I ended up writing …
InteractiveObject(holder_mc.tlf2.getChildAt(1)).tabIndex = 2;
InteractiveObject(holder_mc.tlf3.getChildAt(1)).tabIndex = 3;
InteractiveObject(holder_mc.tlf4.getChildAt(1)).tabIndex = 4;
InteractiveObject(holder_mc.tlf5.getChildAt(1)).tabIndex = 5;
I hope this helps and that you get it to work quicker than I did!
NOTE 1: I’ve noticed that when the user tabs to a Classic TextField the text is selected, but when you tab to a TLFTextField the caret is positioned at the beginning and no text is automatically selected.
NOTE 2: I’ve also noticed that the selection colour for a Classic TextField is black, but the selection colour for a TLFTextField is light blue. This can look a bit strange when you have a mixture textfields on screen near each other.
Posted in ActionScript 3.0, Sample Code |
