Posts Tagged ‘button’

Actionscript 3 Button to Switch Between Fullscreen and Normal States

Tuesday, April 20th, 2010

fullscreen image

As a school project, I have create a photography website in flash actionscript 3 where fullscreen button is used to go to fullscreen and a close button is used to go back to the normal state. Users can by default hit the “escape” key to exit the fullscreen mode but it would be more user friendly to include a “exit” or “close” fullscreen button once you’re in fullscreen mode.

Here is how I did this with actionscript 3.

1. In your flash file, create two buttons on top of each other,

“fullscreen_btn”
“exitfullscreen_btn”

2. Open up your actionscript window and put this code in.

exitfullscreen_btn.visible = false;

fullscreen_btn.addEventListener(MouseEvent.CLICK, fullScreen);

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

fullscreen_btn.visible = false;
exitfullscreen_btn.visible = true;
}

exitfullscreen_btn.addEventListener(MouseEvent.CLICK, exitullScreen);

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

fullscreen_btn.visible = true;
exitfullscreen_btn.visible = false;
}

If you have any questions or suggestions, leave it in the comments!

  • Share/Bookmark
Actionscript 3 Button to Switch Between Fullscreen and Normal States