Sunday, March 28, 2010

Unfocus KeyEvents in Flex Builder 2

Hi,

I'm using Flex Builder 2 and my application requires to monitor the user's keystrokes inputs. I am able to do this in Flash CS3, however it seems the very same script will not work when built in Flex Builder 2. I never get the traced string. Is there any known reason why this may occur?

The script I used:

package {
?import flash.display.Sprite;
?import flash.events.KeyboardEvent;
?
?public class Learning01 extends Sprite
?{
?public function Learning01()
?{
?this.stage.focus = this;
?addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
?}
?
?private function onKeyDown(event:KeyboardEvent):void {
?trace(''testing'');
?}
?}
}

Unfocus KeyEvents in Flex Builder 2

Sorry for bothering, just noticed the main Sprite was targetted, rather then its stage

No comments:

Post a Comment