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