User:Genesisprods

Flash Avatar Creation/ActionScript Functions
If you have never created an avatar for Whirled, you probably want to look into their Simple avatar (Flash tutorial). If you feel sufficiently experienced, feel free to move forward with the more advanced steps below. After becoming familiar with this tutorial, move on to the Remixable avatar (Flash tutorial).

Basic Settings
You can configure your basic document properties under Modify &rarr; Document....
 * Dimensions: An avatar may be any size under the maximum of 600(wide)x450(tall) pixels.
 * Frame rate: All Whirled avatars must be 30 frames per second.
 * Background color: You can use any background color you like, but it won't appear in Whirled.

State Changed
Changes the avatar's speed depending on which state it's in

import com.whirled.ControlEvent;

_ctrl.addEventListener(ControlEvent.STATE_CHANGED, stateChanged);

function stateChanged(event:ControlEvent):void { switch(event.name) { case "Battle":			// If in the Sprint Mode state set move speed to 400 _ctrl.setMoveSpeed(m); _ctrl.setHotSpot(x,y,z); _ctrl.registerActions; break;

default:					// If in any other state set move speed to 110 _ctrl.setMoveSpeed(m); _ctrl.setHotSpot(x,y,z); _ctrl.registerStates("Battle",...); _ctrl.registerActions("Attack"...); break; } }

Bounce on Speak
Makes the avatar bounce when the user speaks

import com.whirled.ControlEvent;

_ctrl.addEventListener(ControlEvent.AVATAR_SPOKE, startBounce);

// Starts the bouncing animation function startBounce(event:ControlEvent):void { bounceCounter = -Math.PI / 2; bounce; this.addEventListener(Event.ENTER_FRAME, bounce); }

// Shows the avatar's bounce animation over time based on a sine wave equation function bounce(event:Event = null):void { bounceCounter += Math.PI / 5; var sizeOffset:Number = (Math.sin(bounceCounter) * 0.5 + 0.5) * 0.05; //The amount to scale the avatar var orientMult:Number = (_ctrl.getOrientation < 180 ? -1 : 1); // -1 if right, 1 if left // Changes the avatar's X and Y scales this.scaleX = orientMult - sizeOffset * orientMult * 2; this.scaleY = 1 + sizeOffset; // Readjusts the position of the avatar inside its parent clip so	// it appears to stay in place, instead of sliding back and forth this.x = hotSpot.x - hotSpot.x * this.scaleX; this.y = hotSpot.y - hotSpot.y * this.scaleY; if(bounceCounter > Math.PI * 3 / 2) { // If the animation has played through once, stop it		this.removeEventListener(Event.ENTER_FRAME, bounce); } }

var bounceCounter:Number; // Keeps track of the passing of time var hotSpot:Point = new Point(x,y); // This avatar's hotspot