eb110k
asked on
Exiting Full Screen Mode with ESC key...
Hello,
I'm working on video player and have a problem when exiting esc key.
I hide unnecessary object such as player's skin and logo when entered full screen mode by using DisplayObject's visible property and displayState property of stage as shown below.
I have no problem as long as user pressed on "Full Screen" button on this player.
But I cannot detect when user exiting full screen mode by pressing esc key.
So, I defined escFullScreen funciton and trying to listen for KeyboardEvent.
However, it looks like it doesn't listen KeyboardEvent when the player is Full Screen Mode.
How do I make this work?
Please advise.
Thank you.
I'm working on video player and have a problem when exiting esc key.
I hide unnecessary object such as player's skin and logo when entered full screen mode by using DisplayObject's visible property and displayState property of stage as shown below.
I have no problem as long as user pressed on "Full Screen" button on this player.
But I cannot detect when user exiting full screen mode by pressing esc key.
So, I defined escFullScreen funciton and trying to listen for KeyboardEvent.
However, it looks like it doesn't listen KeyboardEvent when the player is Full Screen Mode.
How do I make this work?
Please advise.
Thank you.
import flash.display.*;
import flash.events.*;
import flash.ui.Keyboard;
.....................
fullscreen_btn.addEventListener(MouseEvent.CLICK, fullScreen);
stage.addEventListener(KeyboardEvent.KEY_DOWN, escFullScreen);
public function fullScreen(event:MouseEvent):void
{
if (stage.displayState == StageDisplayState.NORMAL) {
logo_mc.visible = false;
skin_bg.visible = false;
stage.displayState=StageDisplayState.FULL_SCREEN;
} else {
logo_mc.visible = true;
skin_bg.visible = true;
stage.displayState=StageDisplayState.NORMAL;
}
}
public function escFullScreen(event:KeyboardEvent):void
{
if (stage.displayState == StageDisplayState.FULL_SCREEN && event.keyCode == Keyboard.ESCAPE)
{
logo_mc.visible = true;
skin_bg.visible = true;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I could make it work by using FullScreenEvent.
It worked perfectly!