1

I am building a kiosk game for a trade show and want to prevent users from exiting fullscreen with ESC.

I am using Flash CS6 IDE.

I can trap the ESC key with a onKeyDown event, but I can't prevent the ESC key from exiting fullscreen on the Windows executable.

I saw a post with a solution for AIR and Flex and saw your note about stage.nativeWindow as the thing to use in Flash IDE, but I am getting a "Access of possibly undefined property nativeWindow through a reference with static type flash.display:Stage." error.

Here is the code I am using:

   function init():void
                {
                    stage.nativeWindow.addEventListener(KeyboardEvent.KEY_DOWN, escapeTrap);
                    stage.nativeWindow.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
                }

    function escapeTrap(event:KeyboardEvent):void
                {
                    if (event.keyCode == Keyboard.ESCAPE)
                    {
                        event.preventDefault();
                    }
                }

Thanks!

user972043
  • 11
  • 2
  • 2
    It's not possible to lock users in fullscreen mode with browser-resident Flash since it's a security issue. NativeWindow is a class specific to the AIR SDK, which explains your error. Your can publish an AIR application that runs only in fullscreen mode, but in either cases users will still be able to force-quit your application via OS security methods (Ctrl+Alt+Del, etc.). If you absolutely must limit users from exiting fullscreen mode you'll have to supply a keyboard with some broken keys. – Chunky Chunk Sep 27 '13 at 04:47
  • that is correct, I had the same problem in the past on PC kiosks and had to handle that by catching/disable the ESC key at the OS level. Windows was pretty flexible, I didn't have to break any keyboards :) – mika Sep 27 '13 at 14:42

0 Answers0