567 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
iamdok says

Hi All,

I’m experiencing some strange behavior in a Flash project on which I’m working.

I’m listening for the Escape key (keyCode = 27) press while in Fullscreen mode with AS3 . I wish to call a function when the escape key is used to exit the fullscreen mode.

Here is the code for the handler function, but the function works perfectly when testing in Flash Player so I don’t think there are problems there. The problem occurs when I’m testing in the browsers, it seems that the KeyDown event is not being received by the function.

I’m guessing it has something to do with focus but it doesn’t matter where or how may times I click while in fullscreen mode, the event is still not received when the escape key has been pressed.

Escape key is available in fullscreen mode. charCode is 27 or Keyboard.ESCAPE

index file is also using MacMouseWheelScroll by pixelbreaker & SWFAddress & SWFObject 2.0

Any ideas?

412 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+5 more
patrickjansen says

you code does trigger / trace in browser (tested not in fullscreen mode). Can you post the fullscreenToggle() function you use to see if it still fires in fullscreen?

1161 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Had an item featured in an Envato Bundle
+4 more
FlashTang says

Why Keyboard.ESCAPE ?

if you want to call function

another way
you can add an EventListener : RESIZE
stage.addEventListener(Event.RESIZE,function(e){
                                               if(isFullscreen){
                                                   yourfunction()

                                               }
                                               else{
                                                   yourfunction2()
                                               }

                                               })
567 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
iamdok says

Hi Patrick,

Cheers for your reply, here is the toggle function code:

CODE

Donagh

ps. How are you checking trace statements in the browser?

8298 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says
ps. How are you checking trace statements in the browser?

you can use Demonster Debugger to debug a running SWF outside of the IDE …

theres a tutorial at gotoandlearn for it as well…

755 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 500+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 1+ items on Envato Market
+5 more
skyplugins says
ps. How are you checking trace statements in the browser?

You can use the remote debugging function in the flash editor.

1161 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Had an item featured in an Envato Bundle
+4 more
FlashTang says
Yes, not working in browser,really don’t know why
so your can use RESIZE event ,it works I ‘ve tried
put a text name it “_txt”
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);
stage.addEventListener(Event.RESIZE,resizeHandler)
function resizeHandler(e){
    if(stage.displayState ==StageDisplayState.NORMAL){
        _txt.text="NORMAL" 

    }else{
    }
}
function keyHandler(e:KeyboardEvent):void {

 if(e.keyCode==Keyboard.ESCAPE){

    fullscreenOff.visible = false;
    fullscreenOn.visible = true;
    _txt.text="NORMAL" 

 }

}

fullscreenOff.addEventListener(MouseEvent.MOUSE_DOWN,fullscreenToggle)
fullscreenOn.addEventListener(MouseEvent.MOUSE_DOWN,fullscreenToggle)
fullscreenOff.visible = false;
function fullscreenToggle(e):void {
   if(stage.displayState ==StageDisplayState.NORMAL){
    stage.displayState=StageDisplayState.FULL_SCREEN
    fullscreenOff.visible = true;
    fullscreenOn.visible = false;
    _txt.text="FULL_SCREEN" 
    }else{
    stage.displayState=StageDisplayState.NORMAL
    fullscreenOff.visible = false;
    fullscreenOn.visible = true;
    _txt.text="NORMAL" 

    }
}
1312 posts
  • Has referred 200+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 100+ items on Envato Market
+8 more
LGLab says

isn’t most keyboard input disabled in full screen due to flash player security etc ? I don’t think you can listen to escape keydown.

1161 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Had an item featured in an Envato Bundle
+4 more
FlashTang says
Oh I know why now , maybe it was limited by Adobe
Think about below code ,what is the aftermath ? you can try it (perss ESC key,in SAflashplayer)
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);
function keyHandler(e:KeyboardEvent):void {
    //trace("charCode= " + e.keyCode);
 if(e.keyCode==Keyboard.ESCAPE){

    fullscreenToggle()
 }

}
function fullscreenToggle():void {
   if(stage.displayState ==StageDisplayState.NORMAL){
     stage.displayState=StageDisplayState.FULL_SCREEN
    }else{
    stage.displayState=StageDisplayState.NORMAL
   }
}
567 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
iamdok says

Hey FlashTang,

Thanks man for your work and your testing. Your resize event did the trick :) , but I am almost certain I got something like this working in the past (listening for the escape key), but I just wasn’t happening for me this time.

It’s true that text input is disabled but the escape key is an exception, but I’m not clear about whether you can listen to it. My trace statments from remote debugging (Thanks guys for the advice ;) ) were actually returning a keyCode of 32 for the escape key when pressed to exit fulscreen mode, 32 is the code for the space Bar! Not sure why this was happening.

You could be right FlashTang, as the security measures are in place to prevent users from being forced to stay in fullscreen mode. And your code shows an easy exploit of this, if we were able to listen to the escape key.

Thanks to all for their input. Appreciate it.

Happy Flashing,

Donagh.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by