topical media & game development
actionscript-events-SomeApp.ax
actionscript-events-SomeApp.ax
[swf]
flex
package {
import flash.display.*;
// A generic application that demonstrates the use of the custom
// ToggleEvent.TOGGLE event
public class @ax-actionscript-events-SomeApp extends Sprite {
// Constructor
public function @ax-actionscript-events-SomeApp () {
// Create a ToggleSwitch
var toggleSwitch:actionscript_events_ToggleSwitch = new actionscript_events_ToggleSwitch();
// Register for ToggleEvent.TOGGLE events
toggleSwitch.addEventListener(actionscript_events_ToggleEvent.TOGGLE,
toggleListener);
// Toggle the switch (normally the switch would be toggled by the
// user, but for demonstration purposes, we toggle
// it programmatically)
toggleSwitch.toggle();
}
// Listener executed whenever a ToggleEvent.TOGGLE event occurs
private function toggleListener (e:actionscript_events_ToggleEvent):void {
if (e.isOn) {
trace("The ToggleSwitch is now on.");
} else {
trace("The ToggleSwitch is now off.");
}
}
}
}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.