as3 how to catch focus selection event?

Is it possible to catch a "Focus selection" on a movieclip (using accessibility stuff such as TAB, ARROWS, ENTER and SPACE keys only)?

In the following example, I can't find a way to catch the "Focus selection" on the blue square. Any suggestions?

import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.display.Sprite;

// build red button
var btSprite:Sprite = new Sprite();;,0,20,20);;
var redBtn:SimpleButton;
redBtn = new SimpleButton(btSprite, btSprite, btSprite, btSprite);
redBtn.x = redBtn.y = 0;

// build blue square
var blueSquare:MovieClip = new MovieClip();;,0,20,20);;
blueSquare.x = blueSquare.y = 100; // not sure it does not show over myBtn

// set blue square selectable using TAB key
blueSquare.tabEnabled = true;
blueSquare.focusRect = true;

// listen events
redBtn.addEventListener(MouseEvent.CLICK, onEvent);         // work click / tab select
blueSquare.addEventListener(Event.SELECT, onEvent);         // does not work
blueSquare.addEventListener(MouseEvent.CLICK, onEvent);     // works click only

// catch events on objects
function onEvent(event:Event){
    trace(('none') + " selected!");


Have you tried using the focus events?


here is a good tutorial:

In regards to arrow keys or space bar or enter, you'll need to use a key Listener:

blueSquare.addEventListner(KeyboardEvent.KEY_DOWN, keyDownHandler);

function keyDownHandler(event:KeyboardEvent):void {
        case Keyboard.SPACE:
        case Keyboard.ENTER:
            //do your select

        case Keyboard.DOWN:
            //do what you want when the down arrow is pressed


Need Your Help

How to delete entire contents of sdcard programmatically in Android 2.2

android android-sdcard android-2.2-froyo

I wish to delete the users entire SDcard programmatically in Android 2.2.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.