You are on page 1of 1

Avatar.

as
class Avatar extends MovieClip
{
public static var HAPPY:Number = 0;
public static var SAD:Number = 1;
public static var IDLE:Number = 2;
public static function createAvatar (name:String, target:MovieClip,
depth:Number, x:Number, y:Number):Avatar
{
var av:Avatar = Avatar(target.attachMovie("AvatarSymbol", name, depth));
av.init(x, y);
return av;
}
public function init (x:Number, y:Number):Void
{
setState(Avatar.HAPPY);
this._x = x;
this._y = y;
}
public function setState(newState:Number):Void
{
switch (newState) {
case Avatar.HAPPY:
this.gotoAndStop("HAPPY");
break;
case Avatar.SAD:
this.gotoAndStop("SAD");
break;
case Avatar.IDLE:
this.gotoAndStop("IDLE");
break;
}
}
}

You might also like