halilcakar
halilcakar

Reputation: 1648

AS3 Keyboard Events doesn't work

    ///toggle
    var tamEkranMi:Boolean = false;
    toggle.buttonMode = true;
    toggle.addEventListener(MouseEvent.CLICK, tamEkran);
    function tamEkran(e:MouseEvent)
    {
        if(tamEkranMi == false)
        {
            tamEkranMi = true;
            stage.displayState =  StageDisplayState.FULL_SCREEN_INTERACTIVE;
            toggle.gotoAndStop(2);
        }
        else
        {
            tamEkranMi = false;
            toggle.gotoAndStop(1);      
            stage.displayState = StageDisplayState.NORMAL;
        }
    }
/*top of this works fine

  below this just doesn't work when i try on a website

*/
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
    function reportKeyDown(e:KeyboardEvent):void 
    {
        switch(e.keyCode)
        {
            case Keyboard.ESCAPE:
                tamEkranMi = false;
                toggle.gotoAndStop(1);

        }   /*
       if(e.keyCode == Keyboard.ESCAPE)
       {
           tamEkranMi = false;
           stage.displayState = StageDisplayState.NORMAL;
           toggle.gotoAndStop(1);
       }*/
    } 

Here is my code block. When i use this in my computer it just works fine but when i use a website to try these codes just not working. The toggle button works but when i use ESC key on my keyboard that code block simply doesn't work.

Upvotes: 0

Views: 204

Answers (1)

akmozo
akmozo

Reputation: 9839

I think that your problem is just because you are using the Escape key which is reserved to exit the fullscreen mode of the flash player standalone version or in the web browser when the fullscreen mode is active, otherwise, you can catch it without any problem.

For the FULL_SCREEN_INTERACTIVE mode, don't forget to enable it in your html code.

Hope that can help.

Upvotes: 2

Related Questions