When developing in AS3, there are times when you will need to be able to define the users focus, for things like moving a user onto a desired input TextField, after a page has transitioned or for ensuring that any input code you might have will capture events.
If you search the web, or in the Flash IDE help in reference to setting focus, you might find notes on the FocusManager, IFocusManager, and possibly some details on having to include components for these classes to be triggered. These are all significant in some situations, but for setting focus in everyday AS3, it’s much, much easier.
All you really need to do is use stage.focus property.
As it is a read/write property, by result you are provided with ultimate control. The following details some AS3 code which allows you force focus onto any InteractiveObject – Sprites, MovieClips, TextFields etc:
stage.focus = your_object
So say we have a list of clips stored as an Array like so:
var movieA:MovieClip = new MovieClip();
var movieB:MovieClip = new MovieClip();
addChild(movieA);
addChild(movieB);
var clips:Array = new Array(movieA, movieB);
We could set the focus to movieB by calling the following:
stage.focus = clips[1];
Simple eh. I use a similar system for controlling button tabbing within some of my applications. The above code is fairly psudo so I hope you get the idea.



