Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
58
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.     //Ranks.as 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. // Rank Changes //
  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.     } if (timer.currentCount + prevCount >= 100) {
  31.         _popup.rank.gotoAndStop(3);
  32.         //Function to Register States/Actions
  33.         function handleState(o:Object = null):void {
  34.         switch (_ctrl.getState()) {
  35.         case "Primary" :
  36.         _ctrl.registerStates("Primary", "Secondary", "Rarestate");
  37.         _ctrl.registerActions("PFire", "SFire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
  38.         break;
  39.     }
  40. }
  41.     }
  42.     _ctrl.setMemory("timerCount", timer.currentCount + prevCount); // When we save it, we save the currentCount plus the previous Count.
  43. }
  44. ////////////////
  45. function handleAction(e:ControlEvent):void {
  46.     switch (e.name) {
  47.         case "Rank" :
  48.             _ctrl.showPopup("Ranks", _popup as DisplayObject, _popup.width, _popup.height);
  49.             break;
  50.     }
  51. }
  52.  
  53. var _popup:Popup = new Popup();
  54.  
  55. var timer:Timer = new Timer(1000, 0); // Create a new Timer...
  56.     timer.addEventListener(TimerEvent.TIMER, timeCount); // ...add the Event...
  57.     timer.start(); // ...and Start it.
  58.    
  59. var prevCount:Number = Number(_ctrl.getMemory("timerCount", 0));
  60.     // This variable will hold how many times the Timer has fired before.
  61.     // _ctrl.getMemory("timerCount", 0)
  62.     // "timerCount" : Name of the Memory
  63.     // 0 : Default Value
  64.     // Basically, instead of checking if it's null, and setting it if it is,
  65.     // we use the Default Value so that if it's null, it uses the Defalt.
  66.    
  67. // STOP
  68.  
  69. var _ctrl:AvatarControl;
  70. var _body:Body;
  71. 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