topical media & game development
actionscript-events-ToggleSwitch.ax
actionscript-events-ToggleSwitch.ax
[swf]
flex
package {
import flash.display.*;
import flash.events.*;
// Represents a simple toggle-switch widget
public class @ax-actionscript-events-ToggleSwitch extends Sprite {
// Stores the state of the switch
private var isOn:Boolean;
// Constructor
public function @ax-actionscript-events-ToggleSwitch () {
// The switch is off by default
isOn = false;
}
// Turns the switch on if it is currently off, or off if it is
// currently on
public function toggle ():void {
// Toggle the switch state
isOn = !isOn;
// Ask ActionScript to dispatch a ToggleEvent.TOGGLE event, targeted
// at this @ax-actionscript-events-ToggleSwitch object
dispatchEvent(new actionscript_events_ToggleEvent(actionscript_events_ToggleEvent.TOGGLE, true, false, isOn));
}
}
}
(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.