Stage.width Property | Flash 6 |
pixel width of the available Flash Player display area or the author-time document | read-only |
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 Document
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.
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.
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.
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);
MovieClip._width, Stage.addListener( ), Stage.height, Stage.onResize( )