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;
- import com.whirled.EntityControl;
- if (_ctrl == null) {
- _ctrl = new AvatarControl(this);
- _ctrl.setHotSpot(300, 370, 250);
- _body = new Body(_ctrl,this,600);
- addEventListener(Event.UNLOAD, handleUnload);
- _ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, handleAction);
- _ctrl.addEventListener(ControlEvent.STATE_CHANGED, handleState);
- function handleUnload(... ignored):void {
- timer.stop();
- timer.removeEventListener(TimerEvent.TIMER, timeCount);
- _body.shutdown();
- }
- }
- function timeCount(e:TimerEvent):void {
- _popup.timeSeconds.text = String(timer.currentCount +prevCount);
- if (timer.currentCount + prevCount >= 30) {
- _popup.rank.gotoAndStop(2);
- } if (timer.currentCount + prevCount >= 100) {
- _popup.rank.gotoAndStop(3);
- }
- totalCount = timer.currentCount + prevCount;
- _ctrl.setMemory("timerCount", timer.currentCount + prevCount);
- }
- function handleAction(e:ControlEvent):void {
- switch (e.name) {
- case "Rank" :
- _ctrl.showPopup("Ranks", _popup as DisplayObject, _popup.width, _popup.height);
- break;
- }
- }
- function handleState(o:Object = null):void {
- _ctrl.registerStates(getStateInfo());
- switch (_ctrl.getState()) {
- case "Primary" :
- _ctrl.registerActions("PFire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
- break;
- case "Secondary" :
- _ctrl.registerActions("SFire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
- break;
- case "Default" :
- _ctrl.registerActions("Toggle Outline ON", "Toggle Outline OFF", "Rank");
- break;
- }
- }
- function getStateInfo():Array {
- var stateArray:Array = new Array();
- stateArray.push("Primary");
- // Template Example:
- // if (totalCount >= 9001) {
- // stateArray.push("StateNewOne", "StateNewTwo");
- // }
- // Information:
- // 9001: Level Unlocked
- // "StateNewOne", "StateNewTwo" : New States
- // For example:
- if (totalCount >= 100) { // After Level 100...
- stateArray.push("Secondary", "Default"); // ...unlock "Secondary" and "Default".
- }
- return stateArray;
- }
- var totalCount:Number = new Number();
- var _popup:Popup = new Popup();
- var timer:Timer = new Timer(1000, 0);
- timer.addEventListener(TimerEvent.TIMER, timeCount);
- timer.start();
- var prevCount:Number = Number(_ctrl.getMemory("timerCount", 0));
- 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"]);
- handleState();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement