To make Esc key close the current window you need to bind events:
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:local="*"
width="1216" height="562" keyDown="group1_keyDownHandler(event)" creationComplete="titlewindow1_creationCompleteHandler(event)">
group1_keyDownHandler function is an event handler for user clicks:
protected function group1_keyDownHandler(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.ESCAPE) {
button1_clickHandler(null);
}
}
You need to bind event listener to this function manually as well (don’t really know why because you did it earlier):
protected function titlewindow1_creationCompleteHandler(event:FlexEvent):void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, group1_keyDownHandler);
}
I have added some imports to enable events. These are:
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.ui.Keyboard;
No comments:
Post a Comment
If you like this post, please leave a comment :)