User Guide

174 Display Programming
In addition, a user can choose to leave full-screen mode by switching focus to a different
window or by pressing one of several key combinations: the escape key (all platforms), ctrl-w
(Windows), cmd-w (Mac), or alt-F4 (Windows).
Stage scaling behavior for full-screen mode is the same as under normal mode; the scaling is
controlled by the Stage classs
scaleMode property. As always, if the scaleMode property is set
to
StageScaleMode.NO_SCALE, the stages stageWidth and stageHeight properties change
to reflect the size of the screen area occupied by the SWF (the entire screen, in this case).
You can use the Stage classs
fullScreen event to detect and respond when full-screen mode
is turned on or off. For example, you might want to reposition, add, or remove items from the
screen when entering or leaving full-screen mode, as in this example:
import flash.events.FullScreenEvent;
function fullScreenRedraw(event:FullScreenEvent):void
{
if (event.fullScreen)
{
// remove input text fields
// add a button which closes full-screen mode
}
else
{
// re-add input text fields
// remove the button which closes full-screen mode
}
}
mySprite.stage.addEventListener(FullScreenEvent.FULL_SCREEN,
fullScreenRedraw);
As this code shows, the event object for the fullScreen event is an instance of the
flash.events.FullScreenEvent class, which includes a
fullScreen property indicating whether
full-screen mode is enabled (
true) or not (false).
When working with full-screen mode in ActionScript, you’ll want to keep the following
considerations in mind:
Full-screen mode can only be initiated through ActionScript in response to a mouse click
(including right-click) or keypress.
For users with multiple monitors, the SWF content will only expand to fill one monitor.
Flash Player uses a metric to determine which monitor contains the greatest portion of the
SWF, and uses that monitor for full-screen mode.
For a SWF file embedded in an HTML page, the HTML code to embed Flash Player
must include a
<param> tag and <embed> attribute with name allowFullScreen and
value
true, such as this: