Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.events.Event;
  2. import com.whirled.AvatarControl;
  3. import com.whirled.ControlEvent;
  4. import com.whirled.EntityControl;
  5.  
  6. if (_ctrl == null) {
  7.     _ctrl = new AvatarControl(this);
  8.     _ctrl.setHotSpot(300, 370, 250);
  9.     _body = new Body(_ctrl,this,600);
  10.     addEventListener(Event.UNLOAD, handleUnload);
  11.     _ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, handleAction);
  12.     _ctrl.addEventListener(ControlEvent.STATE_CHANGED, handleState);
  13.     function handleUnload(... ignored):void {
  14.         timer.stop();
  15.         timer.removeEventListener(TimerEvent.TIMER, timeCount);
  16.         _body.shutdown();
  17.     }
  18. }
  19.  
  20. function timeCount(e:TimerEvent):void {
  21.     _popup.timeSeconds.text = String(timer.currentCount +prevCount);
  22.     if (timer.currentCount + prevCount >= 30) {
  23.         _popup.rank.gotoAndStop(2);
  24.     } if (timer.currentCount + prevCount >= 100) {
  25.         _popup.rank.gotoAndStop(3);
  26.     }
  27.     totalCount = timer.currentCount + prevCount;
  28.     _ctrl.setMemory("timerCount", timer.currentCount + prevCount);
  29. }
  30.  
  31. function handleAction(e:ControlEvent):void {
  32.     switch (e.name) {
  33.         case "Rank" :
  34.             _ctrl.showPopup("Ranks", _popup as DisplayObject, _popup.width, _popup.height);
  35.             break;
  36.     }
  37. }
  38.  
  39. function handleState(o:Object = null):void {
  40.     _ctrl.registerStates(getStateInfo());
  41.     switch (_ctrl.getState()) {
  42.         case "Primary" :
  43.             _ctrl.registerActions("PFire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
  44.             break;
  45.         case "Secondary" :
  46.             _ctrl.registerActions("SFire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
  47.             break;
  48.         case "Default" :
  49.             _ctrl.registerActions("Toggle Outline ON", "Toggle Outline OFF", "Rank");
  50.             break;
  51.     }
  52. }
  53.  
  54. function getStateInfo():Array {
  55.     var stateArray:Array = new Array();
  56.     stateArray.push("Primary");
  57.     // Template Example:
  58.     // if (totalCount >= 9001) {
  59.     //      stateArray.push("StateNewOne", "StateNewTwo");
  60.     //  }
  61.     //  Information:
  62.     // 9001: Level Unlocked
  63.     // "StateNewOne", "StateNewTwo" : New States
  64.    
  65.     // For example:
  66.     if (totalCount >= 100) { // After Level 100...
  67.         stateArray.push("Secondary", "Default"); // ...unlock "Secondary" and "Default".
  68.     }
  69.     return stateArray;
  70. }
  71.  
  72. var totalCount:Number = new Number();
  73.  
  74. var _popup:Popup = new Popup();
  75.  
  76. var timer:Timer = new Timer(1000, 0);
  77.     timer.addEventListener(TimerEvent.TIMER, timeCount);
  78.     timer.start();
  79.    
  80. var prevCount:Number = Number(_ctrl.getMemory("timerCount", 0));
  81.  
  82. var _ctrl:AvatarControl;
  83. var _body:Body;
  84. var dlsa:DuelingLandSeaAnimal = new DuelingLandSeaAnimal(_ctrl, ["PrimaryB","SecondaryB", "MeleeB", "RPGB", "GrenadeB"], ["PFire Battle","SFire Battle", "MeleeB", "RFire Battle", "GThrow Battle"], ["Dead"]);
  85.  
  86. handleState();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement