Exiting Full Screen Mode with ESC key...

Posted on 2009-04-29
Medium Priority
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.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;
	} 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

Accepted Solution

biyik earned 2000 total points
ID: 24267475
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

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

850 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