MovieClipBody.as

MovieClipBody.as is a newer method of handling animations using movieclips in Flash. The older method uses Body.as and scenes in Flash.

Items such as configurable avatars require the use of MovieClipBody.as.

Using MovieClipBody.as
A MovieClipBody.as avatar will have the same main scene code as the advanced avatar (Flash tutorial), but you will need to replace any mention of Body with MovieClipBody.

import flash.events.Event; import com.whirled.AvatarControl; if (_ctrl == null) { _ctrl = new AvatarControl(this); _body = new MovieClipBody(_ctrl, this, w); _ctrl.addEventListener(Event.UNLOAD, handleUnload); function handleUnload (... ignored) :void { _body.shutdown; } } var _ctrl :AvatarControl; var _body :MovieClipBody;
 * 1) Select the scene "main". If this is a new file, double-click "Scene 1" to rename it "main".
 * 2) Open the Actions window (F9).
 * 3) Paste in this code:
 * 4. Replace w with the width of your scene.

Making New States and Actions

 * 1) Make a movieClip that contains all the animation you want for that state/action/transition/incidental.
 * 2) Name the movieClip following the scene naming conventions from the Body.as tutorial linked above.  This is not the instance name, it is the Class name. For example you could have movieclips named state_Default, state_Default_walking, action_Laugh, Default_to_Dancing, and state_Default_01.95. (Use a period rather than a colon to reference incidentals. i.e. state_Default_01.95 rather than state_Default_01:95. See http://www.whirled.com/#groups-t_15103)
 * 3) For each of your movieClips, you will need to "Export for ActionScript." Right click the movieClip name, select Properties &rarr; Advanced &rarr; Export For ActionScript &rarr; OK &rarr; OK. This allows the code in MovieClipBody.as to access the state/action/transition/incidental.
 * 4) Repeat steps 1-3 for each new state/action/transition/incidental.

Making State Triggered States/Actions
To make a state triggered state, your code would look something like this:

_ctrl.addEventListener(ControlEvent.STATE_CHANGED, stateChanged);

function stateChanged(e:ControlEvent) : void { var stateName:String = e.name // This is the state they changed to   switch(stateName) { case "Egg": _ctrl.registerStates("Hatched"); break; case "Hatched": _ctrl.registerStates("Adult", "Foghorn Leghorn"); break; case "Adult": case "Foghorn Leghorn": _ctrl.registerStates("Egg"); break; } }

To make a state triggered action, the code would be similar, but there would be a _ctrl.registerActions("some actions"); call in there before the break statement. The same is true with walk speeds and the code would be a _ctrl.setMoveSpeed(number); call added before the break statement.