[COLOR=#000000][FONT=Arial]I am developing an kiosk-like application (a game) which needs to be locked in full screen all the time. I am using as3/flash/AIR for it. Things started well at first, and for the most part all works fine… but there is a mystery brewing somewhere which I haven’t been able to figure out… That’s where your help would be greatly appreciated![/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]The way I handled this problem is by adding at the very beginning of the app:[/FONT][/COLOR]
[FONT=courier new]stage.addEventListener([COLOR=#2B91AF]KeyboardEvent[/COLOR].KEY_DOWN, playerOnKeyDown);[COLOR=#000000]Then, on my playerOnKeyDown function:[/COLOR]
[COLOR=#00008B]function[/COLOR] playerOnKeyDown([COLOR=#00008B]event[/COLOR]:[COLOR=#2B91AF]KeyboardEvent[/COLOR]):[COLOR=#00008B]void[/COLOR]
{
[COLOR=#00008B] if[/COLOR] ([COLOR=#00008B]event[/COLOR].keyCode == [COLOR=#2B91AF]Keyboard[/COLOR].ESCAPE)
{
[COLOR=#00008B] event[/COLOR].preventDefault();
[COLOR=gray] //More code here opening out menus, etc, etc.)[/COLOR]
}
}[/FONT]
[COLOR=#000000][FONT=Arial]
So, all of this worked just fine, but of course I needed to also bring along:[/FONT][/COLOR]
stage.focus = stage;[COLOR=#000000][FONT=Arial]into the party, otherwise, when removing objects - as in [FONT=courier new]removeChild() [/FONT]- the event firing wouldn’t behave as I wanted, because flash changed the focus elsewhere in the display list.[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]I have been careful to add the focus to the stage every time a remove a “child”, and it works great everywhere, except for one time in the entire run, right after I remove an object from an externally loaded swf.[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]I still add the lines as it should be expected to work:
[/FONT][/COLOR]
[FONT=courier new]removeChild(childFromLoadedSWF);
stage.focus = stage;[/FONT]
[COLOR=#000000][FONT=Arial]Except that when I hit the ESC key, it takes me out of full screen (its default behavior) circumventing completely my listener function [FONT=courier new]playerOnKeyDown.[/FONT][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]
The strange thing is that right before doing this, the line:[/FONT][/COLOR]
[FONT=courier new]stage.hasEventListener([COLOR=#2B91AF]KeyboardEvent[/COLOR].KEY_DOWN))[/FONT] // [COLOR=#000000][FONT=Arial]traces true![/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]
The focus is on the stage, the listener is on, and yet when pressing the ESC key the default behavior is ignoring my function completely…[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]What could be causing this?[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]THANK YOU!![/FONT][/COLOR]