Object | +-Stage public class Stage extends Object The Stage class is a top-level class whose methods, properties, and handlers you can access without using a constructor. Use the methods and properties of this class to access and manipulate information about the boundaries of a SWF file. Availability: ActionScript 1.0; Flash Player 5 - (became a native object in Flash Player 6, which improved performance significantly). Property summary
Properties inherited from class Object
Event summary
Method summary
Methods inherited from class Object
addListener (Stage.addListener method)public static addListener(listener:Object) : Void Detects when a SWF file is resized (but only if Stage.scaleMode = "noScale"). The addListener() method doesn't work with the default movie clip scaling setting (showAll) or other scaling settings (exactFit and noBorder). To use addListener(), you must first create a listener object. Stage listener objects receive notification from Stage.onResize. Availability: ActionScript 1.0; Flash Player 6 Parameters listener:Object - An object that listens for a callback notification from the Stage.onResize event. Example This example creates a new listener object called stageListener. It then uses stageListener to call onResize and define a function that will be called when onResize is triggered. Finally, the code adds the stageListener object to the callback list of the Stage object. Listener objects allow multiple objects to listen for resize notifications. this.createTextField("stageSize_txt", this.getNextHighestDepth(), 10, 10, 100, 22); var stageListener:Object = new Object(); stageListener.onResize = function() { stageSize_txt.text = "w:"+Stage.width+", h:"+Stage.height; }; Stage.scaleMode = "noScale"; Stage.addListener(stageListener); See also onResize (Stage.onResize event listener), removeListener (Stage.removeListener method) align (Stage.align property)public static align : String Indicates the current alignment of the SWF file in the player or browser. The following table lists the values for the align property. Any value not listed here centers the SWF file in Flash player or browser area, which is the default setting.
Availability: ActionScript 1.0; Flash Player 6 Example The following example demonstrates different alignments of the SWF file. Add a ComboBox instance to your document with the instance name stageAlign_cb. Add the following ActionScript to your FLA or AS file: var stageAlign_cb:mx.controls.ComboBox; stageAlign_cb.dataProvider = ['T', 'B', 'L', 'R', 'TL', 'TR', 'BL', 'BR']; var cbListener:Object = new Object(); cbListener.change = function(evt:Object) { var align:String = evt.target.selectedItem; Stage.align = align; }; stageAlign_cb.addEventListener("change", cbListener); Stage.scaleMode = "noScale"; Select different alignment settings from the ComboBox. height (Stage.height property)public static height : Number Property (read-only); indicates the current height, in pixels, of the Stage. When the value of Stage.scaleMode is noScale, the height property represents the height of Flash Player. When the value of Stage.scaleMode is not noScale, height represents the height of the SWF file. Availability: ActionScript 1.0; Flash Player 6 Example This example creates a new listener object called stageListener. It then uses myListener to call onResize and define a function that will be called when onResize is triggered. Finally, the code adds the myListener object to the callback list of the Stage object. Listener objects allow multiple objects to listen for resize notifications. this.createTextField("stageSize_txt", this.getNextHighestDepth(), 10, 10, 100, 22); var stageListener:Object = new Object(); stageListener.onResize = function() { stageSize_txt.text = "w:"+Stage.width+", h:"+Stage.height; }; Stage.scaleMode = "noScale"; Stage.addListener(stageListener); See also align (Stage.align property), scaleMode (Stage.scaleMode property), width (Stage.width property) onResize (Stage.onResize event listener)onResize = function() {} Invoked when Stage.scaleMode is set to noScale and the SWF file is resized. You can use this event handler to write a function that lays out the objects on the Stage when a SWF file is resized. myListener.onResize = function()[ // your statements here } Availability: ActionScript 1.0; Flash Player 6 Example The following example displays a message in the Output panel when the Stage is resized: Stage.scaleMode = "noScale" var myListener:Object = new Object(); myListener.onResize = function () { trace("Stage size is now " + Stage.width + " by " + Stage.height); } Stage.addListener(myListener); // later, call Stage.removeListener(myListener) See also scaleMode (Stage.scaleMode property), addListener (Stage.addListener method), removeListener (Stage.removeListener method) removeListener (Stage.removeListener method)public static removeListener(listener:Object) : Boolean Removes a listener object created with addListener(). Availability: ActionScript 1.0; Flash Player 6 Parameters listener:Object - An object added to an object's callback list with addListener(). Returns Boolean - A Boolean value. Example The following example displays the Stage dimensions in a dynamically created text field. When you resize the Stage, the values in the text field update. Create a button with an instance name remove_btn. Add the following ActionScript to Frame 1 of the Timeline. this.createTextField("stageSize_txt", this.getNextHighestDepth(), 10, 10, 100, 22); stageSize_txt.autoSize = true; stageSize_txt.border = true; var stageListener:Object = new Object(); stageListener.onResize = function() { stageSize_txt.text = "w:"+Stage.width+", h:"+Stage.height; }; Stage.addListener(stageListener); remove_btn.onRelease = function() { stageSize_txt.text = "Removing Stage listener..."; Stage.removeListener(stageListener); } Select Control > Test Movie to test this example. The values you see in the text field are updated when you resize the testing environment. When you click remove_btn, the listener is removed and the values are no longer updated in the text field. See also addListener (Stage.addListener method) scaleMode (Stage.scaleMode property)public static scaleMode : String Indicates the current scaling of the SWF file within Flash Player. The scaleMode property forces the SWF file into a specific scaling mode. By default, the SWF file uses the HTML parameters set in the Publish Settings dialog box. The scaleMode property can use the values "exactFit", "showAll", "noBorder", and "noScale". Any other value sets the scaleMode property to the default "showAll".
Note The default setting is showAll, except when in test movie mode, where the default setting is noScale. Availability: ActionScript 1.0; Flash Player 6 Example The following example demonstrates various scale settings for the SWF file. Add a ComboBox instance to your document with the instance name scaleMode_cb. Add the following ActionScript to your FLA or AS file: var scaleMode_cb:mx.controls.ComboBox; scaleMode_cb.dataProvider = ["showAll", "exactFit", "noBorder", "noScale"]; var cbListener:Object = new Object(); cbListener.change = function(evt:Object) { var scaleMode_str:String = evt.target.selectedItem; Stage.scaleMode = scaleMode_str; }; scaleMode_cb.addEventListener("change", cbListener); To view another example, see the stagesize.fla file in the ActionScript samples Folder. The following list provides typical paths to the ActionScript samples Folder:
showMenu (Stage.showMenu property)public static showMenu : Boolean Specifies whether to show or hide the default items in the Flash Player context menu. If showMenu is set to TRue (the default), all context menu items appear. If showMenu is set to false, only Settings and About Macromedia Flash Player items appear. Availability: ActionScript 1.0; Flash Player 6 Example The following example creates a clickable text link that lets the user enable and disable the Flash Player context menu. this.createTextField("showMenu_txt", this.getNextHighestDepth(), 10, 10, 100, 22); showMenu_txt.html = true; showMenu_txt.autoSize = true; showMenu_txt.htmlText = "<a href=\"asfunction:toggleMenu\"><u>Stage.showMenu = "+Stage.showMenu+"</ u></a>"; function toggleMenu() { Stage.showMenu = !Stage.showMenu; showMenu_txt.htmlText = "<a href=\"asfunction:toggleMenu\"><u>Stage.showMenu = "+Stage.showMenu+"</ u></a>"; } See also ContextMenu, ContextMenuItem width (Stage.width property)public static width : Number Property (read-only); indicates the current width, in pixels, of the Stage. When the value of Stage.scaleMode is "noScale", the width property represents the width of Flash Player. This means that Stage.width will vary as you resize the player window. When the value of Stage.scaleMode is not "noScale", width represents the width of the SWF file as set at author-time in the Document Properties dialog box. This means that the value of width will stay constant as you resize the player window. Availability: ActionScript 1.0; Flash Player 6 Example This example creates a new listener object called stageListener. It then uses stageListener to call onResize and define a function that will be called when onResize is triggered. Finally, the code adds the stageListener object to the callback list of the Stage object. Listener objects allow multiple objects to listen for resize notifications. this.createTextField("stageSize_txt", this.getNextHighestDepth(), 10, 10, 100, 22); var stageListener:Object = new Object(); stageListener.onResize = function() { stageSize_txt.text = "w:"+Stage.width+", h:"+Stage.height; }; Stage.scaleMode = "noScale"; Stage.addListener(stageListener); See also align (Stage.align property), height (Stage.height property), scaleMode (Stage.scaleMode property) |