Stage.width Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Stage.width Property Flash 6

pixel width of the available Flash Player display area or the author-time document read-only
Stage.width

Description

The integer width property indicates the pixel width of the movie, depending on the setting of Stage.scaleMode. When scaleMode is set to "noScale", width reports the size of the Flash Player's available display area either the Standalone Player window's dimensions or the current size of the OBJECT/EMBED region in the browser. When scaleMode is not set to "noScale", width reports the size of the Flash movie as specified at authoring time via Modify figs/u2192.gif Document figs/u2192.gif Dimensions.

In Test Movie mode, scaleMode defaults to "noScale", so width may not match the dimensions set at authoring time. In a browser or the Standalone Player, scaleMode defaults to "showAll", so width matches the dimensions set at authoring time unless scaleMode is explicitly set to "noScale".

To receive notification when Stage.width changes, add listeners for the Stage.onResize( ) listener event.

Usage

Don't confuse Stage.width with _root._width. The former is the width of the available Player space or the specified document dimensions, whereas the latter is the width of all objects on the main movie timeline.

Bugs

When scaleMode is "noScale" and width is accessed on the first few frames of a movie, an incorrect value may be reported. For safety, wait several frames before accessing width, or, better yet, access it only within an onResize( ) listener.

In Test Movie mode, the width of the movie is reported as four pixels less than actual size.

Example

The following code uses MovieClip drawing methods to draw a line across the entire width of the Stage, 30 pixels below its top border:

Stage.scaleMode = "noScale"; Stage.align = "LT";     this.lineStyle(1); this.moveTo(0, 30); this.lineTo(Stage.width, 30);

See Also

MovieClip._width, Stage.addListener( ), Stage.height, Stage.onResize( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net