Exiting Full Screen Mode with ESC key...

Posted on 2009-04-29
Last Modified: 2013-11-11
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.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;


	} else {

		logo_mc.visible = true;

		skin_bg.visible = true;





public function escFullScreen(event:KeyboardEvent):void


	if (stage.displayState == StageDisplayState.FULL_SCREEN && event.keyCode == Keyboard.ESCAPE)


		logo_mc.visible = true;

		skin_bg.visible = true;



Open in new window

Question by:eb110k
    LVL 6

    Accepted Solution

    You don't need to write extra code to detect the "Esc" key.  It's default on flash player.
    Here is a tutorial about full screen mode which works fine: You can compare your codes with this working example
    Don't forget, you can't test it in Flash IDE.

    Author Closing Comment

    Thank you for your advise.
    I could make it work by using FullScreenEvent.
    It worked perfectly!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
    Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now