Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 1.46 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import flash.events.Event;
  2. import com.whirled.AvatarControl;
  3.  
  4. if (_ctrl == null) {
  5.         _ctrl = new AvatarControl(this);
  6.         _body = new Body(_ctrl, this, 240);
  7.         _ctrl.addEventListener(Event.UNLOAD, handleUnload);
  8.         function handleUnload (... ignored) :void {
  9.                 _body.shutdown();
  10.         }
  11. }
  12.  
  13. var _ctrl :AvatarControl;
  14. var _body :Body;
  15.  
  16. //Change the 0.2 below to change how high above the floor the avatar will appear once it is moved. 0 is the floor and 1 is the ceiling
  17. function fly():void{
  18.         updateRoom();
  19.         flyHeight = (roomSize[1] as int)*0.4;
  20.         _ctrl.setPreferredY(flyHeight);
  21. }
  22.  
  23. function unFly():void{
  24.         _ctrl.setPreferredY(0);
  25. }
  26.  
  27. function updateRoom():void{
  28.         roomSize = _ctrl.getRoomBounds();      
  29. }
  30.  
  31. var flyHeight:int = 0;
  32. var roomSize:Array = new Array(100,100,100);
  33.  
  34. _ctrl.addEventListener(ControlEvent.STATE_CHANGED, stateHandler);
  35. _ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, actionHandler);
  36.  
  37.  
  38. function stateCodeSwitch ()
  39. {
  40.         switch (_ctrl.getState())
  41.         {
  42.                 case "<statenamehere>":
  43.                 //code for that state like hotspot and movespeed
  44.                 break;
  45.                 /*
  46.                 just keep adding
  47.                 case "<statenamehere>":
  48.                 //code for that state like hotspot and movespeed
  49.                 break;
  50.                 for any other states you want to have altered coding for
  51.                 */
  52.                 default:
  53.                 //The hotspot and movespeed for the avatar when it's normal goes here
  54.                 break;
  55.         }
  56. }
  57.  
  58.  
  59. function stateHandler (event:ControlEvent)
  60. {
  61.         stateCodeSwitch();
  62. }
  63.  
  64. case "land":
  65.                 //coding
  66.                 break;