PDA

View Full Version : Detecting escape (ESC) key press in Full Screen Mode?


drj201
05-20-2008, 05:59 PM
Hello all...

My first post on this wonderful forum (I have searched this great resource a great deal before).

I have an FLV player that I have programmed in AS3. The player goes into fullscreen when you press a button.

I have an event listener on the button that changes the stage mode to FULL SCREEN. This act in turn is detected with an event listener on the stage that detects an event.RESIZE.

This all works fine. When you click the button in normal mode I go to full screen mode and vice versa. More importantly the button changes (i.e. I line another button in the place of the previous button using coordinates) in full screen and move it off screen in normal screen so I have a "go full screen" icon button in normal mode and a "back to normal mode" icon on full screen.

MY PROBLEM is... Using the button to go into full screen mode changes the button to the 'close full screen' icon as expected. If I use the close full screen button in full screen mode it changes back. All perfect. My problem however is if I exit the full screen mode using the escape key the button does not change back so I am guessing the event handler is not triggered. Is there a way to detect the event of exiting full screen mode using the escape key rather than a button? The event.RESIZE on the stage does not seem to do it...

Hope that makes sense.

Please help :cool:

Slowburn
05-20-2008, 09:06 PM
you'll need to add a FullScreenEvent listener to the Stage. this will pass back a value of fullScreen= true | false. within this method you could change all your buttons appropriately.

MikeTheVike
09-18-2008, 04:00 PM
I ran into the same problem and found this thread in a search. I'm doing something wrong though...


stage.addEventListener(FullScreenEvent.FULL_SCREEN , fsEvent);

function fsEvent(event:FullScreenEvent) :void {
trace("fullscreen event activated");
}


the fsEvent function doesn't fire...Thanks for any help

wvxvw
09-18-2008, 04:39 PM
You probably never change stage's display state, or remove this listener before you change the display state, or add it after you change it, otherwise it should work.
BTW, are you testing it from Flash IDE? If so, than you won't be able to switch to fullscreen mode because of the IDE limitations, you need to test it in the browser.

MikeTheVike
09-18-2008, 05:06 PM
You probably never change stage's display state, or remove this listener before you change the display state, or add it after you change it, otherwise it should work.
BTW, are you testing it from Flash IDE? If so, than you won't be able to switch to fullscreen mode because of the IDE limitations, you need to test it in the browser.

I was testing it in Flash, thought it would still activate the function. I tried it in a browser and it worked, thanks!

crowds
02-20-2009, 09:06 AM
Just stumbled on this via a google and would like to say thanks !
It was just the info I was looking for :)

roberttimes
08-05-2009, 06:00 PM
To have your fullscreen icon change back when exiting fullscreen with the Esc key, add this:

stage.addEventListener(Event.FULLSCREEN, fullScrHandler);
function fullScrHandler(event:FullScreenEvent):void {

if (stage.displayState == StageDisplayState.FULL_SCREEN) {
fullScreen_Btn.visible = false;
normalScreen_Btn.visible = true;
} else {
normalScreen_Btn.visible = false;
fullScreen_Btn.visible = true;
}
}

We need the stage to check if it is in fullscreen or not, and hide the corresponding button.

Vinyl
07-25-2011, 03:15 AM
Thank you roberttimes. The code is perfect ;-)

litaltamari
12-06-2011, 01:22 AM
hi i have created normal button and full screen button for my site:
the site is:yaelasraf

normal.addEventListener(MouseEvent.CLICK, normalScreen);

function normalScreen(event:MouseEvent):void {
stage.displayState = StageDisplayState.NORMAL;
}

full.addEventListener(MouseEvent.CLICK, fullScreen);

function fullScreen(event:MouseEvent):void {
stage.displayState=StageDisplayState.FULL_SCREEN;
}

stage.addEventListener(Event.FULLSCREEN, fullScrHandler);
function fullScrHandler(event:FullScreenEvent):void {

if (stage.displayState == StageDisplayState.FULL_SCREEN) {
full.visible = false;
normal.visible = true;
} else {
normal.visible = false;
full.visible = true;
}
}

my problem is that after you enter from the enter button to the site, you can see also the normal button at the bottom and also full screen button at the top, and only after you press on the normal button the second function starts to play.(that only one of them will be shown at a time)
what can i do in order that the full screen button on the top will not appear
but only after the normal mode?

thanks i hope im clear...:)

i have one more problem in the site...at the contact us form i cant input text when its on a full screen mode..is there anyway to fix it?

thanks:)

Vinyl
12-11-2011, 08:46 PM
my problem is that after you enter from the enter button to the site, you can see also the normal button at the bottom and also full screen button at the top, and only after you press on the normal button the second function starts to play.(that only one of them will be shown at a time)
what can i do in order that the full screen button on the top will not appear
but only after the normal mode?

You can do something like :

normal.visible = false;

Just put the code at the beginning...