Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
81
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; // This is necessary for moving the Action to Main.
  4. import com.whirled.EntityControl; // Incase you need it later. :D
  5.  
  6. if (_ctrl == null) {
  7.     _ctrl = new AvatarControl(this);
  8.     _ctrl.setHotSpot(300, 370, 250);
  9.     _body = new Body(_ctrl,this,600);
  10.     //Rank Below
  11.     addEventListener(Event.UNLOAD, handleUnload);
  12.     _ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, handleAction); // If we trigger an action, handleAction fires.
  13.     function handleUnload(... ignored):void {
  14.         // This function fires when the Avatar is unloaded.
  15.         // This could happen for a variety of reasons, such as:
  16.         // 1) Changing rooms.
  17.         // 2) Switching avatars.
  18.         // 3) Closing the browser.
  19.         timer.stop(); // Stop the Timer, to prevent any problems.
  20.         timer.removeEventListener(TimerEvent.TIMER, timeCount); // And then remove the Event Listener.
  21.         _body.shutdown();
  22.     }
  23. }
  24.  
  25. function timeCount(e:TimerEvent):void {
  26.     _popup.timeSeconds.text = String(timer.currentCount +prevCount);
  27.     //Rank Changes
  28.     if (timer.currentCount + prevCount >= 30) { // We have to take in account also the previous Counts.
  29.         _popup.rank.gotoAndStop(2); // We go to the second Frame. No need to save this.
  30.     } else if (timer.currentCount + prevCount >= 100) {
  31.         _popup.rank.gotoAndStop(3);
  32.     }
  33.     _ctrl.setMemory("timerCount", timer.currentCount + prevCount); // When we save it, we save the currentCount plus the previous Count.
  34. }
  35.  
  36. function handleAction(e:ControlEvent):void {
  37.     switch (e.name) {
  38.         case "Rank" :
  39.             _ctrl.showPopup("Ranks", _popup as DisplayObject, _popup.width, _popup.height);
  40.             break;
  41.     }
  42. }
  43.  
  44. var _popup:Popup = new Popup();
  45.  
  46. var timer:Timer = new Timer(1000, 0); // Create a new Timer...
  47.     timer.addEventListener(TimerEvent.TIMER, timeCount); // ...add the Event...
  48.     timer.start(); // ...and Start it.
  49.    
  50. var prevCount:Number = Number(_ctrl.getMemory("timerCount", 0));
  51.     // This variable will hold how many times the Timer has fired before.
  52.     // _ctrl.getMemory("timerCount", 0)
  53.     // "timerCount" : Name of the Memory
  54.     // 0 : Default Value
  55.     // Basically, instead of checking if it's null, and setting it if it is,
  56.     // we use the Default Value so that if it's null, it uses the Defalt.
  57.    
  58. // STOP
  59.  
  60. var _ctrl:AvatarControl;
  61. var _body:Body;
  62. var dlsa:DuelingLandSeaAnimal = new DuelingLandSeaAnimal(_ctrl, ["PrimaryB","SecondaryB", "MeleeB", "RPGB", "GrenadeB"], ["PFire Battle","SFire Battle", "MeleeB", "RFire Battle", "GThrow Battle"], ["Dead"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement