622
ActionScript classes
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.
Availability:
ActionScript 1.0; Flash Lite 2.0
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)
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...