Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.events.Event;
- import com.whirled.ControlEvent;
- import com.whirled.AvatarControl;
- if (_ctrl == null) {
- _ctrl = new AvatarControl(this);
- _body = new Body(_ctrl, this, 560);
- _ctrl.setHotSpot(255, 400);
- _ctrl.addEventListener(Event.UNLOAD, handleUnload);
- function handleUnload (... ignored) :void {
- _body.shutdown();
- }
- }
- var _ctrl :AvatarControl;
- var _body :Body;
- _ctrl.setMoveSpeed(250);
- // This code will change the speed with the selected state
- _ctrl.addEventListener(ControlEvent.STATE_CHANGED, stateChanged);
- function stateChanged(event:ControlEvent):void {
- switch(event.name) {
- case "Run":
- _ctrl.setMoveSpeed(600);
- break;
- case "Lay":
- _ctrl.setMoveSpeed(175);
- break;
- default:
- _ctrl.setMoveSpeed(250);
- break;
- }
- }
Add Comment
Please, Sign In to add comment