Access keys

StatedMovieClip

Kind of class: class
Inherits from: CoreMovieClip < MovieClip
Known subclasses:
Version: 11/29/06
Author: Toby Boudreaux, David Nelson, Aaron Clinger
Classpath: org.casaframework.movieclip.StatedMovieClip
File last modified: Monday, 08 January 2007, 09:57:51
Provides state-switching mechanism for MovieClip EventHandlers and properties.
Example:
this.attachMovie("statedMovieClip", "stated_mc", 20);

this.stated_mc.onRelease = function():Void {
    trace("onRelease on " + this._name + " was called. Example one.");
}

this.stated_mc.createState("exampleButtonOne");

this.stated_mc.onRelease = function():Void {
    trace("onRelease on " + this._name + " was called. Example two.");
}

this.stated_mc.createState("exampleButtonTwo");

Now you can switch between the states, example:
this.stated_mc.switchState("exampleButtonOne"); or this.stated_mc.switchState("exampleButtonTwo");

To return to the default creation state (no EventHandlers) call:
this.stated_mc.switchState("default");
Usage note:
Class creates "default" state on MovieClip instance creation.

Summary

Instance methods

createState

function createState (
stateName:String, inclusionList:Array) : Void
Creates a new state and records EventHandlers.
Parameters:
stateName :
Unique name for MovieClip state.
inclusionList:
[optional] List of EventHandlers and properties to include. Defaults to all MovieClip EventHandlers.
Usage note:
If parameter stateName is identical to previously created state, createState will overwrite it.
Example:
this.stated_mc.createState("uniqueStateName", new Array("onRollOver", "onRollOut", "onRelease"));

destroy

function destroy (
) : Void

getState

function getState (
) : String
Returns the current state of MovieClip. If no state has been created getState will return "default".
Returns:
The name of current MovieClip state.
Usage note:
getState will always return last created or switched to state.

removeKeyValueForState

function removeKeyValueForState (
stateName:String, keyName:String) : Boolean
Removes/unregisters value from MovieClip property for a given state.
Parameters:
stateName:
Name of precreated MovieClip state.
keyName :
Name of any MovieClip property or EventHandler.
Returns:
Returns true if the key was successfully found and removed from EventHandler state; otherwise false.

removeState

function removeState (
stateName:String) : Boolean
Deletes precreated MovieClip state.
Parameters:
stateName:
Name of precreated MovieClip state.
Returns:
Returns true if the state was successfully found and removed; otherwise false.

setKeyValueForState

function setKeyValueForState (
stateName:String, keyName:String, value:Object) : Void
Registers single value to a MovieClip property for a given state.
Parameters:
stateName:
Name of precreated MovieClip state, or new state.
keyName :
Name of any MovieClip property or EventHandler.
value :
Value of MovieClip property or EventHandler specified by parameter keyName.
Example:
var anonymousFunction:Function = function():Void {
    trace("onRollOver");
} 

this.stated_mc.setKeyValueForState("stateName", "onRollOver", anonymousFunction);

You can define any MovieClip properties, not just event handlers. Such as _alpha, _x, _yscale etc...:
this.stated_mc.setKeyValueForState("stateName", "_alpha", 25);

switchState

function switchState (
stateName:String, inclusionList:Array) : Boolean
Switches MovieClip's current state to a precreated state.
Parameters:
stateName :
Name of precreated MovieClip state.
inclusionList:
[optional] List of EventHandlers and properties to include/switch state of. Defaults to all MovieClip EventHandlers.
Returns:
Returns true if the precreated state was found and the MovieClip's state was successfully changed; otherwise false.
Example:
this.stated_mc.switchState("uniqueStateName", new Array("onEnterFrame", "onRelease"));
See also: