Stage.height Property

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

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

Description

The integer height property indicates the pixel height of the movie, depending on the setting of Stage.scaleMode. When scaleMode is set to "noScale", height 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", height 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 height may not match the dimensions set at authoring time. In a browser or the Standalone Player, scaleMode defaults to "showAll", so height matches the dimensions set at authoring time unless scaleMode is explicitly set to "noScale".

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

Usage

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

Bugs

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

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

Example

The following code creates a text field and centers it on stage:

Stage.scaleMode = "noScale"; Stage.align = "LT";     this.createTextField("theField_txt", 1, 0, 0, 200, 20); theField_txt.text = "Derek got a haircut."; theField_txt._x = Stage.width/2 - theField_txt._width/2; theField_txt._y = Stage.height/2 - theField_txt._height/2;

See Also

MovieClip.createTextField( ), MovieClip._height, Stage.addListener( ), Stage.onResize( ), Stage.width, the TextField class



    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