A simple full screen toggle button in Flash AS3
11 Apr, 2011
Create a button and name it btn_fullsc on stage. Using the following code in action frame.
import flash.display.StageDisplayState;
function toggleFullScreen():void
{
if (stage.displayState == StageDisplayState.NORMAL) {
stage.displayState=StageDisplayState.FULL_SCREEN;
} else {
stage.displayState=StageDisplayState.NORMAL;
}
}
btn_fullsc.buttonMode = true;
btn_fullsc.addEventListener(MouseEvent.CLICK, buttonOnClick)
function buttonOnClick(event:MouseEvent):void
{
toggleFullScreen();
}
Compile and run the flash.
One more thing, make sure <param name="allowfullscreen" value="true" /> is added to the html page.
import flash.display.StageDisplayState;
function goFullScreen():void
{
if (stage.displayState == StageDisplayState.NORMAL) {
stage.displayState=StageDisplayState.FULL_SCREEN;
} else {
stage.displayState=StageDisplayState.NORMAL;
}
}
btn_fullsc.addEventListener(MouseEvent.CLICK, _handleClick)
function _handleClick(event:MouseEvent):void
{
goFullScreen();
}
function goFullScreen():void
{
if (stage.displayState == StageDisplayState.NORMAL) {
stage.displayState=StageDisplayState.FULL_SCREEN;
} else {
stage.displayState=StageDisplayState.NORMAL;
}
}
btn_fullsc.addEventListener(MouseEvent.CLICK, _handleClick)
function _handleClick(event:MouseEvent):void
{
goFullScreen();
}