Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.events.Event;
- import com.whirled.AvatarControl;
- import com.whirled.ControlEvent; // This is necessary for moving the Action to Main.
- import com.whirled.EntityControl; // Incase you need it later. :D
- if (_ctrl == null) {
- _ctrl = new AvatarControl(this);
- _ctrl.setHotSpot(300, 370, 250);
- _body = new Body(_ctrl,this,600);
- //Ranks.as Below //
- addEventListener(Event.UNLOAD, handleUnload);
- _ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, handleAction); // If we trigger an action, handleAction fires.
- function handleUnload(... ignored):void {
- // This function fires when the Avatar is unloaded.
- // This could happen for a variety of reasons, such as:
- // 1) Changing rooms.
- // 2) Switching avatars.
- // 3) Closing the browser.
- timer.stop(); // Stop the Timer, to prevent any problems.
- timer.removeEventListener(TimerEvent.TIMER, timeCount); // And then remove the Event Listener.
- _body.shutdown();
- }
- }
- // Rank Changes //
- function timeCount(e:TimerEvent):void {
- _popup.timeSeconds.text = String(timer.currentCount +prevCount);
- //Rank Changes
- if (timer.currentCount + prevCount >= 30) { // We have to take in account also the previous Counts.
- _popup.rank.gotoAndStop(2); // We go to the second Frame. No need to save this.
- } if (timer.currentCount + prevCount >= 100) {
- _popup.rank.gotoAndStop(3);
- //Function to Register States/Actions
- function handleState(o:Object = null):void {
- switch (_ctrl.getState()) {
- case "Primary" :
- _ctrl.registerStates("Primary", "Secondary", "Rarestate");
- _ctrl.registerActions("PFire", "SFire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
- break;
- }
- }
- }
- _ctrl.setMemory("timerCount", timer.currentCount + prevCount); // When we save it, we save the currentCount plus the previous Count.
- }
- ////////////////
- function handleAction(e:ControlEvent):void {
- switch (e.name) {
- case "Rank" :
- _ctrl.showPopup("Ranks", _popup as DisplayObject, _popup.width, _popup.height);
- break;
- }
- }
- var _popup:Popup = new Popup();
- var timer:Timer = new Timer(1000, 0); // Create a new Timer...
- timer.addEventListener(TimerEvent.TIMER, timeCount); // ...add the Event...
- timer.start(); // ...and Start it.
- var prevCount:Number = Number(_ctrl.getMemory("timerCount", 0));
- // This variable will hold how many times the Timer has fired before.
- // _ctrl.getMemory("timerCount", 0)
- // "timerCount" : Name of the Memory
- // 0 : Default Value
- // Basically, instead of checking if it's null, and setting it if it is,
- // we use the Default Value so that if it's null, it uses the Defalt.
- // STOP
- var _ctrl:AvatarControl;
- var _body:Body;
- 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