Guest User

Untitled

a guest
Jan 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import flash.events.Event;
  2. import com.whirled.ControlEvent;
  3. import com.whirled.AvatarControl;
  4.  
  5. if (_ctrl == null) {
  6. _ctrl = new AvatarControl(this);
  7. _body = new Body(_ctrl, this, 560);
  8. _ctrl.setHotSpot(255, 400);
  9. _ctrl.addEventListener(Event.UNLOAD, handleUnload);
  10. function handleUnload (... ignored) :void {
  11. _body.shutdown();
  12. }
  13. }
  14.  
  15. var _ctrl :AvatarControl;
  16. var _body :Body;
  17.  
  18. _ctrl.setMoveSpeed(250);
  19.  
  20. // This code will change the speed with the selected state
  21.  
  22. _ctrl.addEventListener(ControlEvent.STATE_CHANGED, stateChanged);
  23.  
  24. function stateChanged(event:ControlEvent):void {
  25. switch(event.name) {
  26. case "Run":
  27. _ctrl.setMoveSpeed(600);
  28. break;
  29.  
  30. case "Lay":
  31. _ctrl.setMoveSpeed(175);
  32. break;
  33.  
  34.  
  35. default:
  36. _ctrl.setMoveSpeed(250);
  37. break;
  38. }
  39. }
Add Comment
Please, Sign In to add comment