STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
218911
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2393 · P4786

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/53008036?noj=FRM53008036-24DC" width="1" height="1"></div>

Galaxy Jumper - reach the end of the Galaxy in this online game.swf

This is the info page for
Flash #91103

(Click the ID number above for more basic data on this flash file.)


ActionScript [AS3]
Section 1
//Kgg (api.Kgg) package api { import flash.events.*; import flash.display.*; import flash.net.*; import flash.system.*; public class Kgg extends Sprite { public var k; public var s:Stage; public function Kgg(stage:Stage):void{ var loadComplete:Function; var stage = stage; super(); loadComplete = function (event:Event):void{ k = event.target.content; k.services.connect(); trace("KGG API LOADED"); }; s = stage; var paramObj:Object = LoaderInfo(s.loaderInfo).parameters; var apiPath:String = ((paramObj.kongregate_api_path) || ("http://www.kongregate.com/flash/API_AS3_Local.swf")); Security.allowDomain(apiPath); var request:URLRequest = new URLRequest(apiPath); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); loader.load(request); this.addChild(loader); Global.kgg = this; } } }//package api
Section 2
//MochiBot (api.MochiBot) package api { import flash.display.*; import flash.net.*; import flash.system.*; public class MochiBot extends Sprite { public function MochiBot(){ super(); } public static function track(parent:Sprite, tag:String, aim:String=""):MochiBot{ var nklink:URLRequest; if (Security.sandboxType == "localWithFile"){ return (null); }; var self:MochiBot = new (MochiBot); parent.addChild(self); Security.allowDomain("*"); Security.allowInsecureDomain("*"); var server:String = "http://core.mochibot.com/my/core.swf"; var lv:URLVariables = new URLVariables(); lv["sb"] = Security.sandboxType; lv["v"] = Capabilities.version; lv["swfid"] = tag; lv["mv"] = "8"; lv["fv"] = "9"; var url:String = self.root.loaderInfo.loaderURL; if (url.indexOf("http") == 0){ lv["url"] = url; } else { lv["url"] = "local"; }; var req:URLRequest = new URLRequest(server); req.contentType = "application/x-www-form-urlencoded"; req.method = URLRequestMethod.POST; req.data = lv; var loader:Loader = new Loader(); self.addChild(loader); loader.load(req); if (aim != ""){ trace(("MOCHIBOT > Goto URL " + aim)); nklink = new URLRequest(aim); navigateToURL(nklink, "_blank"); }; return (self); } public static function trackUrl(parent:Sprite, tag:String, aim:String):MochiBot{ trace("MOCHIBOT > click"); return (_slot1.track(parent, tag, aim)); } } }//package api
Section 3
//PropTween (com.greensock.core.PropTween) package com.greensock.core { public class PropTween { public var priority:int; public var start:Number; public var prevNode:PropTween; public var change:Number; public var target:Object; public var name:String; public var property:String; public var nextNode:PropTween; public var isPlugin:Boolean; public function PropTween(target:Object, property:String, start:Number, change:Number, name:String, isPlugin:Boolean, nextNode:PropTween=null, priority:int=0){ super(); this.target = target; this.property = property; this.start = start; this.change = change; this.name = name; this.isPlugin = isPlugin; if (nextNode){ nextNode.prevNode = this; this.nextNode = nextNode; }; this.priority = priority; } } }//package com.greensock.core
Section 4
//SimpleTimeline (com.greensock.core.SimpleTimeline) package com.greensock.core { public class SimpleTimeline extends TweenCore { public var autoRemoveChildren:Boolean; protected var _lastChild:TweenCore; protected var _firstChild:TweenCore; public function SimpleTimeline(vars:Object=null){ super(0, vars); } override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void{ var dur:Number; var next:TweenCore; var tween:TweenCore = _firstChild; this.cachedTotalTime = time; this.cachedTime = time; while (tween) { next = tween.nextNode; if (((tween.active) || ((((((time >= tween.cachedStartTime)) && (!(tween.cachedPaused)))) && (!(tween.gc)))))){ if (!tween.cachedReversed){ tween.renderTime(((time - tween.cachedStartTime) * tween.cachedTimeScale), suppressEvents, false); } else { dur = (tween.cacheIsDirty) ? tween.totalDuration : tween.cachedTotalDuration; tween.renderTime((dur - ((time - tween.cachedStartTime) * tween.cachedTimeScale)), suppressEvents, false); }; }; tween = next; }; } public function addChild(tween:TweenCore):void{ if (((!(tween.gc)) && (tween.timeline))){ tween.timeline.remove(tween, true); }; tween.timeline = this; if (tween.gc){ tween.setEnabled(true, true); }; if (_firstChild){ _firstChild.prevNode = tween; }; tween.nextNode = _firstChild; _firstChild = tween; tween.prevNode = null; } public function remove(tween:TweenCore, skipDisable:Boolean=false):void{ if (tween.gc){ return; }; if (!skipDisable){ tween.setEnabled(false, true); }; if (tween.nextNode){ tween.nextNode.prevNode = tween.prevNode; } else { if (_lastChild == tween){ _lastChild = tween.prevNode; }; }; if (tween.prevNode){ tween.prevNode.nextNode = tween.nextNode; } else { if (_firstChild == tween){ _firstChild = tween.nextNode; }; }; } public function get rawTime():Number{ return (this.cachedTotalTime); } } }//package com.greensock.core
Section 5
//TweenCore (com.greensock.core.TweenCore) package com.greensock.core { import com.greensock.*; public class TweenCore { public var initted:Boolean; protected var _hasUpdate:Boolean; public var active:Boolean; protected var _delay:Number; public var cachedTime:Number; public var cachedReversed:Boolean; public var nextNode:TweenCore; protected var _rawPrevTime:Number;// = -1 public var vars:Object; public var cachedTotalTime:Number; public var timeline:SimpleTimeline; public var data; public var cachedStartTime:Number; public var prevNode:TweenCore; public var cachedDuration:Number; public var gc:Boolean; protected var _pauseTime:Number; public var cacheIsDirty:Boolean; public var cachedPaused:Boolean; public var cachedTimeScale:Number; public var cachedTotalDuration:Number; public static const version:Number = 1.13; protected static var _classInitted:Boolean; public function TweenCore(duration:Number=0, vars:Object=null){ super(); this.vars = ((vars) || ({})); this.cachedDuration = (this.cachedTotalDuration = ((duration) || (0))); _delay = ((this.vars.delay) || (0)); this.cachedTimeScale = ((this.vars.timeScale) || (1)); this.active = Boolean((((((duration == 0)) && ((_delay == 0)))) && (!((this.vars.immediateRender == false))))); this.cachedTotalTime = (this.cachedTime = 0); this.data = this.vars.data; if (!_classInitted){ if (isNaN(TweenLite.rootFrame)){ TweenLite.initClass(); _classInitted = true; } else { return; }; }; var tl:SimpleTimeline = ((this.vars.timeline is SimpleTimeline)) ? this.vars.timeline : (this.vars.useFrames) ? TweenLite.rootFramesTimeline : TweenLite.rootTimeline; this.cachedStartTime = (tl.cachedTotalTime + _delay); tl.addChild(this); if (this.vars.reversed){ this.cachedReversed = true; }; if (this.vars.paused){ this.paused = true; }; } public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void{ } public function get delay():Number{ return (_delay); } public function get duration():Number{ return (this.cachedDuration); } public function restart(includeDelay:Boolean=false, suppressEvents:Boolean=true):void{ this.reversed = false; this.paused = false; this.setTotalTime((includeDelay) ? -(_delay) : 0, suppressEvents); } public function set reversed(b:Boolean):void{ if (b != this.cachedReversed){ this.cachedReversed = b; setTotalTime(this.cachedTotalTime, true); }; } public function set startTime(n:Number):void{ var adjust:Boolean = Boolean(((!((this.timeline == null))) && (((!((n == this.cachedStartTime))) || (this.gc))))); this.cachedStartTime = n; if (adjust){ this.timeline.addChild(this); }; } public function set delay(n:Number):void{ this.startTime = (this.startTime + (n - _delay)); _delay = n; } public function resume():void{ this.paused = false; } public function get paused():Boolean{ return (this.cachedPaused); } public function play():void{ this.reversed = false; this.paused = false; } public function set duration(n:Number):void{ this.cachedDuration = (this.cachedTotalDuration = n); setDirtyCache(false); } public function complete(skipRender:Boolean=false, suppressEvents:Boolean=false):void{ if (!skipRender){ renderTime(this.cachedTotalDuration, suppressEvents, false); return; }; if (this.timeline.autoRemoveChildren){ this.setEnabled(false, false); } else { this.active = false; }; if (!suppressEvents){ if (((((this.vars.onComplete) && ((this.cachedTotalTime == this.cachedTotalDuration)))) && (!(this.cachedReversed)))){ this.vars.onComplete.apply(null, this.vars.onCompleteParams); } else { if (((((this.cachedReversed) && ((this.cachedTotalTime == 0)))) && (this.vars.onReverseComplete))){ this.vars.onReverseComplete.apply(null, this.vars.onReverseCompleteParams); }; }; }; } public function invalidate():void{ } public function get totalTime():Number{ return (this.cachedTotalTime); } public function get reversed():Boolean{ return (this.cachedReversed); } public function get startTime():Number{ return (this.cachedStartTime); } public function set currentTime(n:Number):void{ setTotalTime(n, false); } protected function setDirtyCache(includeSelf:Boolean=true):void{ var tween:TweenCore = (includeSelf) ? this : this.timeline; while (tween) { tween.cacheIsDirty = true; tween = tween.timeline; }; } public function reverse(forceResume:Boolean=true):void{ this.reversed = true; if (forceResume){ this.paused = false; } else { if (this.gc){ this.setEnabled(true, false); }; }; } public function set paused(b:Boolean):void{ if (((!((b == this.cachedPaused))) && (this.timeline))){ if (b){ _pauseTime = this.timeline.rawTime; } else { this.cachedStartTime = (this.cachedStartTime + (this.timeline.rawTime - _pauseTime)); _pauseTime = NaN; setDirtyCache(false); }; this.cachedPaused = b; this.active = Boolean(((((!(this.cachedPaused)) && ((this.cachedTotalTime > 0)))) && ((this.cachedTotalTime < this.cachedTotalDuration)))); }; if (((!(b)) && (this.gc))){ this.setTotalTime(this.cachedTotalTime, false); this.setEnabled(true, false); }; } public function kill():void{ setEnabled(false, false); } public function set totalTime(n:Number):void{ setTotalTime(n, false); } public function get currentTime():Number{ return (this.cachedTime); } protected function setTotalTime(time:Number, suppressEvents:Boolean=false):void{ var tlTime:Number; var dur:Number; if (this.timeline){ tlTime = (((_pauseTime) || ((_pauseTime == 0)))) ? _pauseTime : this.timeline.cachedTotalTime; if (this.cachedReversed){ dur = (this.cacheIsDirty) ? this.totalDuration : this.cachedTotalDuration; this.cachedStartTime = (tlTime - ((dur - time) / this.cachedTimeScale)); } else { this.cachedStartTime = (tlTime - (time / this.cachedTimeScale)); }; if (!this.timeline.cacheIsDirty){ setDirtyCache(false); }; if (this.cachedTotalTime != time){ renderTime(time, suppressEvents, false); }; }; } public function pause():void{ this.paused = true; } public function set totalDuration(n:Number):void{ this.duration = n; } public function get totalDuration():Number{ return (this.cachedTotalDuration); } public function setEnabled(enabled:Boolean, ignoreTimeline:Boolean=false):Boolean{ if (enabled){ this.active = Boolean(((((!(this.cachedPaused)) && ((this.cachedTotalTime > 0)))) && ((this.cachedTotalTime < this.cachedTotalDuration)))); if (((!(ignoreTimeline)) && (this.gc))){ this.timeline.addChild(this); }; } else { this.active = false; if (!ignoreTimeline){ this.timeline.remove(this, true); }; }; this.gc = !(enabled); return (false); } } }//package com.greensock.core
Section 6
//TweenLite (com.greensock.TweenLite) package com.greensock { import flash.events.*; import flash.display.*; import flash.utils.*; import com.greensock.core.*; import com.greensock.plugins.*; public class TweenLite extends TweenCore { protected var _hasPlugins:Boolean; public var propTweenLookup:Object; public var cachedPT1:PropTween; protected var _overwrite:uint; protected var _ease:Function; public var target:Object; public var ratio:Number;// = 0 protected var _overwrittenProps:Object; protected var _notifyPluginsOfEnabled:Boolean; public static const version:Number = 11.2; public static var rootTimeline:SimpleTimeline; public static var fastEaseLookup:Dictionary = new Dictionary(false); public static var onPluginEvent:Function; public static var rootFramesTimeline:SimpleTimeline; public static var defaultEase:Function = TweenLite.easeOut; public static var plugins:Object = {}; public static var masterList:Dictionary = new Dictionary(false); public static var overwriteManager:Object; public static var rootFrame:Number; public static var killDelayedCallsTo:Function = TweenLite.killTweensOf; private static var _shape:Shape = new Shape(); protected static var _reservedProps:Object = {ease:1, delay:1, overwrite:1, onComplete:1, onCompleteParams:1, useFrames:1, runBackwards:1, startAt:1, onUpdate:1, onUpdateParams:1, roundProps:1, onStart:1, onStartParams:1, onInit:1, onInitParams:1, onReverseComplete:1, onReverseCompleteParams:1, onRepeat:1, onRepeatParams:1, proxiedEase:1, easeParams:1, yoyo:1, onCompleteListener:1, onUpdateListener:1, onStartListener:1, onReverseCompleteListener:1, onRepeatListener:1, orientToBezier:1, timeScale:1, immediateRender:1, repeat:1, repeatDelay:1, timeline:1, data:1, paused:1}; public function TweenLite(target:Object, duration:Number, vars:Object){ var sibling:TweenLite; super(duration, vars); this.target = target; if ((((this.target is TweenCore)) && (("timeScale" in this.vars)))){ this.cachedTimeScale = 1; }; propTweenLookup = {}; _ease = defaultEase; _overwrite = (((!((Number(vars.overwrite) > -1))) || (((!(overwriteManager.enabled)) && ((vars.overwrite > 1)))))) ? overwriteManager.mode : int(vars.overwrite); var a:Array = masterList[target]; if (!a){ masterList[target] = [this]; } else { if (_overwrite == 1){ for each (sibling in a) { if (!sibling.gc){ sibling.setEnabled(false, false); }; }; masterList[target] = [this]; } else { a[a.length] = this; }; }; if (((this.active) || (this.vars.immediateRender))){ renderTime(0, false, true); }; } protected function easeProxy(t:Number, b:Number, c:Number, d:Number):Number{ return (this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams))); } override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void{ var isComplete:Boolean; var prevTime:Number = this.cachedTime; if (time >= this.cachedDuration){ this.cachedTotalTime = (this.cachedTime = this.cachedDuration); this.ratio = 1; isComplete = true; if (this.cachedDuration == 0){ if ((((((time == 0)) || ((_rawPrevTime < 0)))) && (!((_rawPrevTime == time))))){ force = true; }; _rawPrevTime = time; }; } else { if (time <= 0){ this.cachedTotalTime = (this.cachedTime = (this.ratio = 0)); if (time < 0){ this.active = false; if (this.cachedDuration == 0){ if (_rawPrevTime > 0){ force = true; isComplete = true; }; _rawPrevTime = time; }; }; if (((this.cachedReversed) && (!((prevTime == 0))))){ isComplete = true; }; } else { this.cachedTotalTime = (this.cachedTime = time); this.ratio = _ease(time, 0, 1, this.cachedDuration); }; }; if ((((this.cachedTime == prevTime)) && (!(force)))){ return; }; if (!this.initted){ init(); if (((!(isComplete)) && (this.cachedTime))){ this.ratio = _ease(this.cachedTime, 0, 1, this.cachedDuration); }; }; if (((!(this.active)) && (!(this.cachedPaused)))){ this.active = true; }; if ((((((((prevTime == 0)) && (this.vars.onStart))) && (!((this.cachedTime == 0))))) && (!(suppressEvents)))){ this.vars.onStart.apply(null, this.vars.onStartParams); }; var pt:PropTween = this.cachedPT1; while (pt) { pt.target[pt.property] = (pt.start + (this.ratio * pt.change)); pt = pt.nextNode; }; if (((_hasUpdate) && (!(suppressEvents)))){ this.vars.onUpdate.apply(null, this.vars.onUpdateParams); }; if (isComplete){ if (((_hasPlugins) && (this.cachedPT1))){ onPluginEvent("onComplete", this); }; complete(true, suppressEvents); }; } override public function setEnabled(enabled:Boolean, ignoreTimeline:Boolean=false):Boolean{ var a:Array; if (enabled){ a = TweenLite.masterList[this.target]; if (!a){ TweenLite.masterList[this.target] = [this]; } else { a[a.length] = this; }; }; super.setEnabled(enabled, ignoreTimeline); if (((_notifyPluginsOfEnabled) && (this.cachedPT1))){ return (onPluginEvent((enabled) ? "onEnable" : "onDisable", this)); }; return (false); } protected function init():void{ var p:String; var i:int; var plugin:*; var prioritize:Boolean; var siblings:Array; var pt:PropTween; if (this.vars.onInit){ this.vars.onInit.apply(null, this.vars.onInitParams); }; if (typeof(this.vars.ease) == "function"){ _ease = this.vars.ease; }; if (this.vars.easeParams){ this.vars.proxiedEase = _ease; _ease = easeProxy; }; this.cachedPT1 = null; this.propTweenLookup = {}; for (p in this.vars) { if ((((p in _reservedProps)) && (!((((p == "timeScale")) && ((this.target is TweenCore))))))){ } else { if ((((p in plugins)) && (new ((plugins[p] as Class)).onInitTween(this.target, this.vars[p], this)))){ this.cachedPT1 = new PropTween(plugin, "changeFactor", 0, 1, ((plugin.overwriteProps.length)==1) ? plugin.overwriteProps[0] : "_MULTIPLE_", true, this.cachedPT1); if (this.cachedPT1.name == "_MULTIPLE_"){ i = plugin.overwriteProps.length; while (i--) { this.propTweenLookup[plugin.overwriteProps[i]] = this.cachedPT1; }; } else { this.propTweenLookup[this.cachedPT1.name] = this.cachedPT1; }; if (plugin.priority){ this.cachedPT1.priority = plugin.priority; prioritize = true; }; if (((plugin.onDisable) || (plugin.onEnable))){ _notifyPluginsOfEnabled = true; }; _hasPlugins = true; } else { this.cachedPT1 = new PropTween(this.target, p, Number(this.target[p]), ((typeof(this.vars[p]))=="number") ? (Number(this.vars[p]) - this.target[p]) : Number(this.vars[p]), p, false, this.cachedPT1); this.propTweenLookup[p] = this.cachedPT1; }; }; }; if (prioritize){ onPluginEvent("onInit", this); }; if (this.vars.runBackwards){ pt = this.cachedPT1; while (pt) { pt.start = (pt.start + pt.change); pt.change = -(pt.change); pt = pt.nextNode; }; }; _hasUpdate = Boolean(!((this.vars.onUpdate == null))); if (_overwrittenProps){ killVars(_overwrittenProps); if (this.cachedPT1 == null){ this.setEnabled(false, false); }; }; if ((((((((_overwrite > 1)) && (this.cachedPT1))) && (masterList[this.target]))) && ((siblings.length > 1)))){ if (overwriteManager.manageOverwrites(this, this.propTweenLookup, siblings, _overwrite)){ init(); }; }; this.initted = true; } public function killVars(vars:Object, permanent:Boolean=true):Boolean{ var p:String; var pt:PropTween; var changed:Boolean; if (_overwrittenProps == null){ _overwrittenProps = {}; }; for (p in vars) { if ((p in propTweenLookup)){ pt = propTweenLookup[p]; if (((pt.isPlugin) && ((pt.name == "_MULTIPLE_")))){ pt.target.killProps(vars); if (pt.target.overwriteProps.length == 0){ pt.name = ""; }; }; if (pt.name != "_MULTIPLE_"){ if (pt.nextNode){ pt.nextNode.prevNode = pt.prevNode; }; if (pt.prevNode){ pt.prevNode.nextNode = pt.nextNode; } else { if (this.cachedPT1 == pt){ this.cachedPT1 = pt.nextNode; }; }; if (((pt.isPlugin) && (pt.target.onDisable))){ pt.target.onDisable(); if (pt.target.activeDisable){ changed = true; }; }; delete propTweenLookup[p]; }; }; if (permanent){ _overwrittenProps[p] = 1; }; }; return (changed); } override public function invalidate():void{ if (((_notifyPluginsOfEnabled) && (this.cachedPT1))){ onPluginEvent("onDisable", this); }; this.cachedPT1 = null; _overwrittenProps = null; _hasUpdate = (this.initted = (this.active = (_notifyPluginsOfEnabled = false))); this.propTweenLookup = {}; } public static function initClass():void{ rootFrame = 0; rootTimeline = new SimpleTimeline(null); rootFramesTimeline = new SimpleTimeline(null); rootTimeline.cachedStartTime = (getTimer() * 0.001); rootFramesTimeline.cachedStartTime = rootFrame; rootTimeline.autoRemoveChildren = true; rootFramesTimeline.autoRemoveChildren = true; _shape.addEventListener(Event.ENTER_FRAME, updateAll, false, 0, true); if (overwriteManager == null){ overwriteManager = {mode:1, enabled:false}; }; } public static function killTweensOf(target:Object, complete:Boolean=false):void{ var a:Array; var i:int; if ((target in masterList)){ a = masterList[target]; i = a.length; while (i--) { if (!TweenLite(a[i]).gc){ if (complete){ TweenLite(a[i]).complete(false, false); } else { TweenLite(a[i]).setEnabled(false, false); }; }; }; delete masterList[target]; }; } public static function from(target:Object, duration:Number, vars:Object):TweenLite{ vars.runBackwards = true; if (!("immediateRender" in vars)){ vars.immediateRender = true; }; return (new TweenLite(target, duration, vars)); } protected static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{ t = (1 - (t / d)); return ((1 - (t * t))); } public static function delayedCall(delay:Number, onComplete:Function, onCompleteParams:Array=null, useFrames:Boolean=false):TweenLite{ return (new TweenLite(onComplete, 0, {delay:delay, onComplete:onComplete, onCompleteParams:onCompleteParams, immediateRender:false, useFrames:useFrames, overwrite:0})); } protected static function updateAll(e:Event=null):void{ var ml:Dictionary; var tgt:Object; var a:Array; var i:int; rootTimeline.renderTime((((getTimer() * 0.001) - rootTimeline.cachedStartTime) * rootTimeline.cachedTimeScale), false, false); rootFrame++; rootFramesTimeline.renderTime(((rootFrame - rootFramesTimeline.cachedStartTime) * rootFramesTimeline.cachedTimeScale), false, false); if (!(rootFrame % 60)){ ml = masterList; for (tgt in ml) { a = ml[tgt]; i = a.length; while (i--) { if (TweenLite(a[i]).gc){ a.splice(i, 1); }; }; if (a.length == 0){ delete ml[tgt]; }; }; }; } public static function to(target:Object, duration:Number, vars:Object):TweenLite{ return (new TweenLite(target, duration, vars)); } } }//package com.greensock
Section 7
//FPSStats (com.hires.FPSStats) package com.hires { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import flash.utils.*; import flash.system.*; public class FPSStats extends Sprite { protected var timer:uint; protected var mem_max_graph:uint; protected var theme:Object; protected var mem:Number; protected var xml:XML; protected var graph:Bitmap; protected var mem_graph:uint; public var WIDTH:uint;// = 70 public var HEIGHT:uint;// = 100 protected var fps:uint; protected var ms_prev:uint; protected var text:TextField; protected var rectangle:Rectangle; protected var style:StyleSheet; protected var ms:uint; protected var currentFps:uint; protected var fps_graph:uint; protected var mem_max:Number; public function FPSStats(_theme:Object=null):void{ theme = {bg:51, fps:0xFFFF00, ms:0xFF00, mem:0xFFFF, memmax:0xFF0070}; super(); if (_theme){ if (_theme.bg != null){ theme.bg = _theme.bg; }; if (_theme.fps != null){ theme.fps = _theme.fps; }; if (_theme.ms != null){ theme.ms = _theme.ms; }; if (_theme.mem != null){ theme.mem = _theme.mem; }; if (_theme.memmax != null){ theme.memmax = _theme.memmax; }; }; mem_max = 0; xml = <xml><fps>FPS:</fps><ms>MS:</ms><mem>MEM:</mem><memMax>MAX:</memMax></xml> ; style = new StyleSheet(); style.setStyle("xml", {fontSize:"9px", fontFamily:"_sans", leading:"-2px"}); style.setStyle("fps", {color:hex2css(theme.fps)}); style.setStyle("ms", {color:hex2css(theme.ms)}); style.setStyle("mem", {color:hex2css(theme.mem)}); style.setStyle("memMax", {color:hex2css(theme.memmax)}); text = new TextField(); text.width = WIDTH; text.height = 50; text.styleSheet = style; text.condenseWhite = true; text.selectable = false; text.mouseEnabled = false; graph = new Bitmap(); graph.y = 50; rectangle = new Rectangle((WIDTH - 1), 0, 1, (HEIGHT - 50)); addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true); addEventListener(Event.REMOVED_FROM_STAGE, destroy, false, 0, true); } private function destroy(e:Event):void{ graphics.clear(); while (numChildren > 0) { removeChildAt(0); }; graph.bitmapData.dispose(); removeEventListener(MouseEvent.CLICK, onClick); removeEventListener(Event.ENTER_FRAME, update); } public function getFps():uint{ return (currentFps); } private function onClick(e:MouseEvent):void{ if (((mouseY / height) > 0.5)){ stage.frameRate--; } else { stage.frameRate++; }; xml.fps = ((("FPS: " + fps) + " / ") + stage.frameRate); text.htmlText = xml; } private function init(e:Event):void{ graphics.beginFill(theme.bg); graphics.drawRect(0, 0, WIDTH, HEIGHT); graphics.endFill(); addChild(text); graph.bitmapData = new BitmapData(WIDTH, (HEIGHT - 50), false, theme.bg); addChild(graph); addEventListener(MouseEvent.CLICK, onClick); addEventListener(Event.ENTER_FRAME, update); } private function update(e:Event):void{ timer = getTimer(); if ((timer - 1000) > ms_prev){ ms_prev = timer; mem = Number((System.totalMemory * 9.54E-7).toFixed(3)); mem_max = ((mem_max > mem)) ? mem_max : mem; fps_graph = Math.min(graph.height, ((fps / stage.frameRate) * graph.height)); mem_graph = (Math.min(graph.height, Math.sqrt(Math.sqrt((mem * 5000)))) - 2); mem_max_graph = (Math.min(graph.height, Math.sqrt(Math.sqrt((mem_max * 5000)))) - 2); graph.bitmapData.scroll(-1, 0); graph.bitmapData.fillRect(rectangle, theme.bg); graph.bitmapData.setPixel((graph.width - 1), (graph.height - fps_graph), theme.fps); graph.bitmapData.setPixel((graph.width - 1), (graph.height - ((timer - ms) >> 1)), theme.ms); graph.bitmapData.setPixel((graph.width - 1), (graph.height - mem_graph), theme.mem); graph.bitmapData.setPixel((graph.width - 1), (graph.height - mem_max_graph), theme.memmax); xml.fps = ((("FPS: " + fps) + " / ") + stage.frameRate); xml.mem = ("MEM: " + mem); xml.memMax = ("MAX: " + mem_max); currentFps = fps; fps = 0; }; fps++; xml.ms = ("MS: " + (timer - ms)); ms = timer; text.htmlText = xml; } private function hex2css(color:int):String{ return (("#" + color.toString(16))); } } }//package com.hires
Section 8
//StopWatch (com.StopWatch) package com { public class StopWatch { public var endTime:Date; public var elapsedTime:Number; public var startTime:Date; public var persistent:Boolean; public static const START:String = "START"; public static const STOP:String = "STOP"; public static const RESET:String = "RESET"; public function StopWatch(persist:Boolean=false){ super(); zero(); persistent = persist; } public function start():void{ if (!persistent){ endTime = null; startTime = new Date(); }; } public function reset():void{ startTime = new Date(); endTime = new Date(); elapsedTime = 0; } public function toString():String{ var res:String = ("StopWatch : " + getElapsedTime()); return (res); } public function zero():void{ startTime = null; endTime = null; elapsedTime = 0; } public function stop():void{ endTime = new Date(); elapsedTime = (endTime.getTime() - startTime.getTime()); } public function getSeconds():String{ var secs:Number = (getElapsedTime() / 1000); return ((secs + " Seconds")); } public function getElapsedTime():Number{ if (startTime != null){ if (endTime != null){ elapsedTime = (endTime.getTime() - startTime.getTime()); } else { elapsedTime = (new Date().getTime() - startTime.getTime()); }; }; return (elapsedTime); } public static function formatTime(time:Number):String{ var myPattern:RegExp = /\./g; var str:String = String((time / 1000)); if (str.length > 4){ str = str.substring(0, (str.length - 2)); }; str = str.replace(myPattern, "'"); return (str); } public static function showTime(time:Number):String{ var d:Date = new Date(0, 0, 0, 0, 0, 0, time); return (((((d.getMinutes() + "'") + d.getSeconds()) + "''") + d.getMilliseconds())); } } }//package com
Section 9
//MochiAd (mochi.as3.MochiAd) package mochi.as3 { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.net.*; import flash.system.*; public class MochiAd { public function MochiAd(){ super(); } public static function getVersion():String{ return (MochiServices.getVersion()); } public static function showClickAwayAd(options:Object):void{ var clip:Object; var mc:MovieClip; var chk:MovieClip; var options = options; var DEFAULTS:Object = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{ }, ad_finished:function ():void{ }, ad_loaded:function (width:Number, height:Number):void{ }, ad_failed:function ():void{ trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software"); }, ad_skipped:function ():void{ }}; options = MochiAd._parseOptions(options, DEFAULTS); clip = options.clip; var ad_timeout:Number = options.ad_timeout; delete options.ad_timeout; if (!MochiAd.load(options)){ options.ad_failed(); options.ad_finished(); return; }; options.ad_started(); mc = clip._mochiad; mc["onUnload"] = function ():void{ MochiAd._cleanup(mc); options.ad_finished(); }; var wh:Array = MochiAd._getRes(options, clip); var w:Number = wh[0]; var h:Number = wh[1]; mc.x = (w * 0.5); mc.y = (h * 0.5); chk = createEmptyMovieClip(mc, "_mochiad_wait", 3); chk.ad_timeout = ad_timeout; chk.started = getTimer(); chk.showing = false; mc.unloadAd = function ():void{ MochiAd.unload(clip); }; mc.adLoaded = options.ad_loaded; mc.adSkipped = options.ad_skipped; mc.rpc = function (callbackID:Number, arg:Object):void{ MochiAd.rpc(clip, callbackID, arg); }; chk["onEnterFrame"] = function ():void{ var total:Number; if (!this.parent){ delete this.onEnterFrame; return; }; var ad_clip:Object = this.parent._mochiad_ctr; var elapsed:Number = (getTimer() - this.started); var finished:Boolean; if (!chk.showing){ total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal; if (total > 0){ chk.showing = true; finished = true; chk.started = getTimer(); } else { if (elapsed > chk.ad_timeout){ options.ad_failed(); finished = true; }; }; }; if (this.root == null){ finished = true; }; if (finished){ delete this.onEnterFrame; }; }; doOnEnterFrame(chk); } public static function _isNetworkAvailable():Boolean{ return (!((Security.sandboxType == "localWithFile"))); } public static function _allowDomains(server:String):String{ var hostname:String = server.split("/")[2].split(":")[0]; if (Security.sandboxType == "application"){ return (hostname); }; Security.allowDomain("*"); Security.allowDomain(hostname); Security.allowInsecureDomain("*"); Security.allowInsecureDomain(hostname); return (hostname); } public static function unload(clip:Object):Boolean{ if (((clip.clip) && (clip.clip._mochiad))){ clip = clip.clip; }; if (clip.origFrameRate != undefined){ clip.stage.frameRate = clip.origFrameRate; }; if (!clip._mochiad){ return (false); }; if (clip._mochiad._containerLCName != undefined){ clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"unload"}); }; if (clip._mochiad.onUnload){ clip._mochiad.onUnload(); }; delete clip._mochiad_loaded; delete clip._mochiad; return (true); } public static function showInterLevelAd(options:Object):void{ var clip:Object; var mc:MovieClip; var chk:MovieClip; var options = options; var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{ if ((this.clip is MovieClip)){ this.clip.stop(); } else { throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_finished:function ():void{ if ((this.clip is MovieClip)){ this.clip.play(); } else { throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_loaded:function (width:Number, height:Number):void{ }, ad_failed:function ():void{ trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software"); }, ad_skipped:function ():void{ }}; options = MochiAd._parseOptions(options, DEFAULTS); clip = options.clip; var ad_msec:Number = 11000; var ad_timeout:Number = options.ad_timeout; delete options.ad_timeout; var fadeout_time:Number = options.fadeout_time; delete options.fadeout_time; if (!MochiAd.load(options)){ options.ad_failed(); options.ad_finished(); return; }; options.ad_started(); mc = clip._mochiad; mc["onUnload"] = function ():void{ MochiAd._cleanup(mc); options.ad_finished(); }; var wh:Array = MochiAd._getRes(options, clip); var w:Number = wh[0]; var h:Number = wh[1]; mc.x = (w * 0.5); mc.y = (h * 0.5); chk = createEmptyMovieClip(mc, "_mochiad_wait", 3); chk.ad_msec = ad_msec; chk.ad_timeout = ad_timeout; chk.started = getTimer(); chk.showing = false; chk.fadeout_time = fadeout_time; chk.fadeFunction = function ():void{ if (!this.parent){ delete this.onEnterFrame; delete this.fadeFunction; return; }; var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time))); if (p > 0){ this.parent.alpha = (p * 0.01); } else { MochiAd.unload(clip); delete this["onEnterFrame"]; }; }; mc.unloadAd = function ():void{ MochiAd.unload(clip); }; mc.adLoaded = options.ad_loaded; mc.adSkipped = options.ad_skipped; mc.adjustProgress = function (msec:Number):void{ var _chk:Object = mc._mochiad_wait; _chk.server_control = true; _chk.showing = true; _chk.started = getTimer(); _chk.ad_msec = (msec - 250); }; mc.rpc = function (callbackID:Number, arg:Object):void{ MochiAd.rpc(clip, callbackID, arg); }; chk["onEnterFrame"] = function ():void{ var total:Number; if (!this.parent){ delete this.onEnterFrame; delete this.fadeFunction; return; }; var ad_clip:Object = this.parent._mochiad_ctr; var elapsed:Number = (getTimer() - this.started); var finished:Boolean; if (!chk.showing){ total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal; if (total > 0){ chk.showing = true; chk.started = getTimer(); MochiAd.adShowing(clip); } else { if (elapsed > chk.ad_timeout){ options.ad_failed(); finished = true; }; }; }; if (elapsed > chk.ad_msec){ finished = true; }; if (finished){ if (this.server_control){ delete this.onEnterFrame; } else { this.fadeout_start = getTimer(); this.onEnterFrame = this.fadeFunction; }; }; }; doOnEnterFrame(chk); } public static function _parseOptions(options:Object, defaults:Object):Object{ var k:String; var pairs:Array; var i:Number; var kv:Array; var optcopy:Object = {}; for (k in defaults) { optcopy[k] = defaults[k]; }; if (options){ for (k in options) { optcopy[k] = options[k]; }; }; if (optcopy.clip == undefined){ throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite.")); }; options = optcopy.clip.loaderInfo.parameters.mochiad_options; if (options){ pairs = options.split("&"); i = 0; while (i < pairs.length) { kv = pairs[i].split("="); optcopy[unescape(kv[0])] = unescape(kv[1]); i++; }; }; if (optcopy.id == "test"){ trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!"); }; return (optcopy); } public static function _cleanup(mc:Object):void{ var k:String; var lc:LocalConnection; var f:Function; var mc = mc; if (("lc" in mc)){ lc = mc.lc; f = function ():void{ lc.client = null; lc.close(); //unresolved jump var _slot1 = e; }; setTimeout(f, 0); }; var idx:Number = DisplayObjectContainer(mc).numChildren; while (idx > 0) { idx = (idx - 1); DisplayObjectContainer(mc).removeChildAt(idx); }; for (k in mc) { delete mc[k]; }; } public static function load(options:Object):MovieClip{ var clip:Object; var mc:MovieClip; var k:String; var server:String; var hostname:String; var lc:LocalConnection; var name:String; var loader:Loader; var g:Function; var req:URLRequest; var v:Object; var options = options; var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"}; options = MochiAd._parseOptions(options, DEFAULTS); options.swfv = 9; options.mav = MochiAd.getVersion(); clip = options.clip; if (!(clip is DisplayObject)){ trace("Warning: Object passed as container clip not a descendant of the DisplayObject type"); return (null); }; if (MovieClip(clip).stage == null){ trace("Warning: Container clip for ad is not attached to the stage"); return (null); }; if (!MochiAd._isNetworkAvailable()){ return (null); }; if (clip._mochiad_loaded){ return (null); }; //unresolved jump var _slot1 = e; throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic.")); var depth:Number = options.depth; delete options.depth; mc = createEmptyMovieClip(clip, "_mochiad", depth); var wh:Array = MochiAd._getRes(options, clip); options.res = ((wh[0] + "x") + wh[1]); options.server = (options.server + options.id); delete options.id; clip._mochiad_loaded = true; if (clip.loaderInfo.loaderURL.indexOf("http") == 0){ options.as3_swf = clip.loaderInfo.loaderURL; } else { trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal"); }; var lv:URLVariables = new URLVariables(); for (k in options) { v = options[k]; if (!(v is Function)){ lv[k] = v; }; }; server = lv.server; delete lv.server; hostname = _allowDomains(server); lc = new LocalConnection(); lc.client = mc; name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_"); lc.allowDomain("*", "localhost"); lc.allowInsecureDomain("*", "localhost"); lc.connect(name); mc.lc = lc; mc.lcName = name; lv.lc = name; lv.st = getTimer(); mc.regContLC = function (lc_name:String):void{ mc._containerLCName = lc_name; }; loader = new Loader(); g = function (ev:Object):void{ ev.target.removeEventListener(ev.type, arguments.callee); MochiAd.unload(clip); }; loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g); req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime())); req.contentType = "application/x-www-form-urlencoded"; req.method = URLRequestMethod.POST; req.data = lv; loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (io:IOErrorEvent):void{ trace("[MochiAds] Blocked URL"); }); if (!options.skip){ loader.load(req); }; mc.addChild(loader); mc._mochiad_ctr = loader; return (mc); } public static function runMethod(base:Object, methodName:String, argsArray:Array):Object{ var nameArray:Array = methodName.split("."); var i:Number = 0; while (i < (nameArray.length - 1)) { if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){ return (undefined); }; base = base[nameArray[i]]; i++; }; if (typeof(base[nameArray[i]]) == "function"){ return (base[nameArray[i]].apply(base, argsArray)); }; return (undefined); } public static function createEmptyMovieClip(parent:Object, name:String, depth:Number):MovieClip{ var mc:MovieClip = new MovieClip(); if (((false) && (depth))){ parent.addChildAt(mc, depth); } else { parent.addChild(mc); }; parent[name] = mc; mc["_name"] = name; return (mc); } public static function _getRes(options:Object, clip:Object):Array{ var xy:Array; var b:Object = clip.getBounds(clip.root); var w:Number = 0; var h:Number = 0; if (typeof(options.res) != "undefined"){ xy = options.res.split("x"); w = parseFloat(xy[0]); h = parseFloat(xy[1]); } else { w = (b.xMax - b.xMin); h = (b.yMax - b.yMin); }; if ((((w == 0)) || ((h == 0)))){ w = clip.stage.stageWidth; h = clip.stage.stageHeight; }; return ([w, h]); } public static function adShowing(mc:Object):void{ mc.origFrameRate = mc.stage.frameRate; mc.stage.frameRate = 30; } public static function getValue(base:Object, objectName:String):Object{ var nameArray:Array = objectName.split("."); var i:Number = 0; while (i < (nameArray.length - 1)) { if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){ return (undefined); }; base = base[nameArray[i]]; i++; }; return (base[nameArray[i]]); } public static function rpc(clip:Object, callbackID:Number, arg:Object):void{ var _local4:Object; var _local5:Object; switch (arg.id){ case "setValue": MochiAd.setValue(clip, arg.objectName, arg.value); break; case "getValue": _local4 = MochiAd.getValue(clip, arg.objectName); clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local4); break; case "runMethod": _local5 = MochiAd.runMethod(clip, arg.method, arg.args); clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local5); break; default: trace(("[mochiads rpc] unknown rpc id: " + arg.id)); }; } public static function setValue(base:Object, objectName:String, value:Object):void{ var nameArray:Array = objectName.split("."); var i:Number = 0; while (i < (nameArray.length - 1)) { if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){ return; }; base = base[nameArray[i]]; i++; }; base[nameArray[i]] = value; } public static function showPreGameAd(options:Object):void{ var clip:Object; var mc:MovieClip; var chk:MovieClip; var complete:Boolean; var unloaded:Boolean; var sendHostProgress:Boolean; var fn:Function; var r:MovieClip; var options = options; var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{ if ((this.clip is MovieClip)){ this.clip.stop(); } else { throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_finished:function ():void{ if ((this.clip is MovieClip)){ this.clip.play(); } else { throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_loaded:function (width:Number, height:Number):void{ }, ad_failed:function ():void{ trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software"); }, ad_skipped:function ():void{ }, ad_progress:function (percent:Number):void{ }, progress_override:function (_clip:Object):Number{ return (NaN); }, bar_offset:0}; options = MochiAd._parseOptions(options, DEFAULTS); if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){ options.ad_started(); fn = function ():void{ options.ad_finished(); }; setTimeout(fn, 100); return; }; clip = options.clip; var ad_msec:Number = 11000; var ad_timeout:Number = options.ad_timeout; if (options.skip){ ad_timeout = 0; }; delete options.ad_timeout; var fadeout_time:Number = options.fadeout_time; delete options.fadeout_time; if (!MochiAd.load(options)){ options.ad_failed(); options.ad_finished(); return; }; options.ad_started(); mc = clip._mochiad; mc["onUnload"] = function ():void{ MochiAd._cleanup(mc); var fn:Function = function ():void{ options.ad_finished(); }; setTimeout(fn, 100); }; var wh:Array = MochiAd._getRes(options, clip); var w:Number = wh[0]; var h:Number = wh[1]; mc.x = (w * 0.5); mc.y = (h * 0.5); chk = createEmptyMovieClip(mc, "_mochiad_wait", 3); chk.x = (w * -0.5); chk.y = (h * -0.5); var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4); if (options.no_progress_bar){ bar.visible = false; delete options.no_progress_bar; } else { bar.x = (10 + options.bar_offset); bar.y = (h - 20); }; var bar_w:Number = ((w - bar.x) - 10); var bar_color:Number = options.color; delete options.color; var bar_background:Number = options.background; delete options.background; var bar_outline:Number = options.outline; delete options.outline; var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1); var backing:Object = backing_mc.graphics; backing.beginFill(bar_background); backing.moveTo(0, 0); backing.lineTo(bar_w, 0); backing.lineTo(bar_w, 10); backing.lineTo(0, 10); backing.lineTo(0, 0); backing.endFill(); var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2); var inside:Object = inside_mc.graphics; inside.beginFill(bar_color); inside.moveTo(0, 0); inside.lineTo(bar_w, 0); inside.lineTo(bar_w, 10); inside.lineTo(0, 10); inside.lineTo(0, 0); inside.endFill(); inside_mc.scaleX = 0; var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3); var outline:Object = outline_mc.graphics; outline.lineStyle(0, bar_outline, 100); outline.moveTo(0, 0); outline.lineTo(bar_w, 0); outline.lineTo(bar_w, 10); outline.lineTo(0, 10); outline.lineTo(0, 0); chk.ad_msec = ad_msec; chk.ad_timeout = ad_timeout; chk.started = getTimer(); chk.showing = false; chk.last_pcnt = 0; chk.fadeout_time = fadeout_time; chk.fadeFunction = function ():void{ var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time))); if (p > 0){ this.parent.alpha = (p * 0.01); } else { MochiAd.unload(clip); delete this["onEnterFrame"]; }; }; complete = false; unloaded = false; var progress:Number = Math.min(1, options.progress_override(clip)); var f:Function = function (ev:Event):void{ ev.target.removeEventListener(ev.type, arguments.callee); complete = true; if (unloaded){ MochiAd.unload(clip); }; }; if (!isNaN(progress)){ complete = (progress == 1); } else { if (clip.loaderInfo.bytesLoaded == clip.loaderInfo.bytesTotal){ complete = true; } else { if ((clip.root is MovieClip)){ r = (clip.root as MovieClip); if (r.framesLoaded >= r.totalFrames){ complete = true; } else { clip.loaderInfo.addEventListener(Event.COMPLETE, f); }; } else { clip.loaderInfo.addEventListener(Event.COMPLETE, f); }; }; }; mc.unloadAd = function ():void{ unloaded = true; if (complete){ MochiAd.unload(clip); }; }; mc.adLoaded = options.ad_loaded; mc.adSkipped = options.ad_skipped; mc.adjustProgress = function (msec:Number):void{ var _chk:Object = mc._mochiad_wait; _chk.server_control = true; _chk.showing = true; _chk.started = getTimer(); _chk.ad_msec = msec; }; mc.rpc = function (callbackID:Number, arg:Object):void{ MochiAd.rpc(clip, callbackID, arg); }; mc.rpcTestFn = function (s:String):Object{ trace(("[MOCHIAD rpcTestFn] " + s)); return (s); }; sendHostProgress = false; mc.sendHostLoadProgress = function (lc_name:String):void{ sendHostProgress = true; }; chk["onEnterFrame"] = function ():void{ var total:Number; if (((!(this.parent)) || (!(this.parent.parent)))){ delete this["onEnterFrame"]; return; }; var _clip:Object = this.parent.parent.root; var ad_clip:Object = this.parent._mochiad_ctr; var elapsed:Number = (getTimer() - this.started); var finished:Boolean; var clip_total:Number = _clip.loaderInfo.bytesTotal; var clip_loaded:Number = _clip.loaderInfo.bytesLoaded; var clip_progress:Number = Math.min(1, options.progress_override(_clip)); if (clip_progress == 1){ complete = true; }; if (complete){ clip_loaded = Math.max(1, clip_loaded); clip_total = clip_loaded; }; var clip_pcnt:Number = ((100 * clip_loaded) / clip_total); if (!isNaN(clip_progress)){ clip_pcnt = (100 * clip_progress); }; var ad_pcnt:Number = ((100 * elapsed) / chk.ad_msec); var _inside:Object = this._mochiad_bar._inside; var pcnt:Number = Math.min(100, Math.min(((clip_pcnt) || (0)), ad_pcnt)); pcnt = Math.max(this.last_pcnt, pcnt); this.last_pcnt = pcnt; _inside.scaleX = (pcnt * 0.01); options.ad_progress(pcnt); if (sendHostProgress){ clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:clip_pcnt}); if (clip_pcnt >= 100){ sendHostProgress = false; }; }; if (!chk.showing){ total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal; if (total > 0){ chk.showing = true; chk.started = getTimer(); MochiAd.adShowing(clip); } else { if ((((elapsed > chk.ad_timeout)) && ((clip_pcnt == 100)))){ options.ad_failed(); finished = true; }; }; }; if (elapsed > chk.ad_msec){ finished = true; }; if (((complete) && (finished))){ if (unloaded){ MochiAd.unload(_clip); } else { if (this.server_control){ delete this.onEnterFrame; } else { this.fadeout_start = getTimer(); this.onEnterFrame = chk.fadeFunction; }; }; }; }; doOnEnterFrame(chk); } public static function showPreloaderAd(options:Object):void{ trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0"); MochiAd.showPreGameAd(options); } public static function showTimedAd(options:Object):void{ trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0"); MochiAd.showInterLevelAd(options); } public static function doOnEnterFrame(mc:MovieClip):void{ var mc = mc; var f:Function = function (ev:Object):void{ if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){ mc.onEnterFrame(); } else { ev.target.removeEventListener(ev.type, arguments.callee); }; }; mc.addEventListener(Event.ENTER_FRAME, f); } } }//package mochi.as3
Section 10
//MochiCoins (mochi.as3.MochiCoins) package mochi.as3 { public class MochiCoins { public static const STORE_HIDE:String = "StoreHide"; public static const NO_USER:String = "NoUser"; public static const IO_ERROR:String = "IOError"; public static const ITEM_NEW:String = "ItemNew"; public static const ITEM_OWNED:String = "ItemOwned"; public static const STORE_ITEMS:String = "StoreItems"; public static const ERROR:String = "Error"; public static const STORE_SHOW:String = "StoreShow"; public static var _inventory:MochiInventory; public function MochiCoins(){ super(); } public static function triggerEvent(eventType:String, args:Object):void{ MochiSocial.triggerEvent(eventType, args); } public static function removeEventListener(eventType:String, delegate:Function):void{ MochiSocial.removeEventListener(eventType, delegate); } public static function addEventListener(eventType:String, delegate:Function):void{ MochiSocial.addEventListener(eventType, delegate); } public static function getStoreItems():void{ MochiServices.send("coins_getStoreItems"); } public static function get inventory():MochiInventory{ return (_inventory); } public static function showStore(options:Object=null):void{ MochiServices.bringToTop(); MochiServices.send("coins_showStore", {options:options}, null, null); } public static function showItem(options:Object=null):void{ if (((!(options)) || (!((typeof(options.item) == "string"))))){ trace("ERROR: showItem call must pass an Object with an item key"); return; }; MochiServices.bringToTop(); MochiServices.send("coins_showItem", {options:options}, null, null); } public static function getVersion():String{ return (MochiServices.getVersion()); } public static function showVideo(options:Object=null):void{ if (((!(options)) || (!((typeof(options.item) == "string"))))){ trace("ERROR: showVideo call must pass an Object with an item key"); return; }; MochiServices.bringToTop(); MochiServices.send("coins_showVideo", {options:options}, null, null); } MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (args:Object):void{ _inventory = new MochiInventory(); }); MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (args:Object):void{ _inventory = null; }); } }//package mochi.as3
Section 11
//MochiDigits (mochi.as3.MochiDigits) package mochi.as3 { public final class MochiDigits { private var Sibling:MochiDigits; private var Fragment:Number; private var Encoder:Number; public function MochiDigits(digit:Number=0, index:uint=0):void{ super(); Encoder = 0; setValue(digit, index); } public function reencode():void{ var newEncode:uint = int((2147483647 * Math.random())); Fragment = (Fragment ^ (newEncode ^ Encoder)); Encoder = newEncode; } public function set value(v:Number):void{ setValue(v); } public function toString():String{ var s:String = String.fromCharCode((Fragment ^ Encoder)); if (Sibling != null){ s = (s + Sibling.toString()); }; return (s); } public function setValue(digit:Number=0, index:uint=0):void{ var s:String = digit.toString(); var _temp1 = index; index = (index + 1); Fragment = (s.charCodeAt(_temp1) ^ Encoder); if (index < s.length){ Sibling = new MochiDigits(digit, index); } else { Sibling = null; }; reencode(); } public function get value():Number{ return (Number(this.toString())); } public function addValue(inc:Number):void{ value = (value + inc); } } }//package mochi.as3
Section 12
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher) package mochi.as3 { public class MochiEventDispatcher { private var eventTable:Object; public function MochiEventDispatcher():void{ super(); eventTable = {}; } public function triggerEvent(event:String, args:Object):void{ var i:Object; if (eventTable[event] == undefined){ return; }; for (i in eventTable[event]) { var _local6 = eventTable[event]; _local6[i](args); }; } public function removeEventListener(event:String, delegate:Function):void{ var s:Object; if (eventTable[event] == undefined){ eventTable[event] = []; return; }; for (s in eventTable[event]) { if (eventTable[event][s] != delegate){ } else { eventTable[event].splice(Number(s), 1); }; }; } public function addEventListener(event:String, delegate:Function):void{ removeEventListener(event, delegate); eventTable[event].push(delegate); } } }//package mochi.as3
Section 13
//MochiEvents (mochi.as3.MochiEvents) package mochi.as3 { import flash.display.*; public class MochiEvents { public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL"; public static const FORMAT_LONG:String = "LongForm"; public static const ALIGN_BOTTOM:String = "ALIGN_B"; public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived"; public static const FORMAT_SHORT:String = "ShortForm"; public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR"; public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR"; public static const ALIGN_TOP:String = "ALIGN_T"; public static const ALIGN_LEFT:String = "ALIGN_L"; public static const ALIGN_RIGHT:String = "ALIGN_R"; public static const ALIGN_TOP_LEFT:String = "ALIGN_TL"; public static const ALIGN_CENTER:String = "ALIGN_C"; private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher(); private static var gameStart:Number; private static var levelStart:Number; public function MochiEvents(){ super(); } public static function endPlay():void{ MochiServices.send("events_clearRoundID", null, null, null); } public static function addEventListener(eventType:String, delegate:Function):void{ _dispatcher.addEventListener(eventType, delegate); } public static function trackEvent(tag:String, value=null):void{ MochiServices.send("events_trackEvent", {tag:tag, value:value}, null, null); } public static function removeEventListener(eventType:String, delegate:Function):void{ _dispatcher.removeEventListener(eventType, delegate); } public static function startSession(achievementID:String):void{ MochiServices.send("events_beginSession", {achievementID:achievementID}, null, null); } public static function triggerEvent(eventType:String, args:Object):void{ _dispatcher.triggerEvent(eventType, args); } public static function setNotifications(clip:MovieClip, style:Object):void{ var s:Object; var args:Object = {}; for (s in style) { args[s] = style[s]; }; args.clip = clip; MochiServices.send("events_setNotifications", args, null, null); } public static function getVersion():String{ return (MochiServices.getVersion()); } public static function startPlay(tag:String="gameplay"):void{ MochiServices.send("events_setRoundID", {tag:String(tag)}, null, null); } } }//package mochi.as3
Section 14
//MochiInventory (mochi.as3.MochiInventory) package mochi.as3 { import flash.events.*; import flash.utils.*; public dynamic class MochiInventory extends Proxy { private var _timer:Timer; private var _names:Array; private var _syncID:Number; private var _consumableProperties:Object; private var _storeSync:Object; private var _outstandingID:Number; private var _syncPending:Boolean; public static const READY:String = "InvReady"; public static const ERROR:String = "Error"; public static const IO_ERROR:String = "IoError"; private static const KEY_SALT:String = " syncMaint"; public static const WRITTEN:String = "InvWritten"; public static const NOT_READY:String = "InvNotReady"; public static const VALUE_ERROR:String = "InvValueError"; private static const CONSUMER_KEY:String = "MochiConsumables"; private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher(); public function MochiInventory():void{ super(); MochiCoins.addEventListener(MochiCoins.ITEM_OWNED, itemOwned); MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems); MochiSocial.addEventListener(MochiSocial.LOGGED_IN, loggedIn); MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, loggedOut); _storeSync = new Object(); _syncPending = false; _outstandingID = 0; _syncID = 0; _timer = new Timer(1000); _timer.addEventListener(TimerEvent.TIMER, sync); _timer.start(); if (MochiSocial.loggedIn){ loggedIn(); } else { loggedOut(); }; } private function newItems(event:Object):void{ if (!this[(event.id + KEY_SALT)]){ this[(event.id + KEY_SALT)] = 0; }; if (!this[event.id]){ this[event.id] = 0; }; this[(event.id + KEY_SALT)] = (this[(event.id + KEY_SALT)] + event.count); this[event.id] = (this[event.id] + event.count); if (event.privateProperties.consumable){ if (!this[event.privateProperties.tag]){ this[event.privateProperties.tag] = 0; }; this[event.privateProperties.tag] = (this[event.privateProperties.tag] + (event.privateProperties.inc * event.count)); }; } public function release():void{ MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems); MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn); MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){ if (_consumableProperties == null){ triggerEvent(ERROR, {type:NOT_READY}); return (-1); }; if (_consumableProperties[name]){ return (MochiDigits(_consumableProperties[name]).value); }; return (undefined); } private function loggedIn(args:Object=null):void{ MochiUserData.get(CONSUMER_KEY, getConsumableBag); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(name):Boolean{ if (_consumableProperties == null){ triggerEvent(ERROR, {type:NOT_READY}); return (false); }; if (_consumableProperties[name] == undefined){ return (false); }; return (true); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(index:int):int{ return (((index)>=_names.length) ? 0 : (index + 1)); } private function putConsumableBag(userData:MochiUserData):void{ _syncPending = false; if (userData.error){ triggerEvent(ERROR, {type:IO_ERROR, error:userData.error}); _outstandingID = -1; }; triggerEvent(WRITTEN, {}); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{ var d:MochiDigits; if (_consumableProperties == null){ triggerEvent(ERROR, {type:NOT_READY}); return; }; if (!(value is Number)){ triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:value}); return; }; if (_consumableProperties[name]){ d = MochiDigits(_consumableProperties[name]); if (d.value == value){ return; }; d.value = value; } else { _names.push(name); _consumableProperties[name] = new MochiDigits(value); }; _syncID++; } private function itemOwned(event:Object):void{ _storeSync[event.id] = {properties:event.properties, count:event.count}; } private function sync(e:Event=null):void{ var key:String; if (((_syncPending) || ((_syncID == _outstandingID)))){ return; }; _outstandingID = _syncID; var output:Object = {}; for (key in _consumableProperties) { output[key] = MochiDigits(_consumableProperties[key]).value; }; MochiUserData.put(CONSUMER_KEY, output, putConsumableBag); _syncPending = true; } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(index:int):String{ return (_names[(index - 1)]); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(name):Boolean{ if (!_consumableProperties[name]){ return (false); }; _names.splice(_names.indexOf(name), 1); delete _consumableProperties[name]; return (true); } private function getConsumableBag(userData:MochiUserData):void{ var key:String; var unsynced:Number; if (userData.error){ triggerEvent(ERROR, {type:IO_ERROR, error:userData.error}); return; }; _consumableProperties = {}; _names = new Array(); if (userData.data){ for (key in userData.data) { _names.push(key); _consumableProperties[key] = new MochiDigits(userData.data[key]); }; }; for (key in _storeSync) { unsynced = _storeSync[key].count; if (_consumableProperties[(key + KEY_SALT)]){ unsynced = (unsynced - _consumableProperties[key]); }; if (unsynced == 0){ } else { newItems({id:key, count:unsynced, properties:_storeSync[key].properties}); }; }; triggerEvent(READY, {}); } private function loggedOut(args:Object=null):void{ _consumableProperties = null; } public static function triggerEvent(eventType:String, args:Object):void{ _dispatcher.triggerEvent(eventType, args); } public static function removeEventListener(eventType:String, delegate:Function):void{ _dispatcher.removeEventListener(eventType, delegate); } public static function addEventListener(eventType:String, delegate:Function):void{ _dispatcher.addEventListener(eventType, delegate); } } }//package mochi.as3
Section 15
//MochiServices (mochi.as3.MochiServices) package mochi.as3 { import flash.events.*; import flash.display.*; import flash.geom.*; import flash.utils.*; import flash.net.*; import flash.system.*; public class MochiServices { private static var _container:Object; private static var _connected:Boolean = false; private static var _queue:Array; private static var _swfVersion:String; private static var _preserved:Object; public static var netupAttempted:Boolean = false; private static var _sendChannel:LocalConnection; public static var servicesSync:MochiSync = new MochiSync(); private static var _nextCallbackID:Number; private static var _clip:MovieClip; private static var _id:String; private static var _services:String = "services.swf"; private static var _servURL:String = "http://www.mochiads.com/static/lib/services/"; public static var widget:Boolean = false; private static var _timer:Timer; private static var _sendChannelName:String; private static var _loader:Loader; private static var _callbacks:Object; private static var _connecting:Boolean = false; private static var _mochiLocalConnection:MovieClip; private static var _listenChannelName:String = "__ms_"; public static var onError:Object; public static var netup:Boolean = true; private static var _mochiLC:String = "MochiLC.swf"; public function MochiServices(){ super(); } public static function isNetworkAvailable():Boolean{ return (!((Security.sandboxType == "localWithFile"))); } public static function get connected():Boolean{ return (_connected); } private static function onReceive(pkg:Object):void{ var methodName:String; var pkg = pkg; var cb:String = pkg.callbackID; var cblst:Object = _callbacks[cb]; if (!cblst){ return; }; var method:* = cblst.callbackMethod; methodName = ""; var obj:Object = cblst.callbackObject; if (((obj) && ((typeof(method) == "string")))){ methodName = method; if (obj[method] != null){ method = obj[method]; } else { trace((("Error: Method " + method) + " does not exist.")); }; }; if (method != undefined){ method.apply(obj, pkg.args); //unresolved jump var _slot1 = error; trace(((("Error invoking callback method '" + methodName) + "': ") + _slot1.toString())); } else { if (obj != null){ obj(pkg.args); //unresolved jump var _slot1 = error; trace(("Error invoking method on object: " + _slot1.toString())); }; }; delete _callbacks[cb]; } public static function send(methodName:String, args:Object=null, callbackObject:Object=null, callbackMethod:Object=null):void{ if (_connected){ _mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:methodName, args:args, callbackID:_nextCallbackID}); } else { if ((((_clip == null)) || (!(_connecting)))){ trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + methodName)); handleError(args, callbackObject, callbackMethod); flush(true); return; }; _queue.push({methodName:methodName, args:args, callbackID:_nextCallbackID}); }; if (_clip != null){ if (_callbacks != null){ _callbacks[_nextCallbackID] = {callbackObject:callbackObject, callbackMethod:callbackMethod}; _nextCallbackID++; }; }; } private static function init(id:String, clip:Object):void{ _id = id; if (clip != null){ _container = clip; loadCommunicator(id, _container); }; } public static function get childClip():Object{ return (_clip); } private static function clickMovie(url:String, cb:Function):MovieClip{ var b:int; var loader:Loader; var avm1_bytecode:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23]; var header:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3]; var footer:Array = [0, 64, 0, 0, 0]; var mc:MovieClip = new MovieClip(); var lc:LocalConnection = new LocalConnection(); var lc_name:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time)); lc = new LocalConnection(); mc.lc = lc; mc.click = cb; lc.client = mc; lc.connect(lc_name); var ba:ByteArray = new ByteArray(); var cpool:ByteArray = new ByteArray(); cpool.endian = Endian.LITTLE_ENDIAN; cpool.writeShort(1); cpool.writeUTFBytes(((url + " ") + lc_name)); cpool.writeByte(0); var actionLength:uint = ((avm1_bytecode.length + cpool.length) + 4); var fileLength:uint = (actionLength + 35); ba.endian = Endian.LITTLE_ENDIAN; ba.writeUTFBytes("FWS"); ba.writeByte(8); ba.writeUnsignedInt(fileLength); for each (b in header) { ba.writeByte(b); }; ba.writeUnsignedInt(actionLength); ba.writeByte(136); ba.writeShort(cpool.length); ba.writeBytes(cpool); for each (b in avm1_bytecode) { ba.writeByte(b); }; for each (b in footer) { ba.writeByte(b); }; loader = new Loader(); loader.loadBytes(ba); mc.addChild(loader); return (mc); } public static function stayOnTop():void{ _container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true); if (_clip != null){ _clip.visible = true; }; } public static function addLinkEvent(url:String, burl:String, btn:DisplayObjectContainer, onClick:Function=null):void{ var avm1Click:DisplayObject; var x:String; var req:URLRequest; var loader:Loader; var setURL:Function; var err:Function; var complete:Function; var url = url; var burl = burl; var btn = btn; var onClick = onClick; var vars:Object = new Object(); vars["mav"] = getVersion(); vars["swfv"] = "9"; vars["swfurl"] = btn.loaderInfo.loaderURL; vars["fv"] = Capabilities.version; vars["os"] = Capabilities.os; vars["lang"] = Capabilities.language; vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY); var s = "?"; var i:Number = 0; for (x in vars) { if (i != 0){ s = (s + "&"); }; i = (i + 1); s = (((s + x) + "=") + escape(vars[x])); }; req = new URLRequest("http://x.mochiads.com/linkping.swf"); loader = new Loader(); setURL = function (url:String):void{ if (avm1Click){ btn.removeChild(avm1Click); }; avm1Click = clickMovie(url, onClick); var rect:Rectangle = btn.getBounds(btn); btn.addChild(avm1Click); avm1Click.x = rect.x; avm1Click.y = rect.y; avm1Click.scaleX = (0.01 * rect.width); avm1Click.scaleY = (0.01 * rect.height); }; err = function (ev:Object):void{ netup = false; ev.target.removeEventListener(ev.type, arguments.callee); setURL(burl); }; complete = function (ev:Object):void{ ev.target.removeEventListener(ev.type, arguments.callee); }; if (netup){ setURL((url + s)); } else { setURL(burl); }; if (!((netupAttempted) || (_connected))){ netupAttempted = true; loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete); loader.load(req); }; } public static function disconnect():void{ if (((_connected) || (_connecting))){ if (_clip != null){ if (_clip.parent != null){ if ((_clip.parent is Sprite)){ Sprite(_clip.parent).removeChild(_clip); _clip = null; }; }; }; _connecting = (_connected = false); flush(true); _mochiLocalConnection.close(); //unresolved jump var _slot1 = error; }; if (_timer != null){ _timer.stop(); //unresolved jump var _slot1 = error; }; } public static function allowDomains(server:String):String{ var hostname:String; if (Security.sandboxType != "application"){ Security.allowDomain("*"); Security.allowInsecureDomain("*"); }; if (server.indexOf("http://") != -1){ hostname = server.split("/")[2].split(":")[0]; if (Security.sandboxType != "application"){ Security.allowDomain(hostname); Security.allowInsecureDomain(hostname); }; }; return (hostname); } public static function getVersion():String{ return ("3.8 as3"); } public static function doClose():void{ _container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop); } public static function warnID(bid:String, leaderboard:Boolean):void{ bid = bid.toLowerCase(); if (bid.length != 16){ trace((("WARNING: " + (leaderboard) ? "board" : "game") + " ID is not the appropriate length")); return; } else { if (bid == "1e113c7239048b3f"){ if (leaderboard){ trace("WARNING: Using testing board ID"); } else { trace("WARNING: Using testing board ID as game ID"); }; return; } else { if (bid == "84993a1de4031cd8"){ if (leaderboard){ trace("WARNING: Using testing game ID as board ID"); } else { trace("WARNING: Using testing game ID"); }; return; }; }; }; var i:Number = 0; while (i < bid.length) { switch (bid.charAt(i)){ case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": case "a": case "b": case "c": case "d": case "e": case "f": break; default: trace(("WARNING: Board ID contains illegal characters: " + bid)); return; }; i++; }; } private static function flush(error:Boolean):void{ var request:Object; var callback:Object; if (((_clip) && (_queue))){ while (_queue.length > 0) { request = _queue.shift(); callback = null; if (request != null){ if (request.callbackID != null){ callback = _callbacks[request.callbackID]; }; delete _callbacks[request.callbackID]; if (((error) && (!((callback == null))))){ handleError(request.args, callback.callbackObject, callback.callbackMethod); }; }; }; }; } public static function get id():String{ return (_id); } private static function onEvent(pkg:Object):void{ var target:String = pkg.target; var event:String = pkg.event; switch (target){ case "events": MochiEvents.triggerEvent(pkg.event, pkg.args); break; case "coins": MochiCoins.triggerEvent(pkg.event, pkg.args); break; case "sync": servicesSync.triggerEvent(pkg.event, pkg.args); break; }; } private static function urlOptions(clip:Object):Object{ var options:String; var pairs:Array; var i:Number; var kv:Array; var opts:Object = {}; if (clip.stage){ options = clip.stage.loaderInfo.parameters.mochiad_options; } else { options = clip.loaderInfo.parameters.mochiad_options; }; if (options){ pairs = options.split("&"); i = 0; while (i < pairs.length) { kv = pairs[i].split("="); opts[unescape(kv[0])] = unescape(kv[1]); i++; }; }; return (opts); } public static function setContainer(container:Object=null, doAdd:Boolean=true):void{ if (_clip.parent){ _clip.parent.removeChild(_clip); }; if (container != null){ if ((container is DisplayObjectContainer)){ _container = container; }; }; if (doAdd){ if ((_container is DisplayObjectContainer)){ DisplayObjectContainer(_container).addChild(_clip); }; }; } private static function handleError(args:Object, callbackObject:Object, callbackMethod:Object):void{ var args = args; var callbackObject = callbackObject; var callbackMethod = callbackMethod; if (args != null){ if (args.onError != null){ args.onError.apply(null, ["NotConnected"]); }; if (((!((args.options == null))) && (!((args.options.onError == null))))){ args.options.onError.apply(null, ["NotConnected"]); }; }; if (callbackMethod != null){ args = {}; args.error = true; args.errorCode = "NotConnected"; if (((!((callbackObject == null))) && ((callbackMethod is String)))){ var _local5 = callbackObject; _local5[callbackMethod](args); //unresolved jump var _slot1 = error; } else { if (callbackMethod != null){ callbackMethod.apply(args); //unresolved jump var _slot1 = error; }; }; }; } private static function loadError(ev:Object):void{ _clip._mochiad_ctr_failed = true; trace("MochiServices could not load."); MochiServices.disconnect(); MochiServices.onError("IOError"); } private static function initComChannels():void{ if (!_connected){ trace("[SERVICES_API] connected!"); _connecting = false; _connected = true; _mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"}); _mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, version:getVersion(), parentURL:_container.loaderInfo.loaderURL}); _clip.onReceive = onReceive; _clip.onEvent = onEvent; _clip.onError = function ():void{ MochiServices.onError("IOError"); }; while (_queue.length > 0) { _mochiLocalConnection.send(_sendChannelName, "onReceive", _queue.shift()); }; }; } private static function loadLCBridge(clip:Object):void{ var loader:Loader; var clip = clip; loader = new Loader(); var mochiLCURL:String = (_servURL + _mochiLC); var req:URLRequest = new URLRequest(mochiLCURL); var complete:Function = function (ev:Object):void{ _mochiLocalConnection = MovieClip(loader.content); listen(); }; loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError); loader.load(req); clip.addChild(loader); } private static function listen():void{ _mochiLocalConnection.connect(_listenChannelName); _clip.handshake = function (args:Object):void{ MochiServices.comChannelName = args.newChannel; }; trace("Waiting for MochiAds services to connect..."); } public static function get clip():Object{ return (_container); } public static function set comChannelName(val:String):void{ if (val != null){ if (val.length > 3){ _sendChannelName = (val + "_fromgame"); initComChannels(); }; }; } private static function loadCommunicator(id:String, clip:Object):MovieClip{ if (_clip != null){ return (_clip); }; if (!MochiServices.isNetworkAvailable()){ return (null); }; if (urlOptions(clip).servURL){ _servURL = urlOptions(clip).servURL; }; var servicesURL:String = (_servURL + _services); if (urlOptions(clip).servicesURL){ servicesURL = urlOptions(clip).servicesURL; }; _listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999)))); MochiServices.allowDomains(servicesURL); _clip = new MovieClip(); loadLCBridge(_clip); _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError); var req:URLRequest = new URLRequest(servicesURL); var vars:URLVariables = new URLVariables(); vars.listenLC = _listenChannelName; vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options; vars.api_version = getVersion(); if (widget){ vars.widget = true; }; req.data = vars; _loader.load(req); _clip.addChild(_loader); _sendChannel = new LocalConnection(); _queue = []; _nextCallbackID = 0; _callbacks = {}; _timer = new Timer(10000, 1); _timer.addEventListener(TimerEvent.TIMER, connectWait); _timer.start(); return (_clip); } public static function connect(id:String, clip:Object, onError:Object=null):void{ var id = id; var clip = clip; var onError = onError; warnID(id, false); if ((clip is DisplayObject)){ if (clip.stage == null){ trace("MochiServices connect requires the containing clip be attached to the stage"); }; if (((!(_connected)) && ((_clip == null)))){ trace("MochiServices Connecting..."); _connecting = true; init(id, clip); }; } else { trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage."); }; if (onError != null){ MochiServices.onError = onError; } else { if (MochiServices.onError == null){ MochiServices.onError = function (errorCode:String):void{ trace(errorCode); }; }; }; } public static function updateCopy(args:Object):void{ MochiServices.send("coins_updateCopy", args, null, null); } public static function bringToTop(e:Event=null):void{ var e = e; if (((!((MochiServices.clip == null))) && (!((MochiServices.childClip == null))))){ if (MochiServices.clip.numChildren > 1){ MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1)); }; //unresolved jump var _slot1 = errorObject; trace("Warning: Depth sort error."); _container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop); }; } public static function connectWait(e:TimerEvent):void{ if (!_connected){ _clip._mochiad_ctr_failed = true; trace("MochiServices could not load. (timeout)"); MochiServices.disconnect(); MochiServices.onError("IOError"); }; } } }//package mochi.as3
Section 16
//MochiSocial (mochi.as3.MochiSocial) package mochi.as3 { public class MochiSocial { public static const LOGGED_IN:String = "LoggedIn"; public static const PROFILE_HIDE:String = "ProfileHide"; public static const NO_USER:String = "NoUser"; public static const PROPERTIES_SIZE:String = "PropertiesSize"; public static const IO_ERROR:String = "IOError"; public static const PROPERTIES_SAVED:String = "PropertySaved"; public static const WIDGET_LOADED:String = "WidgetLoaded"; public static const USER_INFO:String = "UserInfo"; public static const ERROR:String = "Error"; public static const LOGIN_SHOW:String = "LoginShow"; public static const LOGGED_OUT:String = "LoggedOut"; public static const PROFILE_SHOW:String = "ProfileShow"; public static const LOGIN_SHOWN:String = "LoginShown"; public static const LOGIN_HIDE:String = "LoginHide"; private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher(); public static var _user_info:Object = null; public function MochiSocial(){ super(); } public static function getVersion():String{ return (MochiServices.getVersion()); } public static function saveUserProperties(properties:Object):void{ MochiServices.send("coins_saveUserProperties", properties); } public static function get loggedIn():Boolean{ return (!((_user_info == null))); } public static function triggerEvent(eventType:String, args:Object):void{ _dispatcher.triggerEvent(eventType, args); } public static function addEventListener(eventType:String, delegate:Function):void{ _dispatcher.addEventListener(eventType, delegate); } public static function getUserInfo():void{ MochiServices.send("coins_getUserInfo"); } public static function showLoginWidget(options:Object=null):void{ MochiServices.setContainer(); MochiServices.bringToTop(); MochiServices.send("coins_showLoginWidget", {options:options}); } public static function removeEventListener(eventType:String, delegate:Function):void{ _dispatcher.removeEventListener(eventType, delegate); } public static function requestLogin():void{ MochiServices.send("coins_requestLogin"); } public static function getAPIURL():String{ if (!_user_info){ return (null); }; return (_user_info.api_url); } public static function hideLoginWidget():void{ MochiServices.send("coins_hideLoginWidget"); } public static function getAPIToken():String{ if (!_user_info){ return (null); }; return (_user_info.api_token); } MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (args:Object):void{ _user_info = args; }); MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (args:Object):void{ _user_info = null; }); } }//package mochi.as3
Section 17
//MochiSync (mochi.as3.MochiSync) package mochi.as3 { import flash.utils.*; public dynamic class MochiSync extends Proxy { private var _syncContainer:Object; public static var SYNC_PROPERTY:String = "UpdateProperty"; public static var SYNC_REQUEST:String = "SyncRequest"; public function MochiSync():void{ super(); _syncContainer = {}; } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{ if (_syncContainer[name] == value){ return; }; var n:String = name.toString(); _syncContainer[n] = value; MochiServices.send("sync_propUpdate", {name:n, value:value}); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){ return (_syncContainer[name]); } public function triggerEvent(eventType:String, args:Object):void{ switch (eventType){ case SYNC_REQUEST: MochiServices.send("sync_syncronize", _syncContainer); break; case SYNC_PROPERTY: _syncContainer[args.name] = args.value; break; }; } } }//package mochi.as3
Section 18
//MochiUserData (mochi.as3.MochiUserData) package mochi.as3 { import flash.events.*; import flash.utils.*; import flash.net.*; public class MochiUserData extends EventDispatcher { public var callback:Function;// = null public var operation:String;// = null public var error:Event;// = null public var data;// = null public var _loader:URLLoader; public var key:String;// = null public function MochiUserData(key:String="", callback:Function=null){ super(); this.key = key; this.callback = callback; } public function serialize(obj):ByteArray{ var arr:ByteArray = new ByteArray(); arr.objectEncoding = ObjectEncoding.AMF3; arr.writeObject(obj); arr.compress(); return (arr); } public function errorHandler(event:IOErrorEvent):void{ data = null; error = event; if (callback != null){ performCallback(); } else { dispatchEvent(event); }; close(); } public function putEvent(obj):void{ request("put", serialize(obj)); } public function deserialize(arr:ByteArray){ arr.objectEncoding = ObjectEncoding.AMF3; arr.uncompress(); return (arr.readObject()); } public function securityErrorHandler(event:SecurityErrorEvent):void{ errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + event.toString()))); } public function getEvent():void{ request("get", serialize(null)); } override public function toString():String{ return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]")); } public function performCallback():void{ callback(this); //unresolved jump var _slot1 = e; trace(("[MochiUserData] exception during callback: " + _slot1)); } public function request(_operation:String, _data:ByteArray):void{ var _operation = _operation; var _data = _data; operation = _operation; var api_url:String = MochiSocial.getAPIURL(); var api_token:String = MochiSocial.getAPIToken(); if ((((api_url == null)) || ((api_token == null)))){ errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in")); return; }; _loader = new URLLoader(); var args:URLVariables = new URLVariables(); args.op = _operation; args.key = key; var req:URLRequest = new URLRequest((((MochiSocial.getAPIURL() + "/") + "MochiUserData?") + args.toString())); req.method = URLRequestMethod.POST; req.contentType = "application/x-mochi-userdata"; req.requestHeaders = [new URLRequestHeader("x-mochi-services-version", MochiServices.getVersion()), new URLRequestHeader("x-mochi-api-token", api_token)]; req.data = _data; _loader.dataFormat = URLLoaderDataFormat.BINARY; _loader.addEventListener(Event.COMPLETE, completeHandler); _loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); _loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); _loader.load(req); //unresolved jump var _slot1 = e; errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _slot1.toString()))); } public function completeHandler(event:Event):void{ var event = event; if (_loader.data.length){ data = deserialize(_loader.data); } else { data = null; }; //unresolved jump var _slot1 = e; errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + _slot1.toString()))); return; if (callback != null){ performCallback(); } else { dispatchEvent(event); }; close(); } public function close():void{ if (_loader){ _loader.removeEventListener(Event.COMPLETE, completeHandler); _loader.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler); _loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); _loader.close(); _loader = null; }; error = null; callback = null; } public static function get(key:String, callback:Function):void{ var userData:MochiUserData = new MochiUserData(key, callback); userData.getEvent(); } public static function put(key:String, obj, callback:Function):void{ var userData:MochiUserData = new MochiUserData(key, callback); userData.putEvent(obj); } } }//package mochi.as3
Section 19
//BitmapAsset (mx.core.BitmapAsset) package mx.core { import flash.display.*; public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject { mx_internal static const VERSION:String = "3.4.1.10084"; public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){ super(bitmapData, pixelSnapping, smoothing); } public function get measuredWidth():Number{ if (bitmapData){ return (bitmapData.width); }; return (0); } public function get measuredHeight():Number{ if (bitmapData){ return (bitmapData.height); }; return (0); } public function setActualSize(newWidth:Number, newHeight:Number):void{ width = newWidth; height = newHeight; } public function move(x:Number, y:Number):void{ this.x = x; this.y = y; } } }//package mx.core
Section 20
//ByteArrayAsset (mx.core.ByteArrayAsset) package mx.core { import flash.utils.*; public class ByteArrayAsset extends ByteArray implements IFlexAsset { mx_internal static const VERSION:String = "3.4.1.10084"; public function ByteArrayAsset(){ super(); } } }//package mx.core
Section 21
//EdgeMetrics (mx.core.EdgeMetrics) package mx.core { public class EdgeMetrics { public var top:Number; public var left:Number; public var bottom:Number; public var right:Number; mx_internal static const VERSION:String = "3.4.1.10084"; public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0); ; public function EdgeMetrics(left:Number=0, top:Number=0, right:Number=0, bottom:Number=0){ super(); this.left = left; this.top = top; this.right = right; this.bottom = bottom; } public function clone():EdgeMetrics{ return (new EdgeMetrics(left, top, right, bottom)); } } }//package mx.core
Section 22
//FlexBitmap (mx.core.FlexBitmap) package mx.core { import flash.display.*; import mx.utils.*; public class FlexBitmap extends Bitmap { mx_internal static const VERSION:String = "3.4.1.10084"; public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){ var bitmapData = bitmapData; var pixelSnapping = pixelSnapping; var smoothing = smoothing; super(bitmapData, pixelSnapping, smoothing); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 23
//FlexMovieClip (mx.core.FlexMovieClip) package mx.core { import flash.display.*; import mx.utils.*; public class FlexMovieClip extends MovieClip { mx_internal static const VERSION:String = "3.4.1.10084"; public function FlexMovieClip(){ super(); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 24
//FontAsset (mx.core.FontAsset) package mx.core { import flash.text.*; public class FontAsset extends Font implements IFlexAsset { mx_internal static const VERSION:String = "3.4.1.10084"; public function FontAsset(){ super(); } } }//package mx.core
Section 25
//IBorder (mx.core.IBorder) package mx.core { public interface IBorder { function get borderMetrics():EdgeMetrics; } }//package mx.core
Section 26
//IFlexAsset (mx.core.IFlexAsset) package mx.core { public interface IFlexAsset { } }//package mx.core
Section 27
//IFlexDisplayObject (mx.core.IFlexDisplayObject) package mx.core { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.accessibility.*; public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher { function get visible():Boolean; function get rotation():Number; function localToGlobal(void:Point):Point; function get name():String; function set width(flash.display:Number):void; function get measuredHeight():Number; function get blendMode():String; function get scale9Grid():Rectangle; function set name(flash.display:String):void; function set scaleX(flash.display:Number):void; function set scaleY(flash.display:Number):void; function get measuredWidth():Number; function get accessibilityProperties():AccessibilityProperties; function set scrollRect(flash.display:Rectangle):void; function get cacheAsBitmap():Boolean; function globalToLocal(void:Point):Point; function get height():Number; function set blendMode(flash.display:String):void; function get parent():DisplayObjectContainer; function getBounds(String:DisplayObject):Rectangle; function get opaqueBackground():Object; function set scale9Grid(flash.display:Rectangle):void; function setActualSize(_arg1:Number, _arg2:Number):void; function set alpha(flash.display:Number):void; function set accessibilityProperties(flash.display:AccessibilityProperties):void; function get width():Number; function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean; function set cacheAsBitmap(flash.display:Boolean):void; function get scaleX():Number; function get scaleY():Number; function get scrollRect():Rectangle; function get mouseX():Number; function get mouseY():Number; function set height(flash.display:Number):void; function set mask(flash.display:DisplayObject):void; function getRect(String:DisplayObject):Rectangle; function get alpha():Number; function set transform(flash.display:Transform):void; function move(_arg1:Number, _arg2:Number):void; function get loaderInfo():LoaderInfo; function get root():DisplayObject; function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean; function set opaqueBackground(flash.display:Object):void; function set visible(flash.display:Boolean):void; function get mask():DisplayObject; function set x(flash.display:Number):void; function set y(flash.display:Number):void; function get transform():Transform; function set filters(flash.display:Array):void; function get x():Number; function get y():Number; function get filters():Array; function set rotation(flash.display:Number):void; function get stage():Stage; } }//package mx.core
Section 28
//IRepeaterClient (mx.core.IRepeaterClient) package mx.core { public interface IRepeaterClient { function get instanceIndices():Array; function set instanceIndices(C:\autobuild\3.4.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function get isDocument():Boolean; function set repeaters(C:\autobuild\3.4.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function initializeRepeaterArrays(C:\autobuild\3.4.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void; function get repeaters():Array; function set repeaterIndices(C:\autobuild\3.4.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function get repeaterIndices():Array; } }//package mx.core
Section 29
//MovieClipAsset (mx.core.MovieClipAsset) package mx.core { public class MovieClipAsset extends FlexMovieClip implements IFlexAsset, IFlexDisplayObject, IBorder { private var _measuredHeight:Number; private var _measuredWidth:Number; mx_internal static const VERSION:String = "3.4.1.10084"; public function MovieClipAsset(){ super(); _measuredWidth = width; _measuredHeight = height; } public function get measuredWidth():Number{ return (_measuredWidth); } public function get measuredHeight():Number{ return (_measuredHeight); } public function setActualSize(newWidth:Number, newHeight:Number):void{ width = newWidth; height = newHeight; } public function move(x:Number, y:Number):void{ this.x = x; this.y = y; } public function get borderMetrics():EdgeMetrics{ if (scale9Grid == null){ return (EdgeMetrics.EMPTY); }; return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom)))); } } }//package mx.core
Section 30
//MovieClipLoaderAsset (mx.core.MovieClipLoaderAsset) package mx.core { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.system.*; public class MovieClipLoaderAsset extends MovieClipAsset implements IFlexAsset, IFlexDisplayObject { protected var initialHeight:Number;// = 0 private var loader:Loader;// = null private var initialized:Boolean;// = false protected var initialWidth:Number;// = 0 private var requestedHeight:Number; private var requestedWidth:Number; mx_internal static const VERSION:String = "3.4.1.10084"; public function MovieClipLoaderAsset(){ super(); var loaderContext:LoaderContext = new LoaderContext(); loaderContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); if (("allowLoadBytesCodeExecution" in loaderContext)){ loaderContext["allowLoadBytesCodeExecution"] = true; }; loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.loadBytes(movieClipData, loaderContext); addChild(loader); } override public function get width():Number{ if (!initialized){ return (initialWidth); }; return (super.width); } override public function set width(value:Number):void{ if (!initialized){ requestedWidth = value; } else { loader.width = value; }; } override public function get measuredHeight():Number{ return (initialHeight); } private function completeHandler(event:Event):void{ initialized = true; initialWidth = loader.width; initialHeight = loader.height; if (!isNaN(requestedWidth)){ loader.width = requestedWidth; }; if (!isNaN(requestedHeight)){ loader.height = requestedHeight; }; dispatchEvent(event); } override public function set height(value:Number):void{ if (!initialized){ requestedHeight = value; } else { loader.height = value; }; } override public function get measuredWidth():Number{ return (initialWidth); } override public function get height():Number{ if (!initialized){ return (initialHeight); }; return (super.height); } public function get movieClipData():ByteArray{ return (null); } } }//package mx.core
Section 31
//mx_internal (mx.core.mx_internal) package mx.core { public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal"; }//package mx.core
Section 32
//SoundAsset (mx.core.SoundAsset) package mx.core { import flash.media.*; public class SoundAsset extends Sound implements IFlexAsset { mx_internal static const VERSION:String = "3.4.1.10084"; public function SoundAsset(){ super(); } } }//package mx.core
Section 33
//NameUtil (mx.utils.NameUtil) package mx.utils { import flash.display.*; import mx.core.*; import flash.utils.*; public class NameUtil { mx_internal static const VERSION:String = "3.4.1.10084"; private static var counter:int = 0; public function NameUtil(){ super(); } public static function displayObjectToString(displayObject:DisplayObject):String{ var result:String; var o:DisplayObject; var s:String; var indices:Array; var displayObject = displayObject; o = displayObject; while (o != null) { if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){ break; }; s = o.name; if ((o is IRepeaterClient)){ indices = IRepeaterClient(o).instanceIndices; if (indices){ s = (s + (("[" + indices.join("][")) + "]")); }; }; result = ((result == null)) ? s : ((s + ".") + result); o = o.parent; }; //unresolved jump var _slot1 = e; return (result); } public static function createUniqueName(object:Object):String{ if (!object){ return (null); }; var name:String = getQualifiedClassName(object); var index:int = name.indexOf("::"); if (index != -1){ name = name.substr((index + 2)); }; var charCode:int = name.charCodeAt((name.length - 1)); if ((((charCode >= 48)) && ((charCode <= 57)))){ name = (name + "_"); }; return ((name + counter++)); } } }//package mx.utils
Section 34
//ZoBackground (zomg.gui.ZoBackground) package zomg.gui { import flash.display.*; import flash.geom.*; public class ZoBackground extends Sprite { protected var col:uint;// = 0 protected var _position:Point; public var _mySize:Point; protected var myAlpha:Number;// = 0xFF public function ZoBackground(size:Point, color:uint=0, alpha:Number=0xFF, pos:Point=null){ super(); mySize = size; switchColor(color, alpha); if (pos){ x = pos.x; y = pos.y; }; } public function get position():Point{ position = new Point(x, y); return (position); } public function get mySize():Point{ return (_mySize); } public function switchColor(color:uint=0, alpha:Number=0xFF):void{ col = color; myAlpha = alpha; graphics.clear(); graphics.beginFill(color, (alpha / 0xFF)); graphics.drawRect(0, 0, mySize.x, mySize.y); graphics.endFill(); } public function set position(pos:Point):void{ x = pos.x; y = pos.y; } public function set mySize(pt:Point):void{ _mySize = pt; switchColor(col, myAlpha); } } }//package zomg.gui
Section 35
//ZoButton (zomg.gui.ZoButton) package zomg.gui { import flash.events.*; import flash.geom.*; import flash.display.*; import zomg.*; public class ZoButton extends ZoSprite { protected var toggle:Boolean;// = false public function ZoButton(sheet:Bitmap, size:Point, name:String="", toggle:Boolean=false, active:Boolean=true){ super(sheet, size, new Point()); this.name = name; this.toggle = toggle; symbol.addAnim("mouseOut", size, 1, new Point(0, 0)); symbol.addAnim("mouseOver", size, 1, new Point(0, 1)); symbol.playAnim("mouseOut"); switchActive(active); mouseChildren = false; } protected function mouseOver(e:MouseEvent):void{ symbol.playAnim("mouseOver"); } public function update():void{ symbol.update(); } public function switchAnim(name:String="mouseOut"):void{ symbol.playAnim(name); } public function action(flag:Boolean=false):void{ } protected function mouseDown(e:MouseEvent):void{ var onoff:Boolean; if (symbol.currentAnim == "mouseOut"){ symbol.playAnim("mouseOver"); onoff = true; } else { symbol.playAnim("mouseOut"); }; action(onoff); } protected function mouseOut(e:MouseEvent):void{ symbol.playAnim("mouseOut"); } public function switchActive(flag:Boolean=false):Boolean{ visible = (active = flag); if (flag){ if (toggle){ addEventListener(MouseEvent.MOUSE_DOWN, mouseDown); } else { addEventListener(MouseEvent.MOUSE_OUT, mouseOut); addEventListener(MouseEvent.MOUSE_OVER, mouseOver); }; } else { if (toggle){ removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown); } else { removeEventListener(MouseEvent.MOUSE_OUT, mouseOut); removeEventListener(MouseEvent.MOUSE_OVER, mouseOver); }; }; return (active); } } }//package zomg.gui
Section 36
//ZoGUI (zomg.gui.ZoGUI) package zomg.gui { import flash.display.*; import flash.text.*; import flash.geom.*; public class ZoGUI { public function ZoGUI(){ super(); } public static function getStdTextField(tfSize:Point, defaultText:String="", param:Object=null, pos:Point=null, container:DisplayObjectContainer=null, name:String=""):TextField{ if (!pos){ pos = new Point(); }; if (!param.size){ param.size = 12; }; if (!param.font){ param.font = "Arial"; }; if (!param.embed){ param.embed = false; }; if (!param.align){ param.align = "left"; }; if (!param.color){ param.color = 0; }; if (!param.letterSpace){ param.letterSpace = 0; }; if (!param.selectable){ param.selectable = false; }; if (!param.underline){ param.underline = false; }; if (!param.bold){ param.bold = false; }; var format:TextFormat = new TextFormat(param.font, param.size, param.color); format.align = param.align; format.letterSpacing = param.letterSpace; format.underline = param.underline; format.bold = param.bold; var tf:TextField = new TextField(); tf.width = tfSize.x; tf.height = tfSize.y; tf.name = name; tf.selectable = false; tf.embedFonts = param.embed; tf.defaultTextFormat = format; tf.text = defaultText; if (container){ container.addChild(tf); }; tf.x = pos.x; tf.y = pos.y; return (tf); } } }//package zomg.gui
Section 37
//ZoLoadBar (zomg.gui.ZoLoadBar) package zomg.gui { import flash.display.*; import flash.geom.*; public class ZoLoadBar extends Sprite { protected var size:Point; protected var fill:Sprite; protected var _currentPerc:Number; protected var cadre:Sprite; protected var borderSize:Number;// = 2 protected var fillColor:uint;// = 0 protected var myMask:Sprite; protected var _current:Number; protected static var min:Number = 0; protected static var max:Number = 100; public function ZoLoadBar(size:Point, value:Number=0, fillColor:uint=0xFF0000, borderColor:uint=0){ _current = min; _currentPerc = min; super(); this.size = size; this.fillColor = fillColor; if (size.y < 20){ borderSize = 1; }; cadre = new Sprite(); cadre.graphics.beginFill(borderColor); cadre.graphics.drawRect(0, 0, size.x, size.y); cadre.graphics.endFill(); fill = new Sprite(); fill.graphics.beginFill(fillColor); fill.graphics.drawRect(0, 0, (size.x - (borderSize * 2)), (size.y - (borderSize * 2))); fill.graphics.endFill(); fill.y = (fill.x = borderSize); myMask = new Sprite(); myMask.graphics.beginFill(0xFFFFFF); myMask.graphics.drawRect(0, 0, (size.x / 2), (size.y - (borderSize * 2))); myMask.graphics.endFill(); myMask.x = (myMask.y = borderSize); addChild(cadre); addChild(fill); addChild(myMask); fill.mask = myMask; setValue(value); } public function reset():void{ currentPerc = 0; } public function setFillColor(col:uint=0xFF0000):void{ fill.graphics.clear(); fill.graphics.beginFill(col); fill.graphics.drawRect(0, 0, (size.x - (borderSize * 2)), (size.y - (borderSize * 2))); fill.graphics.endFill(); } public function toggleBar():void{ if (visible){ visible = false; } else { visible = true; }; } protected function setValue(value:Number):void{ var theWidth:Number = ((size.x / 100) * value); if (theWidth < 1){ theWidth = 1; }; myMask.graphics.clear(); myMask.graphics.beginFill(0xFFFFFF); myMask.graphics.drawRect(0, 0, theWidth, (size.y - (borderSize * 2))); myMask.graphics.endFill(); } public function set current(v:Number):void{ _current = v; setValue(v); } public function get current():Number{ return (_current); } public function set currentPerc(v:Number):void{ _currentPerc = v; current = (v * 100); } public function get currentPerc():Number{ return ((_current / 100)); } } }//package zomg.gui
Section 38
//OLRlinks (zomg.olr.OLRlinks) package zomg.olr { import flash.events.*; import flash.display.*; import flash.text.*; import flash.net.*; public class OLRlinks extends Sprite { private static var txt:String = ("> By " + owner); private static var crossColor:uint = 0xFF0000; private static var useCross:Boolean = true; private static var owner:String = "OneLifeRemains"; public function OLRlinks(stage:Stage){ var tformat:TextFormat; var tf:TextField; var cross:Sprite; var left:Sprite; var right:Sprite; super(); tformat = new TextFormat(); tformat.size = 12; tformat.font = "Arial"; tformat.align = "right"; tformat.bold = true; tformat.color = 0xFFFF00; tf = new TextField(); tf.selectable = false; tf.width = stage.stageWidth; tf.height = 20; tf.x = -10; tf.y = ((stage.stageHeight - tf.height) - 10); tf.defaultTextFormat = tformat; tf.text = txt; if (useCross){ cross = new Sprite(); left = new Sprite(); left.graphics.lineStyle(1, crossColor); left.graphics.moveTo(0, 0); left.graphics.lineTo(stage.stageWidth, stage.stageHeight); cross.addChild(left); right = new Sprite(); right.graphics.lineStyle(1, crossColor); right.graphics.moveTo(stage.stageWidth, 0); right.graphics.lineTo(0, stage.stageHeight); cross.addChild(right); cross.alpha = 0.3; addChild(cross); }; addChild(tf); this.mouseChildren = false; this.buttonMode = true; this.addEventListener(MouseEvent.MOUSE_DOWN, onClick); } private function onClick(e:MouseEvent):void{ var req:URLRequest = new URLRequest("http://www.oneliferemains.com/"); navigateToURL(req, "_blank"); } } }//package zomg.olr
Section 39
//OLRLogo (zomg.olr.OLRLogo) package zomg.olr { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import flash.net.*; import zomg.gui.*; public class OLRLogo extends Sprite { protected var wait:int;// = 20 protected var myMask:Sprite; protected var show:int;// = 120 public static const FONT:String = "OLRLogo_FONT"; public function OLRLogo(s:Stage){ var contain:Sprite; super(); contain = new Sprite(); addChild(new ZoBackground(new Point(s.stageWidth, s.stageHeight))); addChild(contain); myMask = new Sprite(); myMask.graphics.beginFill(0); myMask.graphics.drawRect(0, 0, s.stageWidth, s.stageHeight); myMask.graphics.endFill(); var tfone:TextField = ZoGUI.getStdTextField(new Point(70, 20), "one", {font:"visitor2", embed:true, size:40, color:0x888888, align:"center"}, new Point(0, 0), contain); var tflife:TextField = ZoGUI.getStdTextField(new Point(75, 20), "life", {font:"visitor2", embed:true, size:40, color:0xEE0000, align:"center"}, new Point((tfone.x + tfone.width), 0), contain); var tfremains:TextField = ZoGUI.getStdTextField(new Point(125, 20), "remains", {font:"visitor2", embed:true, size:40, color:0x888888, align:"center"}, new Point((tflife.x + tflife.width), 0), contain); var tf:TextField = ZoGUI.getStdTextField(new Point(contain.width, 20), "Developed by :", {font:"visitor2", embed:true, size:20, color:0xAAAAAA, align:"center"}, new Point(0, -20), contain); tfone.selectable = (tflife.selectable = (tfremains.selectable = false)); contain.x = ((s.stageWidth / 2) - (contain.width / 2)); contain.y = ((s.stageHeight / 2) - (contain.height / 2)); addEventListener(Event.ENTER_FRAME, update); addEventListener(MouseEvent.CLICK, goto); addChild(myMask); buttonMode = true; } protected function goto(e:MouseEvent):void{ var nklink:URLRequest = new URLRequest("http://www.oneliferemains.com"); navigateToURL(nklink, "_blank"); } protected function update(e:Event=null):void{ if (wait){ wait--; } else { if (show){ if (myMask.alpha > 0){ myMask.alpha = (myMask.alpha - 0.08); } else { show--; }; } else { if (myMask.alpha < 1){ myMask.alpha = (myMask.alpha + 0.08); } else { kill(); }; }; }; } public function kill():void{ visible = false; removeEventListener(Event.ENTER_FRAME, update); removeEventListener(MouseEvent.CLICK, goto); } } }//package zomg.olr
Section 40
//OLRLogo_FONT (zomg.olr.OLRLogo_FONT) package zomg.olr { import mx.core.*; public class OLRLogo_FONT extends FontAsset { } }//package zomg.olr
Section 41
//ZoSound (zomg.sound.ZoSound) package zomg.sound { import flash.events.*; import flash.media.*; import com.greensock.*; public class ZoSound { protected var channel:SoundChannel; protected var _myVolume:Number;// = 1 protected var sndTransform:SoundTransform; protected var name:String;// = "" protected var active:Boolean;// = true protected var state:uint;// = 0 protected var loop:int;// = 1 protected var snd:Sound; protected var playing:Boolean;// = false protected var type:String;// = "" public function ZoSound(sound:Sound, name:String, type:String="music", loop:int=1, active:Boolean=true){ super(); snd = sound; this.name = name; this.type = type; this.loop = loop; sndTransform = new SoundTransform(1); this.active = active; } protected function updateChannel():void{ channel.soundTransform = sndTransform; this.myVolume = sndTransform.volume; } public function update():void{ var mute:Boolean; var typeVolume:Number; if (isPlaying()){ if (ZoSoundEngine.useSound){ mute = false; typeVolume = 1; switch (type){ case "fx": mute = ZoSoundEngine.muteFx; typeVolume = ZoSoundEngine.volumeFx; break; case "music": mute = ZoSoundEngine.muteMusic; typeVolume = ZoSoundEngine.volumeMusic; break; }; if (mute){ sndTransform.volume = 0; } else { sndTransform.volume = ((myVolume * ZoSoundEngine.globalVolume) * typeVolume); }; channel.soundTransform = sndTransform; }; }; } public function set myVolume(v:Number):void{ _myVolume = v; update(); } protected function stopChannel():void{ channel.stop(); } public function isMute():Boolean{ if (sndTransform.volume <= 0){ return (true); }; return (false); } public function get myVolume():Number{ return (_myVolume); } public function isPlaying():Boolean{ return (playing); } public function stopSound(fadeOut:Number=0):void{ if (playing){ if (fadeOut){ TweenLite.to(sndTransform, fadeOut, {volume:0, onUpdate:updateChannel, onComplete:stopChannel}); } else { stopChannel(); }; }; playing = false; } public function muteSound(mute:Boolean=true, fadeInOut:Number=0):void{ if (playing){ if (mute){ TweenLite.to(sndTransform, fadeInOut, {volume:0, onUpdate:updateChannel}); } else { TweenLite.to(sndTransform, fadeInOut, {volume:1, onUpdate:updateChannel}); }; }; } public function complete(e:Event):void{ if (loop == 0){ playSound(); } else { stopSound(); }; } public function playSound(offset:Number=0, fadeIn:Number=0):void{ if (ZoSoundEngine.playMp3){ offset = (offset + 0.025); }; if (((active) && (ZoSoundEngine.useSound))){ if (!playing){ channel = snd.play(offset, loop, sndTransform); channel.addEventListener(Event.SOUND_COMPLETE, complete); update(); } else { stopSound(); playSound(offset, fadeIn); }; if (fadeIn > 0){ TweenLite.to(sndTransform, fadeIn, {volume:1, onUpdate:updateChannel}); }; playing = true; update(); }; } } }//package zomg.sound
Section 42
//ZoSoundEngine (zomg.sound.ZoSoundEngine) package zomg.sound { public class ZoSoundEngine { public static var sounds:Object; public static var muteFx:Boolean = false; public static var muteMusic:Boolean = false; public static var useSound:Boolean = true; public static var alias:Array; public static var playMp3:Boolean = true; public static var _volumeFx:Number = 1; public static var _volumeMusic:Number = 1; public static var _globalVolume:Number = 1; public function ZoSoundEngine(){ super(); } public static function setEngineInfo(initVol:Number):void{ sounds = new Object(); alias = new Array(); globalVolume = initVol; } public static function get volumeFx():Number{ return (_volumeFx); } public static function muting(fx:Boolean=false, music:Boolean=false):void{ muteFx = fx; muteMusic = music; globalVolume = globalVolume; } public static function getSound(name:String):ZoSound{ if (sounds[name]){ return (sounds[name]); }; return (null); } public static function get globalVolume():Number{ return (_globalVolume); } public static function set volumeFx(v:Number):void{ _volumeFx = v; } public static function set volumeMusic(v:Number):void{ _volumeMusic = v; } public static function addSound(embedSound:Class, name:String="", type:String="music", loop:int=1):void{ if (!sounds[name]){ sounds[name] = new ZoSound(new (embedSound), name, type, loop, true); alias.push(name); } else { trace((("SoundEngine >> sound " + name) + " already exist ")); }; } public static function get volumeMusic():Number{ return (_volumeMusic); } public static function set globalVolume(v:Number):void{ var s:ZoSound; var i:Number; _globalVolume = v; if (alias){ i = 0; while (i < alias.length) { s = (sounds[alias[i]] as ZoSound); if (s.isPlaying()){ s.update(); }; i++; }; }; } } }//package zomg.sound
Section 43
//DebugFatalError (zomg.tools.DebugFatalError) package zomg.tools { import flash.display.*; import flash.text.*; import flash.geom.*; import zomg.gui.*; import zomg.olr.*; public class DebugFatalError extends Sprite { public function DebugFatalError(txt:String, stage:Stage){ super(); addChild(new ZoBackground(new Point(stage.stageWidth, stage.stageHeight), 0)); var tformat:TextFormat = new TextFormat(); tformat.size = 30; tformat.font = "Arial"; tformat.align = "center"; tformat.color = 0xFF0000; var tf:TextField = new TextField(); tf.selectable = false; tf.width = 800; tf.height = 100; tf.x = ((stage.stageWidth / 2) - (tf.width / 2)); tf.y = ((stage.stageHeight / 2) - (tf.height / 2)); tf.defaultTextFormat = tformat; tf.text = txt; addChild(tf); addChild(new OLRlinks(stage)); } } }//package zomg.tools
Section 44
//DebugTitle (zomg.tools.DebugTitle) package zomg.tools { import flash.events.*; import flash.display.*; import flash.text.*; public class DebugTitle extends Sprite { private var mainTitle:TextField; private var t:TextField; private var content:Array; private var titles:Array; public function DebugTitle(title:String="", cont:String=""){ super(); titles = new Array(); content = new Array(); if (title.length > 0){ addTitle(title, cont); }; createGlobal(); mainTitle = new TextField(); mainTitle.textColor = 0xFF0000; mainTitle.width = 200; mainTitle.height = 25; mainTitle.x = 0; mainTitle.y = 0; mainTitle.text = "DEBUG \n"; addChild(mainTitle); this.addEventListener(Event.ENTER_FRAME, update); } public function getTitle(ind:Number):String{ if (ind < titles.length){ return (titles[ind]); }; return (""); } public function getContent(ind:Number):String{ if (ind < content.length){ return (content[ind]); }; return (""); } public function update(e:Event):void{ var txt:String = ""; var i:Number = 0; while (i < titles.length) { txt = (txt + (((this.getTitle(i) + " : ") + this.getContent(i)) + " \n")); i++; }; t.text = txt; } public function setContent(title:String, contentAdd:String):void{ var exist:Boolean; var i:Number = 0; while (i < titles.length) { if (titles[i] == title){ content[i] = contentAdd; exist = true; }; i++; }; if (!exist){ titles.push(title); content.push(contentAdd); }; } public function addTitle(title:String, contentAdd:String=""):void{ titles.push(title); content.push(contentAdd); } public function getContentByTitle(title:String):String{ var i:Number = 0; while (i < titles.length) { if (titles[i] == title){ return (content[i]); }; i++; }; return (""); } private function createGlobal():void{ t = new TextField(); t.textColor = 0xFF00; t.width = 400; t.height = 300; t.setTextFormat(new TextFormat("Arial", 12)); t.text = ""; t.x = 10; t.y = 25; addChild(t); } } }//package zomg.tools
Section 45
//DebugTool (zomg.tools.DebugTool) package zomg.tools { import flash.geom.*; import flash.display.*; import flash.text.*; public class DebugTool extends Sprite { public var shape:Sprite; protected var color:uint; private var myType:String; private var textArray:DebugTitle; protected var pos:Point; public var myText:TextField; public function DebugTool(pos:Point=null, type:String="followGUI", textColor:uint=0xFF0000, defaultText:String=""){ super(); name = "DEBUG TEXT"; if (!pos){ pos = new Point(); }; myType = type; this.pos = pos; color = textColor; switch (myType){ case "point": createShape(); break; case "followGUI": createTextField().text = defaultText; break; default: trace("DebugTool >> wrong debug info"); break; }; mouseEnabled = false; } public function createShape():void{ shape = buildSquare(0xFF0000); shape.x = (-(width) / 2); shape.y = (-(height) / 2); addChild(shape); } public function Update():void{ switch (myType){ default: trace("Debug >> error switch"); break; }; } private function buildSquare(color:uint):Sprite{ var width:Number = 5; var height:Number = 5; var shape:Sprite = new Sprite(); shape.graphics.beginFill(color); shape.graphics.drawRect(0, 0, width, height); shape.graphics.endFill(); return (shape); } public function setText(str:String, add:Boolean=false):void{ if (add){ myText.appendText(str); } else { myText.text = str; }; } public function createTextField():TextField{ myText = new TextField(); myText.text = "DEBUG"; addChild(myText); myText.textColor = color; myText.selectable = false; myText.x = pos.x; myText.y = pos.y; myText.width = 500; myText.height = 200; myText.mouseEnabled = false; return (myText); } public function pointColor(color:uint):void{ shape.graphics.clear(); shape = buildSquare(color); toggleShape(true); } public function toggleShape(flag:Boolean=true):Boolean{ if (flag){ addChild(shape); } else { removeChild(shape); }; return (flag); } } }//package zomg.tools
Section 46
//ZoConsole (zomg.tools.ZoConsole) package zomg.tools { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import zomg.*; import zomg.gui.*; import flash.ui.*; public class ZoConsole extends Sprite { protected var owners:Array; public var size:Point; protected var k:ZoKeys; public var tf:TextField; protected var lines:Array; public function ZoConsole(s:Stage, fpsManager:Sprite){ size = new Point(500, 300); tf = ZoGUI.getStdTextField(size, "BLAH BLAH BLAH", {size:12, font:"Arial", embed:false, align:"left", color:0xFFFFFF}); lines = new Array(); owners = new Array(); super(); addChild(new ZoBackground(size, 16768477, 150)); k = new ZoKeys(s, new Array(new ZoKey(Keyboard.TAB, "show")), "console"); addChild(tf); tf.x = (tf.y = 10); if (fpsManager){ addChild(fpsManager); fpsManager.x = (size.x + 10); fpsManager.y = y; }; addEventListener(Event.ENTER_FRAME, update); x = (y = 10); visible = false; } protected function update(e:Event=null):void{ if (k.getKeyStateByName("show")){ visible = true; } else { visible = false; }; } public function addLine(s:String="", from:String=""):void{ trace(((("[console] " + from) + " >> ") + s)); tf.text = "Console > \n"; lines.push(s); owners.push(from); var start:uint; if (lines.length > 20){ start = (lines.length - 20); }; var i:uint = start; while (i < lines.length) { tf.appendText((((owners[i] + " >> ") + lines[i]) + "\n")); i++; }; } } }//package zomg.tools
Section 47
//ZoMathTools (zomg.tools.ZoMathTools) package zomg.tools { import flash.geom.*; public class ZoMathTools { public function ZoMathTools(){ super(); } public static function getAngleVector(myPos:Point, aimPos:Point):Number{ var angle:Number = ZoMathTools.dirRotation(myPos, aimPos); if (angle < 0){ return (-(angle)); }; return ((360 - angle)); } public static function thresholdInt(min:int, max:int, val:int):int{ if (val < min){ val = min; } else { if (val > max){ val = max; }; }; return (val); } public static function randomBetween(min:Number, max:Number, round:Boolean=false):Number{ var val:Number = ((Math.random() * (max - min)) + min); if (round){ return (Math.round(val)); }; return (val); } public static function linearTransform(intA:Point, intB:Point, val:Number):Number{ return (((((val - intA.x) / (intA.y - intA.x)) * (intB.y - intB.x)) + intB.x)); } public static function vectorLength(pt:Point):Number{ return (Math.sqrt((Math.pow(pt.x, 2) + Math.pow(pt.y, 2)))); } public static function addDirRotation(dir:Point, rot:Number=90):Point{ var diff:Number = ZoMathTools.degreeToRadian((ZoMathTools.radianToDegree(Math.acos(dir.x)) + rot)); var pt:Point = new Point(Math.cos(diff), Math.sin(diff)); return (pt); } public static function getDirectionVec(myPos:Point, aimPos:Point):Point{ return (normalize(new Point((aimPos.x - myPos.x), (aimPos.y - myPos.y)))); } public static function normalize(pt:Point):Point{ var length:Number = Math.sqrt(((pt.x * pt.x) + (pt.y * pt.y))); if (length != 0){ return (new Point((pt.x / length), (pt.y / length))); }; return (new Point()); } public static function isNearZeroThreshold(limit:Number, val:Number):Number{ if ((((val > -(limit))) && ((val < limit)))){ return (0); }; return (val); } public static function roundNear(val:Number, digit:Number=2):Number{ var num:Number = Math.pow(10, digit); return ((Math.round((val * num)) / num)); } public static function getVectorAngle(pt:Point):Number{ var degCos:Number = ZoMathTools.radianToDegree(Math.acos(pt.x)); if (pt.x > 0){ if (pt.y == 0){ return (0); }; if (pt.y > 0){ return (degCos); }; if (pt.y < 0){ return ((360 - degCos)); }; } else { if (pt.x < 0){ if (pt.y == 0){ return (180); }; if (pt.y > 0){ return (degCos); }; if (pt.y < 0){ return ((180 + (180 - degCos))); }; } else { if (pt.x == 0){ if (pt.y == 0){ return (0); }; if (pt.y > 0){ return (90); }; if (pt.y < 0){ return (270); }; }; }; }; return (0); } public static function isNearValue(val:Number, nearValue:Number, gap:Number=0.1, deg:Boolean=false):Boolean{ var intervB:Point; var interv:Point = new Point((nearValue - gap), (nearValue + gap)); var flag:Boolean; if ((((val < interv.y)) && ((val > interv.x)))){ flag = true; } else { if (deg){ intervB = new Point(); if ((nearValue + gap) > 360){ intervB.x = 0; intervB.y = ((nearValue + gap) - 360); } else { if ((nearValue - gap) < 0){ intervB.x = ((360 - nearValue) - gap); intervB.y = 360; }; }; if ((((val < intervB.y)) && ((val > intervB.x)))){ flag = true; }; }; }; return (flag); } public static function reduceToMax(aim:Number, step:Number, value:Number):Number{ if (Math.abs(value) > Math.abs(aim)){ value = (value + (-(ZoMathTools.sign(aim)) * step)); return (value); }; return (value); } public static function randomBoolean():Boolean{ if (Math.random() > 0.5){ return (true); }; return (false); } public static function degreeToRadian(angle:Number):Number{ return ((angle * (Math.PI / 180))); } public static function getAngleVector180(pt:Point):Number{ var angle:Number = ZoMathTools.radianToDegree(Math.acos(pt.x)); if (pt.y < 0){ return (-(angle)); }; if (pt.y > 0){ return (angle); }; return (0); } public static function threshold(min:Number, max:Number, val:Number):Number{ if (val < min){ val = min; } else { if (val > max){ val = max; }; }; return (val); } public static function circleInter(home:Point, dest:Point, circleCenter:Point, circleRadius:Number):Point{ var distA:Number; var distB:Number; var a:Number = (Math.pow((dest.x - home.x), 2) + Math.pow((dest.y - home.y), 2)); var b:Number = (2 * (((dest.x - home.x) * (home.x - circleCenter.x)) + ((dest.y - home.y) * (home.y - circleCenter.y)))); var c:Number = (((((Math.pow(circleCenter.x, 2) + Math.pow(circleCenter.y, 2)) + Math.pow(home.x, 2)) + Math.pow(home.y, 2)) - (2 * ((circleCenter.x * home.x) + (circleCenter.y * home.y)))) - Math.pow(circleRadius, 2)); var coef:Number = ((b * b) - ((4 * a) * c)); var k1:Number = 0; var k2:Number = 0; var ptA:Point = new Point(); var ptB:Point = new Point(); if (coef == 0){ k1 = (-(b) / (2 * a)); } else { if (coef > 0){ k1 = ((-(b) - Math.sqrt(coef)) / (2 * a)); k2 = ((-(b) + Math.sqrt(coef)) / (2 * a)); }; }; if (k1 != 0){ ptA = new Point((home.x + (k1 * (dest.x - home.x))), (home.y + (k1 * (dest.y - home.y)))); distA = ZoMathTools.distance(home, ptA); if (k2 != 0){ ptB = new Point((home.x + (k2 * (dest.x - home.x))), (home.y + (k2 * (dest.y - home.y)))); distB = ZoMathTools.distance(home, ptB); if (distA < distB){ return (ptA); }; return (ptB); } else { return (ptA); }; }; return (new Point()); } public static function getDirectionObj(me:Object, aim:Object):Point{ return (normalize(new Point((aim.x - me.x), (aim.y - me.y)))); } public static function radianToDegree(angle:Number):Number{ return ((angle * (180 / Math.PI))); } public static function getAdjAngle(adjLen:Number, oppoLen:Number):Number{ var hyp:Number = Math.sqrt((Math.pow(adjLen, 2) + Math.pow(oppoLen, 2))); var c:Number = (adjLen / hyp); return (ZoMathTools.radianToDegree(Math.acos(c))); } public static function dirRotation(pta:Point, ptb:Point):Number{ return ((Math.atan2((ptb.y - pta.y), (ptb.x - pta.x)) / (Math.PI / 180))); } public static function distance(pta:Point, ptb:Point):Number{ return (Math.sqrt((Math.pow((ptb.x - pta.x), 2) + Math.pow((ptb.y - pta.y), 2)))); } public static function getAdj(adjLen:Number, adjAng:Number):Number{ var hyp:Number = (adjLen / Math.cos(adjAng)); return (Math.sqrt((Math.pow(hyp, 2) - Math.pow(adjLen, 2)))); } public static function destinationPoint(origin:Point, dir:Point, lenght:Number):Point{ return (new Point((origin.x + (dir.x * lenght)), (origin.y + (dir.y * lenght)))); } public static function sign(val:Number):Number{ if (val > 0){ return (1); }; if (val < 0){ return (-1); }; return (0); } public static function isBetween(x:Number, min:Number, max:Number):Boolean{ if ((((x < min)) || ((x > max)))){ return (false); }; return (true); } } }//package zomg.tools
Section 48
//ZoSitelock (zomg.tools.ZoSitelock) package zomg.tools { public class ZoSitelock { public static var domain:String = ""; public function ZoSitelock(){ super(); } public static function SiteLock(myUrl:String, allowLocal:Boolean=false, urls_allowed:Array=null):Boolean{ var url:String; var urlStart:Number; var urlEnd:Number; var domain:String; var LastDot:Number; var domEnd:Number; var i:Number; var lock:Boolean; if (urls_allowed){ url = myUrl; urlStart = (url.indexOf("://") + 3); urlEnd = url.indexOf("/", urlStart); domain = url.substring(urlStart, urlEnd); LastDot = (domain.lastIndexOf(".") - 1); domEnd = (domain.lastIndexOf(".", LastDot) + 1); domain = domain.substring(domEnd, domain.length); if (allowLocal){ if (myUrl.indexOf("file://") > -1){ lock = false; }; }; if (lock){ i = 0; while (i < urls_allowed.length) { if (urls_allowed[i] == domain){ trace(("-" + urls_allowed[i])); lock = false; }; i++; }; }; if (domain.length > 0){ _slot1.domain = domain; } else { _slot1.domain = "[local]"; }; } else { _slot1.domain = "No domain list"; }; trace(((((((("ZoSiteLock >> (file:" + myUrl.indexOf("file://")) + " | web:") + lock) + ") URL:") + myUrl) + " || Real domain:") + domain)); return (lock); } } }//package zomg.tools
Section 49
//ZoTools (zomg.tools.ZoTools) package zomg.tools { import flash.geom.*; import flash.display.*; import flash.net.*; public class ZoTools { public function ZoTools(){ super(); } public static function getSlotLevel(ar:Array, lvl:int=0):Array{ var temp:Array; var result:Array = new Array(); var middle:int = Math.round((ar.length / 2)); result.push(middle); var i:uint = 1; while (i < lvl) { if ((middle - i) > 0){ temp = new Array(); temp.push((middle - i)); result = temp.concat(result); }; result.push((middle + i)); i++; }; return (result); } public static function cookie(cookieName:String="olr", saveState:SharedObject=null):SharedObject{ var myState:SharedObject; if (saveState){ myState = saveState; myState.flush(); } else { myState = SharedObject.getLocal(cookieName); }; return (myState); } public static function sortChildrenDepth(container:DisplayObjectContainer, param:String="y"):Boolean{ var depthsSwapped:Boolean; var child:DisplayObject; var numChildren:int = container.numChildren; if (numChildren < 2){ return (false); }; var children:Array = new Array(numChildren); var i = -1; while (++i < numChildren) { children[i] = container.getChildAt(i); }; children.sortOn(param, Array.NUMERIC); i = -1; while (++i < numChildren) { child = DisplayObject(children[i]); if (i != container.getChildIndex(child)){ depthsSwapped = true; container.setChildIndex(child, i); }; }; return (depthsSwapped); } public static function removeArrayElement(ar:Array, elmt:Object):Array{ var ar_aft:Array; var ar_bef:Array; var i:Number = ar.indexOf(elmt); var arr:Array = ar; if (i > -1){ ar_aft = ar.slice((i + 1)); ar_bef = ar.slice(0, i); arr = ar_bef.concat(ar_aft); }; return (arr); } public static function transformToPoint(s:String):Point{ var ar:Array = s.split(","); return (new Point(Number(ar[0]), Number(ar[1]))); } public static function insertInFront(ar:Array, elmt:Object):Array{ var arr:Array = new Array(elmt); return (arr.concat(ar)); } } }//package zomg.tools
Section 50
//ZoColor (zomg.ZoColor) package zomg { import flash.geom.*; import flash.display.*; import zomg.tools.*; public class ZoColor { private var num:uint; public function ZoColor(value:uint, valueS:String=""){ super(); this.num = value; if (valueS.length > 0){ this.num = uint(value); }; } public function toString():String{ var str:String = "ColorManager >> "; str = (str + (" A:" + ((num & 4278190080) >>> 24))); str = (str + (" R:" + ((num & 0xFF0000) >>> 16))); str = (str + (" G:" + ((num & 0xFF00) >>> 8))); str = (str + (" B:" + (num & 0xFF))); return (str); } public static function getImageFromSheet(sheet:Bitmap, size:Point, posOnSheet:Point=null):Bitmap{ if (!posOnSheet){ posOnSheet = new Point(); }; var current:Bitmap = new Bitmap(new BitmapData(size.x, size.y)); var upLeft:Point = new Point((posOnSheet.y * size.x), (posOnSheet.x * size.y)); var coord:Rectangle = new Rectangle(upLeft.x, upLeft.y, size.x, size.y); current.bitmapData.copyPixels(sheet.bitmapData, coord, new Point()); return (current); } public static function getRandomColor(alpha:Number=0xFF):uint{ alpha = ZoMathTools.threshold(0, 0xFF, alpha); return (new ColorTransform(0, 0, 0, 0, ZoMathTools.randomBetween(0, 0xFF), ZoMathTools.randomBetween(0, 0xFF), ZoMathTools.randomBetween(0, 0xFF), alpha).color); } public static function drawCross(length:Number=10, tickness:Number=1, color:uint=0xFF0000):Sprite{ var s:Sprite = new Sprite(); s.graphics.lineStyle(3, color); s.graphics.moveTo(-(length), 0); s.graphics.lineTo(length, 0); s.graphics.moveTo(0, -(length)); s.graphics.lineTo(0, length); return (s); } public static function rgbaToUint(r:Number=0, g:Number=0, b:Number=0, a:Number=0xFF):uint{ return (new ColorTransform(0, 0, 0, 0, r, g, b, a).color); } public static function getComponentValue(color:uint, component:String):Number{ switch (component){ case "a": return (((color & 4278190080) >>> 24)); case "r": return (((color & 0xFF0000) >>> 16)); case "g": return (((color & 0xFF00) >>> 8)); case "b": return ((color & 0xFF)); default: trace("World >> getPixelCompo error"); break; }; return (-1); } public static function getRandomColorComponent(component:String="r", alpha:Number=0xFF):uint{ var r:Number = 0; var g:Number = 0; var b:Number = 0; switch (component){ case "r": r = ZoMathTools.randomBetween(0, 0xFF); break; case "g": g = ZoMathTools.randomBetween(0, 0xFF); break; case "b": b = ZoMathTools.randomBetween(0, 0xFF); break; }; alpha = ZoMathTools.threshold(0, 0xFF, alpha); return (new ColorTransform(0, 0, 0, 0, r, g, b, alpha).color); } public static function setSpriteColor(sprite:Sprite, color:uint):void{ var r:Number = ((color >> 16) & 0xFF); var g:Number = ((color >> 8) & 0xFF); var b:Number = (color & 0xFF); sprite.transform.colorTransform = new ColorTransform(0, 0, 0, 0xFF, r, g, b, 0xFF); } public static function getPixelComponent(map:Bitmap, x:Number, y:Number, component:String):Number{ return (ZoColor.getComponentValue(map.bitmapData.getPixel32(x, y), "a")); } public static function getRandomGrayscale(alpha:Number):uint{ alpha = ZoMathTools.threshold(0, 0xFF, alpha); var rand:Number = ZoMathTools.randomBetween(0, 0xFF); return (new ColorTransform(0, 0, 0, 0, rand, rand, rand, alpha).color); } } }//package zomg
Section 51
//ZoCursor (zomg.ZoCursor) package zomg { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.ui.*; public class ZoCursor extends ZoSprite { public var left:Boolean;// = false protected var _state:uint; protected var s:Stage; private var sheet_cursor:Class; public static var BUSY:uint = 3; public static var NO:uint = 2; public static var OVER:uint = 1; public static var POINT:uint = 4; public static var IDLE:uint = 0; public function ZoCursor(s:Stage, listenClick:Boolean=false, bmp:Bitmap=null, sizeOfPointer:Point=null){ var img:Bitmap; sheet_cursor = ZoCursor_sheet_cursor; name = "[ZoCursor]Cursor"; this.s = s; var size:Point = new Point(32, 32); if (bmp){ img = bmp; size = sizeOfPointer; }; super(img, size, new Point()); mouseEnabled = false; mouseChildren = false; if (symbol){ symbol.name = "Cursor Sheet"; symbol.addAnim("idle", size, 1, new Point()); }; if (bmp){ symbol.addAnim("over", size, 1, new Point(0, 1)); symbol.addAnim("no", size, 1, new Point(1, 0)); symbol.addAnim("busy", size, 1, new Point(1, 1)); symbol.addAnim("point", size, 1, new Point(0, 2)); }; setCursor(); if (listenClick){ s.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown); s.addEventListener(MouseEvent.MOUSE_UP, mouseRelease); }; addEventListener(Event.ENTER_FRAME, update); if (symbol){ Mouse.hide(); }; } public function get state():uint{ return (_state); } public function activate(flag:Boolean=false):void{ if (flag){ Mouse.hide(); } else { Mouse.show(); }; symbol.visible = flag; } protected function update(e:Event):void{ x = s.mouseX; y = s.mouseY; } public function reset():void{ left = false; } override public function get position():Point{ return (localToGlobal(new Point(0, 0))); } protected function mouseRelease(e:MouseEvent):void{ left = false; } public function setCursor(status:uint=0):void{ var anim:String = "idle"; switch (status){ case OVER: anim = "over"; break; case NO: anim = "no"; break; case BUSY: anim = "busy"; break; case POINT: anim = "point"; break; }; state = status; if (symbol){ symbol.playAnim(anim); }; } public function set state(v:uint):void{ _state = v; } protected function mouseDown(e:MouseEvent):void{ left = true; } } }//package zomg
Section 52
//ZoCursor_sheet_cursor (zomg.ZoCursor_sheet_cursor) package zomg { import mx.core.*; public class ZoCursor_sheet_cursor extends BitmapAsset { } }//package zomg
Section 53
//ZoKey (zomg.ZoKey) package zomg { public class ZoKey { protected var _name:String; protected var _code:uint; protected var _state:Boolean; public function ZoKey(c:uint, n:String){ super(); this.code = c; this.name = n; this.state = false; } public function set state(v:Boolean):void{ _state = v; } public function get name():String{ return (_name); } public function get code():uint{ return (_code); } public function get state():Boolean{ return (_state); } public function set name(v:String):void{ _name = v; } public function set code(v:uint):void{ _code = v; } } }//package zomg
Section 54
//ZoKeys (zomg.ZoKeys) package zomg { import flash.events.*; import flash.display.*; public class ZoKeys { protected var owner:String;// = "" protected var isActive:Boolean; protected var _lastReleased:uint; protected var _lastPressed:uint; protected var keys:Array; protected var s:Stage; public function ZoKeys(s:Stage, k:Array, owner:String=""){ super(); this.s = s; this.owner = owner; keys = new Array(0xFF); assign(k); isActive = false; toggleKeys(true); } public function getNameOfCode(keyCode:uint):String{ return (keys[keyCode].name); } public function active():Boolean{ return (isActive); } protected function clean():void{ var i:Number = 0; while (i < keys.length) { if (keys[i]){ keys[i].state = false; }; i++; }; } public function getKeyStateByName(keyName:String):Boolean{ return (keys[getKeyId(keyName)].state); } public function get lastReleased():uint{ return (_lastReleased); } public function myKeyUp(e:KeyboardEvent):void{ if (keys[e.keyCode]){ keys[e.keyCode].state = false; lastReleased = e.keyCode; }; } public function myKeyDown(e:KeyboardEvent):void{ if (keys[e.keyCode]){ keys[e.keyCode].state = true; lastPressed = e.keyCode; }; } public function getKeyCodeOfName(keyName:String):uint{ return (keys[getKeyId(keyName)].code); } public function set lastPressed(v:uint):void{ _lastPressed = v; } protected function getKeyId(keyName:String):Number{ var i:Number = 0; while (i < keys.length) { if (keys[i]){ if (keys[i].name == keyName){ return (i); }; }; i++; }; return (-1); } public function getKeyStateByCode(keyCode:uint):Boolean{ return (keys[keyCode].state); } protected function assign(k:Array):void{ var i:Number = 0; while (i < k.length) { keys[k[i].code] = k[i]; i++; }; } public function toggleKeys(active:Boolean):void{ if (((!(isActive)) && (active))){ s.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown); s.addEventListener(KeyboardEvent.KEY_UP, myKeyUp); } else { if (((isActive) && (!(active)))){ s.removeEventListener(KeyboardEvent.KEY_DOWN, myKeyDown); s.removeEventListener(KeyboardEvent.KEY_UP, myKeyUp); clean(); }; }; isActive = active; } public function get lastPressed():uint{ return (_lastPressed); } public function set lastReleased(v:uint):void{ _lastReleased = v; } } }//package zomg
Section 55
//ZoObject (zomg.ZoObject) package zomg { import flash.geom.*; import flash.display.*; import zomg.tools.*; public class ZoObject extends Sprite { protected var _direction:Point; protected var _infrustrum:Boolean;// = false protected var _position:Point; protected var _active:Boolean;// = true public function ZoObject(){ _position = new Point(); _direction = new Point(); super(); } public function get active():Boolean{ return (_active); } public function inFront(obj:Object, wideangle:Number):Boolean{ var pt:Point = ZoMathTools.getDirectionVec(position, new Point(obj.x, obj.y)); var angle:Number = ZoMathTools.getVectorAngle(direction); if (ZoMathTools.isNearValue(angle, ZoMathTools.getVectorAngle(pt), wideangle)){ return (true); }; return (false); } public function set active(v:Boolean):void{ _active = v; } public function get mySize():Point{ return (new Point(width, height)); } public function isInFrustrum():Boolean{ infrustrum = true; var pos:Point = localToGlobal(new Point()); if (stage){ if ((((pos.x < -100)) || ((pos.x > (stage.stageWidth + 100))))){ infrustrum = false; } else { if ((((pos.y < -100)) || ((pos.y > (stage.stageHeight + 100))))){ infrustrum = false; }; }; }; return (infrustrum); } public function set infrustrum(v:Boolean):void{ _infrustrum = v; } public function set position(v:Point):void{ _position = v; x = v.x; y = v.y; } public function getLocalDir():Point{ var me:Point = new Point(0, 0); var forward:Point = localToGlobal(direction); var diff:Point = new Point(direction.x, (forward.y - me.y)); return (ZoMathTools.normalize(diff)); } public function getRealDirection():Point{ var rot:Number = 0; if (rotation > 0){ rot = (360 - rotation); }; rot = -(rotation); return (new Point(Math.cos(ZoMathTools.degreeToRadian(rot)), Math.sin(ZoMathTools.degreeToRadian(rot)))); } public function getTowardObjDir(aim:Object):Point{ var forward:Point = new Point(aim.x, aim.y); var diff:Point = new Point((forward.x - x), (forward.y - y)); return (ZoMathTools.normalize(diff)); } public function getTowardVecDir(aimPos:Point):Point{ var diff:Point = new Point((aimPos.x - x), (aimPos.y - y)); return (ZoMathTools.normalize(diff)); } public function get position():Point{ _position = new Point(x, y); return (_position); } public function get infrustrum():Boolean{ return (_infrustrum); } public function getTheRadius():Number{ return ((scaleX * (width / 2))); } public function getTowardMouseDir():Point{ var me:Point = localToGlobal(new Point(0, 0)); var forward:Point = localToGlobal(new Point(mouseX, mouseY)); var diff:Point = new Point((forward.x - me.x), (forward.y - me.y)); return (ZoMathTools.normalize(diff)); } public function toggleActive():Boolean{ if (active){ visible = (active = false); } else { visible = (active = true); }; return (active); } public function set direction(v:Point):void{ _direction = v; rotation = ZoMathTools.dirRotation(new Point(), v); } public function get direction():Point{ var rot:Number = rotation; _direction = new Point(Math.cos(ZoMathTools.degreeToRadian(rotation)), Math.sin(ZoMathTools.degreeToRadian(rotation))); return (_direction); } } }//package zomg
Section 56
//ZoPreloader (zomg.ZoPreloader) package zomg { import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.utils.*; import zomg.gui.*; public class ZoPreloader { public var container:Sprite; public var par:MovieClip; protected var done:Boolean;// = false public var tf:TextField; public var tfpercent:TextField; public var lb:ZoLoadBar; protected var finalSize:Number;// = 0 protected var classToLoad:String; public function ZoPreloader(parent:MovieClip, className:String="Main"):void{ tf = ZoGUI.getStdTextField(new Point(300, 20), "", {size:10, color:0xAAAAAA}); tfpercent = ZoGUI.getStdTextField(new Point(50, 20), "", {size:10, color:0xAAAAAA}); super(); container = new Sprite(); classToLoad = className; par = parent; var url:String = parent.loaderInfo.loaderURL; parent.addEventListener(Event.ENTER_FRAME, checkFrame); parent.loaderInfo.addEventListener(ProgressEvent.PROGRESS, progress); var lbSize:Point = new Point(60, 10); lb = new ZoLoadBar(lbSize); lb.x = ((parent.stage.stageWidth / 2) - (lbSize.x / 2)); lb.y = ((parent.stage.stageHeight / 2) - (lbSize.y / 2)); tfpercent.text = "0%"; tfpercent.x = ((lb.x + lbSize.x) + 3); tfpercent.y = (lb.y - (lbSize.y / 4)); tf.x = lb.x; tf.y = (lb.y + 20); container.addChild(lb); container.addChild(tf); container.addChild(tfpercent); parent.addChild(container); } private function checkFrame(e:Event):void{ if (par.currentFrame == par.totalFrames){ par.removeEventListener(Event.ENTER_FRAME, checkFrame); startup(); }; } private function progress(e:ProgressEvent):void{ lb.current = int(((e.bytesLoaded / e.bytesTotal) * 100)); finalSize = e.bytesTotal; tf.text = ((e.bytesLoaded + " / ") + e.bytesTotal); tfpercent.text = (lb.current + " %"); trace(("ZoPreloader > current load:" + tf.text)); } public function isDone():Boolean{ return (done); } private function startup():void{ par.stop(); par.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progress); var mainClass:Class = (getDefinitionByName(classToLoad) as Class); par.addChild((new (mainClass) as Sprite)); container.removeChild(lb); container.removeChild(tf); container.removeChild(tfpercent); par.removeChild(container); trace("ZoPreloader > End of load"); done = true; } } }//package zomg
Section 57
//ZoSheet (zomg.ZoSheet) package zomg { import flash.geom.*; import flash.display.*; public class ZoSheet extends Sprite { protected var sFlip:Boolean;// = false protected var anims:Array; protected var currentLoop:uint;// = 0 protected var zeroPoint:Point; public var pos:Number;// = 0 protected var sh:BitmapData; protected var loop:uint;// = 0 protected var _currentAnim:String;// = "" protected var timerAnim:Number;// = 0 public var useAnim:Boolean;// = true protected var current:Bitmap; protected var animSpeed:Number;// = 0 public function ZoSheet(img:Bitmap, size:Point, offset:Point=null, rotate:Number=0){ zeroPoint = new Point(); super(); if (!offset){ offset = new Point(); }; sh = img.bitmapData; anims = new Array(); current = new Bitmap(new BitmapData(size.x, size.y, true, 0)); current.x = -(((size.x / 2) + offset.x)); current.y = -(((size.y / 2) + offset.y)); addChild(current); current.rotation = rotate; } public function update():void{ var ind:Number = hasAnim(_currentAnim); var loopDone:Boolean; if (useAnim){ if (timerAnim == 0){ if ((((currentLoop < loop)) || ((loop == 0)))){ if (currentAnim.length > 1){ if (ind > -1){ if (anims[ind].length > 0){ pos = (pos + anims[ind].dir); if (anims[ind].backForth){ if ((((((anims[ind].dir < 0)) && ((pos <= 0)))) && (anims[ind].backForth))){ anims[ind].dir = (anims[ind].dir * -1); loopDone = true; } else { if ((((anims[ind].dir > 0)) && ((pos >= anims[ind].length)))){ if (anims[ind].backForth){ anims[ind].dir = (anims[ind].dir * -1); } else { pos = anims[ind].colInit; }; }; }; } else { if (anims[ind].backWard){ if (pos <= 0){ pos = anims[ind].length; loopDone = true; }; } else { if (pos >= anims[ind].length){ pos = anims[ind].colInit; loopDone = true; }; }; }; if (((loopDone) && (!((loop == 0))))){ if (loop > 0){ currentLoop++; }; if (loop == currentLoop){ if (anims[ind].backWard){ pos = 0; } else { pos = anims[ind].length; }; }; }; setImage(currentAnim, pos); }; } else { trace(("ZoSheet >> no anim with name : " + currentAnim)); }; if (sFlip){ this.scaleX = -1; }; } else { trace("ZoSheet >> no anim asked"); }; }; }; }; if (anims[ind].speed > 0){ if (timerAnim < anims[ind].speed){ timerAnim++; } else { timerAnim = 0; }; }; } public function switchSheet(img:Bitmap):void{ sh = img.bitmapData; } public function addAnim(name:String, size:Point, length:Number, initPos:Point, animSpeed:uint=30, backForth:Boolean=false, backWard:Boolean=false):void{ var obj:Object = new Object(); obj["name"] = name; obj["rowInit"] = initPos.x; obj["colInit"] = initPos.y; obj["length"] = (length - 1); obj["width"] = size.x; obj["height"] = size.y; obj["speed"] = animSpeed; obj["backForth"] = backForth; obj["backWard"] = backWard; obj["dir"] = 1; anims.push(obj); } protected function setImage(name:String, currentPos:Number):void{ var upLeft:Point; var coord:Rectangle; var info:Object = getAnimParams(name); current.bitmapData = new BitmapData(info.width, info.height); if (info){ upLeft = new Point(((info.colInit + currentPos) * info.width), (info.rowInit * info.height)); coord = new Rectangle(upLeft.x, upLeft.y, info.width, info.height); current.bitmapData.copyPixels(sh, coord, zeroPoint); }; } protected function hasAnim(name:String):Number{ var i:Number = 0; while (i < anims.length) { if (anims[i].name == name){ return (i); }; i++; }; return (-1); } public function set currentAnim(v:String):void{ _currentAnim = v; } public function getInfos():void{ var ind:Number = hasAnim(currentAnim); trace(((((((((((("anim:" + currentAnim) + " | pos:(") + getAnimParams(currentAnim).rowInit) + ",") + pos) + ") - length:") + anims[ind].length) + " - current/loop:") + currentLoop) + "/") + loop)); } public function playAnimId(ind:uint, loop:uint=0, flip:Boolean=false):Boolean{ if (anims[ind]){ currentAnim = anims[ind].name; sFlip = flip; pos = -1; currentLoop = 0; this.loop = loop; if (anims[ind].backWard){ anims[ind].dir = -1; pos = anims[ind].length; }; if (anims[ind].length == 0){ setImage(currentAnim, 0); } else { update(); }; return (true); }; return (false); } public function hasFinishedPlaying(name:String):Boolean{ var ind:Number; if (name == currentAnim){ if (loop > 0){ ind = hasAnim(currentAnim); if (currentLoop == loop){ return (true); }; }; }; return (false); } public function playAnim(name:String, loop:uint=0, flip:Boolean=false):Boolean{ var i:Number = 0; while (i < anims.length) { if (anims[i].name == name){ return (playAnimId(i, loop, flip)); }; i++; }; return (false); } public function getAnimParams(name:String):Object{ var anim:Object; var i:Number = 0; while (i < anims.length) { if (anims[i].name == name){ return (anims[i]); }; i++; }; return (null); } public function get currentAnim():String{ return (_currentAnim); } public function currentAnimLength():Number{ return (anims[hasAnim(currentAnim)].length); } } }//package zomg
Section 58
//ZoSprite (zomg.ZoSprite) package zomg { import flash.geom.*; import flash.display.*; import zomg.tools.*; public class ZoSprite extends ZoObject { public var size:Point; public var symbol:ZoSheet; protected var useSheet:Boolean;// = true public function ZoSprite(sheet:Bitmap=null, objSize:Point=null, initPos:Point=null, offset:Point=null, rotation:Number=0, singleImage:Boolean=false){ super(); if (initPos){ position = initPos; } else { position = new Point(); }; if (objSize){ size = objSize; } else { size = new Point(0, 0); }; if (sheet){ symbol = new ZoSheet(sheet, objSize, offset, rotation); symbol.name = (((((("ZoSheet_spritesheet - " + this) + " - ") + sheet) + " (") + position) + ")"); addChild(symbol); sheet.x = (-(sheet.width) / 2); sheet.y = (-(sheet.height) / 2); if (singleImage){ symbol.addAnim("idle", size, 1, new Point()); symbol.playAnim("idle"); }; } else { useSheet = false; }; } protected function symbolLookAtPoint(pt:Point):void{ symbol.rotation = ZoMathTools.dirRotation(new Point(this.x, this.y), new Point(pt.x, pt.y)); } public function getCirclePoints(percSize:Number=0.5, n:Number=10):Array{ var theta:Number; var pointOnCircle:Point; var alpha:Number = ((Math.PI * 2) / n); var points:Array = new Array((n + 1)); var radius:Number = (size.x * percSize); points[0] = new Point(0, 0); var i:int; while (i++ < n) { theta = (alpha * i); pointOnCircle = new Point((Math.cos(theta) * radius), (Math.sin(theta) * radius)); points[i] = pointOnCircle; }; return (points); } protected function symbolLookAt(obj:Sprite):void{ symbol.rotation = ZoMathTools.dirRotation(new Point(this.x, this.y), new Point(obj.x, obj.y)); } protected function lookAt(obj:Sprite):void{ rotation = ZoMathTools.dirRotation(new Point(this.x, this.y), new Point(obj.x, obj.y)); } public function getSizeRect():Rectangle{ return (new Rectangle(0, 0, size.x, size.y)); } public function getRectPoints():Array{ return (new Array(new Point(this.x, this.y), new Point((this.x - (size.x / 2)), (this.y - (size.y / 2))), new Point((this.x + (size.x / 2)), (this.y - (size.y / 2))), new Point((this.x - (size.x / 2)), (this.y + (size.y / 2))), new Point((this.x + (size.x / 2)), (this.y + (size.y / 2))))); } } }//package zomg
Section 59
//Background (Background) package { import flash.geom.*; import flash.display.*; import zomg.*; import zomg.tools.*; public class Background extends Sprite { protected var paralax:Sprite; protected var max:int;// = 1000 protected var move:Boolean;// = false protected var _useStars:Boolean;// = true public static var sheet_stars:Class = Background_sheet_stars; public static var zoneColor:Array = new Array(7517873, 8089524, 15955815, 15911027, 8762994, 4612833); protected static var speedMin:Number = 0.01; protected static var speedMax:Number = 0.05; public function Background(nb:int=1){ paralax = new Sprite(); super(); x = -200; y = -200; needMore(paralax, nb); addChild(paralax); visible = false; } public function countStars():int{ var res:int = paralax.numChildren; return (res); } protected function needMore(paralax:Sprite, nb:int=1):void{ var img:Bitmap; var i:uint; i = 0; while (i < nb) { img = ZoColor.getImageFromSheet(new sheet_stars(), new Point(16, 16), new Point(0, ZoMathTools.randomBetween(0, 2, true))); img.alpha = 0.4; paralax.addChild(img); i++; }; } public function clear():Boolean{ while (paralax.numChildren) { paralax.removeChildAt(0); }; removeChild(paralax); return (true); } public function init(bgColorZone:int=0, move:Boolean=false):void{ var i:uint; var num:int; this.move = move; Global.g.bgColor.switchColor(Background.zoneColor[bgColorZone]); if (useStars){ num = 200; if (num > max){ num = max; }; if (paralax.numChildren < num){ needMore(paralax, (num - paralax.numChildren)); }; i = 0; while (i < paralax.numChildren) { newPos(paralax.getChildAt(i)); i++; }; }; visible = true; } protected function newPos(obj:DisplayObject):void{ var size:Point = Global.g.appSize.add(new Point(400, 400)); obj.x = ZoMathTools.randomBetween(0, size.x); obj.y = ZoMathTools.randomBetween(0, size.y); } public function motion(move:Point):void{ var pos:Point; if (this.move){ pos = new Point((paralax.x + (-(move.x) / 20)), (paralax.y + (-(move.y) / 15))); paralax.x = pos.x; paralax.y = pos.y; }; } public function get useStars():Boolean{ return (_useStars); } public function set useStars(v:Boolean):void{ _useStars = v; visible = v; } public function removeStars(flag:Boolean=false):void{ paralax.visible = flag; } } }//package
Section 60
//Background_sheet_stars (Background_sheet_stars) package { import mx.core.*; public class Background_sheet_stars extends BitmapAsset { } }//package
Section 61
//Border (Border) package { import flash.geom.*; import flash.display.*; import zomg.tools.*; public class Border extends Sprite { protected var timer:int;// = 0 protected var theHeight:Number;// = 0 protected var dir:int;// = 1 protected var alphaBound:Point; protected var bottomright:Sprite; protected var theWidth:Number;// = 0 protected var right:Sprite; protected var gap:Number;// = 1500 protected var left:Sprite; protected var aimtimer:int;// = 15 protected var pt_topleft:Point; protected var topleft:Sprite; protected var pt_bottomright:Point; protected var topright:Sprite; protected var bottom:Sprite; protected var top:Sprite; protected var bottomleft:Sprite; public function Border(){ topleft = new Sprite(); top = new Sprite(); topright = new Sprite(); left = new Sprite(); right = new Sprite(); bottomleft = new Sprite(); bottom = new Sprite(); bottomright = new Sprite(); alphaBound = new Point(0.2, 0.5); super(); addChild(topleft); addChild(top); addChild(topright); addChild(left); addChild(right); addChild(bottomleft); addChild(bottom); addChild(bottomright); } public function update():void{ if (dir == 1){ if (timer < aimtimer){ timer = (timer + dir); } else { dir = (dir * -1); }; } else { if (timer > 0){ timer = (timer + dir); } else { dir = (dir * -1); }; }; alpha = ZoMathTools.linearTransform(new Point(0, aimtimer), alphaBound, timer); } public function init(topleft:Point, bottomright:Point):void{ pt_topleft = topleft; pt_bottomright = bottomright; theWidth = (bottomright.x - topleft.x); theHeight = (bottomright.y - topleft.y); drawZones(); } protected function drawZone(s:Sprite, top:Point, bottom:Point):Sprite{ s.graphics.clear(); s.graphics.beginFill(0xFFFFFF); s.graphics.drawRect(top.x, top.y, (bottom.x - top.x), (bottom.y - top.y)); s.graphics.endFill(); return (s); } protected function drawZones():void{ drawZone(top, new Point((pt_topleft.x - gap), (pt_topleft.y - gap)), new Point((pt_bottomright.x + gap), pt_topleft.y)); drawZone(left, new Point((pt_topleft.x - gap), pt_topleft.y), new Point(pt_topleft.x, pt_bottomright.y)); drawZone(right, new Point(pt_bottomright.x, pt_topleft.y), new Point((pt_bottomright.x + gap), pt_bottomright.y)); drawZone(bottom, new Point((pt_topleft.x - gap), pt_bottomright.y), new Point((pt_bottomright.x + gap), (pt_bottomright.y + gap))); } } }//package
Section 62
//Btn_logo (Btn_logo) package { import flash.events.*; import flash.geom.*; import flash.display.*; import api.*; public class Btn_logo extends Sprite { public static var img:Class = Btn_logo_img; public static var img2:Class = Btn_logo_img2; public function Btn_logo(parent:Sprite, initPos:Point, white:Boolean=false):void{ super(); name = "BTNLOGO"; if (white){ addChild(new img2()); } else { addChild(new img()); }; parent.addChild(this); x = initPos.x; y = initPos.y; buttonMode = true; addEventListener(MouseEvent.CLICK, tracking); addEventListener(MouseEvent.MOUSE_OVER, over); addEventListener(MouseEvent.MOUSE_OUT, out); } protected function over(e:MouseEvent):void{ Global.mouse.activate(false); } protected function out(e:MouseEvent):void{ Global.mouse.activate(true); } protected function tracking(e:MouseEvent):void{ MochiBot.trackUrl(this, "5ee274a2", "http://www.ninjakiwi.com/"); } } }//package
Section 63
//Btn_logo_img (Btn_logo_img) package { import mx.core.*; public class Btn_logo_img extends BitmapAsset { } }//package
Section 64
//Btn_logo_img2 (Btn_logo_img2) package { import mx.core.*; public class Btn_logo_img2 extends BitmapAsset { } }//package
Section 65
//Collectable (Collectable) package { import flash.geom.*; import flash.display.*; import zomg.sound.*; import zomg.*; import zomg.tools.*; public class Collectable extends ZoSprite { protected var goToExit:Boolean;// = false protected var inExit:Boolean;// = false protected var initPos:Point; public var params:Object; protected var speed:Number;// = 8.5 protected var l:LevelManager; protected var p:Player; public var value:Number;// = 1 public var type:uint; public static var CASH:uint = 0; public static var KEY:uint = 1; public static var sheet_cash:Class = Collectable_sheet_cash; public static var sheet_key:Class = Collectable_sheet_key; public function Collectable(type:uint, initPos:Point, plyr:Player=null, lvl:LevelManager=null){ var bmp:Bitmap; var thesize:Point; name = ("COLLECTABLE " + initPos); if (plyr){ p = plyr; }; if (lvl){ l = lvl; }; this.type = type; this.initPos = initPos; var simplesheet:Boolean; switch (type){ case CASH: bmp = new sheet_cash(); thesize = new Point(13, 13); simplesheet = false; break; case KEY: bmp = new sheet_key(); thesize = new Point(25, 13); simplesheet = false; break; }; super(bmp, thesize, initPos, new Point(), 0, simplesheet); switch (type){ case CASH: symbol.addAnim("idle", new Point(13, 13), 8, new Point(), 10); symbol.addAnim("taken", new Point(13, 13), 7, new Point(1, 0), 4); break; default: symbol.addAnim("idle", new Point(25, 13), 18, new Point(), 5); symbol.addAnim("onMove", new Point(25, 13), 18, new Point(1, 0), 5); break; }; reset(); } protected function collect():void{ active = false; switch (type){ case KEY: ZoSoundEngine.getSound("collect_key").playSound(); goToExit = true; symbol.playAnim("onMove"); break; case CASH: ZoSoundEngine.getSound("collect").playSound(); symbol.playAnim("taken", 1); Global.gui.bumpCash(); break; }; Global.gui.updateGUI(); } public function reset():void{ symbol.playAnim("idle"); position = initPos; rotation = 0; active = true; visible = true; if (type == KEY){ goToExit = false; inExit = false; }; if (Global.gui){ Global.gui.updateGUI(); }; } public function update():void{ isInFrustrum(); if (((active) && (infrustrum))){ if (p){ if (p.isAlive()){ if (ZoMathTools.distance(new Point(x, y), new Point(p.x, p.y)) < (p.collectableZone + 5)){ collect(); }; }; }; } else { switch (type){ case KEY: if (((goToExit) && (!(inExit)))){ if (ZoMathTools.distance(position, l.endpos) < 10){ goToExit = false; visible = false; inExit = true; Global.gui.updateGUI(); } else { position = ZoMathTools.destinationPoint(position, ZoMathTools.getDirectionVec(position, l.endpos), speed); }; }; break; case CASH: if (symbol.currentAnim == "taken"){ if (symbol.hasFinishedPlaying("taken")){ visible = false; Global.gui.updateGUI(); }; }; break; }; }; if (infrustrum){ symbol.update(); }; } public function isDone():Boolean{ switch (type){ case KEY: if (((!(active)) && (!(visible)))){ return (true); }; break; case CASH: if (!active){ return (true); }; break; }; return (false); } public function isTaken():Boolean{ if (!active){ return (true); }; return (false); } public static function getIcon(what:String="cash"):Bitmap{ switch (what){ case "cash": return (ZoColor.getImageFromSheet(new sheet_cash(), new Point(13, 13))); case "key": return (ZoColor.getImageFromSheet(new sheet_key(), new Point(25, 13))); }; return (null); } } }//package
Section 66
//Collectable_sheet_cash (Collectable_sheet_cash) package { import mx.core.*; public class Collectable_sheet_cash extends BitmapAsset { } }//package
Section 67
//Collectable_sheet_key (Collectable_sheet_key) package { import mx.core.*; public class Collectable_sheet_key extends BitmapAsset { } }//package
Section 68
//Collisionable (Collisionable) package { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import zomg.sound.*; import zomg.*; import zomg.tools.*; import zomg.gui.*; public class Collisionable extends ZoSprite { protected var sunGrowSpeed:Number;// = 0 private var editor_end:Class; public var mouseActive:Boolean;// = false private var sheet_p45:Class; private var editor_start:Class; private var sheet_sun_off:Class; private var sheet_p320:Class; public var guitf_collec:TextField; protected var initPos:Point; protected var light:ZoSprite; protected var lvl_lock:Sprite; protected var ring:ZoSprite; protected var lvl_score:Sprite; private var sheet_p170:Class; protected var halo:Sprite; private var sheet_exp:Class; public var type:uint;// = 0 protected var sunGrowSpeedMax:Number;// = 1.8 protected var speed:Number;// = 0 private var sheet_p60:Class; private var editor_bottom:Class; protected var alphaDir:Number;// = -0.03 private var sheet_gate_halo:Class; public var planetRadius:Number;// = 0 protected var star:ZoSprite; protected var sunOffSize:Point; private var sheet_p70:Class; protected var sunSize:Number; protected var lvl_completed:Sprite; protected var _need:int;// = 0 private var sheet_cadenas:Class; private var sheet_start:Class; private var editor_top:Class; public var params:XMLList; private var sheet_p80:Class; private var sheet_logo:Class; protected var lvl_desc:Sprite; protected var _sunLight:Number;// = 0 protected var guitf_lvlNum:TextField; protected var radius:Number;// = 0 private var sheet_p120:Class; protected var sunGrow:Number;// = 0 private var sheet_p365:Class; protected var _gate:int;// = -1 private var sheet_gate:Class; private var sheet_p10:Class; protected var lvl_lvlName:TextField; protected var owner:Object; protected var sunGrowStepRef:Number;// = 0.15 protected var sunUnGrow:Number;// = 0 protected var disappear:Boolean;// = false protected var lvl_score_tf:TextField; private var sheet_p250:Class; private var sheet_sun_200_on:Class; private var sheet_debug_red:Class; protected var sunLightMin:Number;// = 0 private var sheet_sun_45_on:Class; private var sheet_p20:Class; protected var angle:Number;// = 0 public var halfSize:Point; private var sheet_exp_end:Class; protected var explode:Sprite; private var sheet_p145:Class; protected var alphaIntv:Point; protected var lvl_press:TextField; private var sheet_sun_80_on:Class; private var sheet_p30:Class; protected var debugDot:Sprite; public var lockLvl:int;// = 2 protected var sunOnSize:Point; private var sheet_exit:Class; public static var p320:uint = 11; public static var p145:uint = 8; public static var gatetype:uint = 105; public static var p70:uint = 5; public static var sun:uint = 15; public static var p30:uint = 2; public static var p10:uint = 0; public static var top:uint = 103; public static var start:uint = 100; public static var p250:uint = 10; public static var p170:uint = 9; public static var p365:uint = 12; public static var logotype:uint = 106; public static var p80:uint = 6; public static var p60:uint = 4; public static var bottom:uint = 104; public static var cp:uint = 102; public static var p20:uint = 1; public static var p45:uint = 3; public static var end:uint = 101; public static var p120:uint = 7; public function Collisionable(type:uint, initPos:Point, xm:XMLList=null, inEditor:Boolean=false, owner:Object=null){ var img:Bitmap; var _local13:int; var sheet:Bitmap; sheet_p10 = Collisionable_sheet_p10; sheet_p20 = Collisionable_sheet_p20; sheet_p30 = Collisionable_sheet_p30; sheet_p45 = Collisionable_sheet_p45; sheet_p60 = Collisionable_sheet_p60; sheet_p70 = Collisionable_sheet_p70; sheet_p80 = Collisionable_sheet_p80; sheet_p120 = Collisionable_sheet_p120; sheet_p145 = Collisionable_sheet_p145; sheet_p170 = Collisionable_sheet_p170; sheet_p250 = Collisionable_sheet_p250; sheet_p320 = Collisionable_sheet_p320; sheet_p365 = Collisionable_sheet_p365; sheet_exp = Collisionable_sheet_exp; sheet_exp_end = Collisionable_sheet_exp_end; sheet_start = Collisionable_sheet_start; sheet_exit = Collisionable_sheet_exit; sheet_debug_red = Collisionable_sheet_debug_red; sheet_gate = Collisionable_sheet_gate; sheet_gate_halo = Collisionable_sheet_gate_halo; sheet_cadenas = Collisionable_sheet_cadenas; sheet_logo = Collisionable_sheet_logo; sheet_sun_off = Collisionable_sheet_sun_off; sheet_sun_45_on = Collisionable_sheet_sun_45_on; sheet_sun_80_on = Collisionable_sheet_sun_80_on; sheet_sun_200_on = Collisionable_sheet_sun_200_on; editor_start = Collisionable_editor_start; editor_end = Collisionable_editor_end; editor_top = Collisionable_editor_top; editor_bottom = Collisionable_editor_bottom; halfSize = new Point(); alphaIntv = new Point(0.5, 0.9); if (!inEditor){ name = ("[COLL] " + Global.lvl.allAsset.length); }; var thesize:Point = new Point(); var imgsize:Point = new Point(); var animNum:Point = new Point(); var color:int; this.type = type; this.initPos = initPos; params = xm; if (owner){ this.owner = owner; }; switch (type){ case p10: img = new sheet_p10(); thesize = new Point(10, 10); imgsize = new Point(15, 15); name = (name + " p10"); break; case p20: img = new sheet_p20(); thesize = new Point(20, 20); imgsize = new Point(22, 22); name = (name + " p20"); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 7))); break; case p30: img = new sheet_p30(); thesize = new Point(30, 30); imgsize = new Point(36, 36); name = (name + " p30"); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 7))); break; case p45: img = new sheet_p45(); thesize = new Point(45, 45); imgsize = new Point(53, 53); name = (name + " p45"); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 7))); break; case p60: img = new sheet_p60(); thesize = new Point(60, 60); imgsize = new Point(72, 72); name = (name + " p60"); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 3))); break; case p70: img = new sheet_p70(); thesize = new Point(70, 70); imgsize = new Point(108, 108); name = (name + " p70"); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 3))); break; case p80: img = new sheet_p80(); thesize = new Point(80, 80); imgsize = new Point(108, 108); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 3))); break; case p120: img = new sheet_p120(); thesize = new Point(120, 120); imgsize = new Point(146, 146); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 3))); break; case p145: img = new sheet_p145(); thesize = new Point(145, 145); imgsize = new Point(177, 177); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 3))); break; case p170: img = new sheet_p170(); thesize = new Point(170, 170); imgsize = new Point(208, 208); animNum = new Point(color, int(ZoMathTools.randomBetween(0, 3))); break; case p250: img = new sheet_p250(); thesize = new Point(250, 250); imgsize = new Point(290, 290); break; case p320: img = new sheet_p320(); thesize = new Point(320, 320); imgsize = new Point(360, 360); break; case p365: img = new sheet_p365(); thesize = new Point(365, 365); imgsize = new Point(405, 405); break; case start: img = new sheet_start(); thesize = new Point(107, 113); break; case end: img = new sheet_exit(); thesize = new Point(107, 113); break; case top: img = new editor_top(); thesize = new Point(16, 16); break; case bottom: img = new editor_bottom(); thesize = new Point(16, 16); break; case sun: if (params.@size > 0){ sunSize = Number(params.@size); img = new sheet_sun_off(); thesize = (sunOffSize = new Point(325, 325)); if (sunSize == 200){ sheet = new sheet_sun_200_on(); sunOnSize = new Point(325, 325); } else { if (sunSize == 80){ sheet = new sheet_sun_80_on(); sunOnSize = new Point(170, 170); } else { if (sunSize == 45){ sheet = new sheet_sun_45_on(); sunOnSize = new Point(117, 117); }; }; }; light = new ZoSprite(sheet, sunOnSize, new Point()); light.symbol.addAnim("growing", sunOnSize, 1, new Point()); light.symbol.addAnim("ring", sunOnSize, 6, new Point(0, 1), 4); light.symbol.playAnim("growing"); if (sunSize == 45){ sunGrow = sunGrowStepRef; } else { if (sunSize == 80){ sunGrow = (sunGrowStepRef * 0.5); } else { if (sunSize == 200){ sunGrow = (sunGrowStepRef * 0.3); } else { Global.console.addLine("ERROR > sun size not valid", "Colli"); }; }; }; } else { trace(("Colli > sun error size " + name)); }; break; case cp: thesize = new Point(109, 110); name = (name + " checkpoint"); break; case gatetype: halo = new Sprite(); _local13 = int(params.@zone); img = ZoColor.getImageFromSheet(new sheet_gate_halo(), new Point(106, 111), new Point(0, _local13)); img.x = (-(img.width) / 2); img.y = (-(img.height) / 2); halo.addChild(img); addChild(halo); img = new sheet_gate(); thesize = new Point(51, 59); name = (name + " [GATE]"); break; case logotype: img = new sheet_logo(); imgsize = new Point(318, 336); break; }; halfSize = new Point((thesize.x / 2), (thesize.y / 2)); if (type == gatetype){ planetRadius = (thesize.x / 1.4); } else { planetRadius = (thesize.x / 2); }; if (imgsize.length == 0){ imgsize = thesize; }; super(img, imgsize, initPos); if (type == gatetype){ symbol.addAnim("idle", imgsize, 1, new Point(0, _local13)); symbol.addAnim("over", imgsize, 1, new Point(0, 6)); symbol.addAnim("lockover", imgsize, 1, new Point(0, 7)); symbol.addAnim("lock", imgsize, 1, new Point(0, 8)); } else { if (type == start){ symbol.addAnim("idle", imgsize, 1, new Point(0, 17)); symbol.addAnim("open", imgsize, 17, new Point(), 4); symbol.addAnim("close", imgsize, 17, new Point(), 4, false, true); } else { if (type == end){ symbol.addAnim("idle", imgsize, 1, new Point()); symbol.addAnim("open", imgsize, 10, new Point(0, 1), 4); } else { symbol.addAnim("idle", imgsize, 1, animNum); }; }; }; symbol.playAnim("idle"); if (type == start){ active = false; }; if (xm){ if ((((type == gatetype)) && (!(inEditor)))){ need = int(params.@need); gate = int(params.@gate); name = (name + (" gate #" + gate)); lvl_completed = new Sprite(); lvl_completed.addChild(ZoGUI.getStdTextField(new Point(130, 20), "COMPLETED", {font:"grotesque", embed:true, size:15, letterSpace:2, color:0, bold:true})); lvl_completed.x = 40; lvl_completed.y = 22; addChild(lvl_completed); lvl_desc = new Sprite(); lvl_desc.addChild(ZoGUI.getStdTextField(new Point(350, 25), String(Global.lvl.getLevelName(gate)).toUpperCase(), {font:"futura", embed:true, size:18, letterSpace:1, color:0xFFFFFF})); lvl_desc.addChild(ZoGUI.getStdTextField(new Point(40, 25), "LEVEL", {font:"grotesque", embed:true, size:18, letterSpace:2, color:0xFFFFFF}, new Point(0, 18))); lvl_lvlName = ZoGUI.getStdTextField(new Point(300, 25), String(params.@gate), {font:"futura", embed:true, letterSpace:2, size:18, color:0xFFFFFF}, new Point(40, 18)); lvl_desc.addChild(lvl_lvlName); lvl_desc.x = lvl_completed.x; lvl_desc.y = -20; addChild(lvl_desc); lvl_lock = new Sprite(); img = new sheet_cadenas(); img.y = 5; lvl_lock.addChild(img); lvl_lock.addChild(ZoGUI.getStdTextField(new Point(30, 20), (need + "x"), {font:"futura", embed:true, size:18, letterSpace:0, align:"center", color:0}, new Point(13, 0))); img = Collectable.getIcon("cash"); img.x = (13 + 32); img.y = 5; lvl_lock.addChild(img); lvl_lock.x = lvl_completed.x; lvl_lock.y = lvl_completed.y; addChild(lvl_lock); lvl_score = new Sprite(); lvl_score_tf = ZoGUI.getStdTextField(new Point(54, 20), "0 / 20", {font:"futura", embed:true, size:15, color:0, align:"left"}); lvl_score.x = lvl_lock.x; lvl_score.y = lvl_lock.y; lvl_score.addChild(lvl_score_tf); img = Collectable.getIcon("cash"); img.x = lvl_score_tf.width; img.y = 3; lvl_score.addChild(img); addChild(lvl_score); lvl_press = ZoGUI.getStdTextField(new Point(200, 100), "PRESS ENTER\nTO BUY", {font:"grotesque", embed:true, size:18, letterSpace:2, color:0xDDDDDD}); lvl_press.x = lvl_completed.x; lvl_press.y = (lvl_completed.y + 22); addChild(lvl_press); setLocked(); }; radius = Number(params.@radius); speed = Number(params.@speed); if (params.@size > 0){ planetRadius = (Number(params.@size) / 2); sunLight = int(params.@sun); sunLightMin = int(params.@sun); sunUnGrow = (-(sunGrow) * 0.5); addChild(light); symbol.scaleX = (symbol.scaleY = (sunSize / 200)); }; if (params.@explode > 0){ explode = new Sprite(); img = new sheet_exp(); img.x = (-(img.width) / 2); img.y = (-(img.height) / 2); explode.addChild(img); explode.scaleX = (explode.scaleY = (thesize.x / 250)); symbol.addChild(explode); star = new ZoSprite(new sheet_exp_end(), new Point(30, 30), new Point()); star.symbol.addAnim("idle", new Point(30, 30), 1, new Point()); star.symbol.addAnim("go", new Point(30, 30), 4, new Point(), 4); addChild(star); star.visible = false; }; }; debugDot = new Sprite(); debugDot.addChild(new sheet_debug_red()); debugDot.addChild(ZoGUI.getStdTextField(new Point(100, 30), name, {size:8})); addChild(debugDot); toggleDebug(false); } public function isMouseOver():Boolean{ var pos:Point; if (mouseActive){ pos = localToGlobal(new Point()); if (ZoMathTools.isBetween(Global.mouse.position.x, (pos.x - getRadius()), (pos.x + getRadius()))){ if (ZoMathTools.isBetween(Global.mouse.position.y, (pos.y - getRadius()), (pos.y + getRadius()))){ return (true); }; }; }; return (false); } public function setLocked(unlock:Boolean=true, done:Boolean=false, highscore:int=0, max:int=0, over:Boolean=false):void{ lvl_desc.visible = true; if (need <= 0){ unlock = true; }; if (unlock){ lvl_press.text = "PRESS ENTER\nTO PLAY"; } else { lvl_press.text = "PRESS ENTER\nTO BUY"; }; symbol.playAnim("idle"); if (over){ symbol.playAnim("over"); lvl_press.visible = true; } else { lvl_press.visible = false; }; halo.visible = true; if (!unlock){ lvl_lock.visible = true; lvl_score.visible = (lvl_completed.visible = false); if (over){ symbol.playAnim("lockover"); } else { symbol.playAnim("lock"); }; } else { if (highscore >= max){ lvl_completed.visible = true; lvl_lock.visible = (lvl_score.visible = false); } else { if (highscore < max){ lvl_score.visible = true; lvl_lock.visible = (lvl_completed.visible = false); }; }; }; if (highscore < 0){ highscore = 0; }; lvl_score_tf.text = ((highscore + " / ") + max); } public function isGate():Boolean{ if (gate >= 0){ return (true); }; return (false); } public function isMoving():Boolean{ if (radius > 0){ return (true); }; return (false); } public function isCP():Boolean{ if (type == cp){ return (true); }; return (false); } public function colide(globalPosition:Point):Boolean{ if (ZoMathTools.distance(globalPosition, position) < halfSize.x){ return (true); }; return (false); } public function get sunLight():Number{ return (_sunLight); } public function set need(v:int):void{ _need = v; } public function isSunOn():Boolean{ if (isSun()){ if (sunGrow >= 100){ return (true); }; }; return (false); } public function set sunLight(v:Number):void{ _sunLight = v; light.scaleX = (light.scaleY = (v / 100)); if (sunLight > 0){ light.visible = true; } else { light.visible = false; }; } public function isPlanet():Boolean{ if ((((((type == start)) || ((type == end)))) || ((type == cp)))){ return (false); }; return (true); } public function lightSun():void{ if (isSun()){ light.visible = true; sunLight = 100; }; } public function isExit():Boolean{ if (type == end){ return (true); }; return (false); } protected function open(e:MouseEvent):void{ Global.lvl.gateOpen(); } public function reset():void{ position = initPos; angle = (rotation = 0); active = (visible = true); if (type == start){ active = false; } else { if (type == sun){ sunLight = int(params.@sun); light.symbol.playAnim("growing"); sunGrowSpeed = 0; } else { if (explode){ disappear = false; symbol.scaleX = (symbol.scaleY = 1); star.visible = false; }; }; }; isInFrustrum(); } public function toggleDebug(flag:Boolean=false):void{ debugDot.visible = flag; } public function hasToDestroy():void{ if (params.@explode){ if (int(params.@explode) == 1){ ZoSoundEngine.getSound("planet_dis").playSound(); disappear = true; }; }; } public function getRadius():Number{ if (type == sun){ if (sunLight >= 100){ return ((planetRadius + (planetRadius * 0.3))); }; }; return (planetRadius); } public function avatarTouch():Boolean{ var mysize:Number = getRadius(); var ar:Array = Global.p.getColisionPoints(); if (Global.p.comparePlanetLanded(this)){ return (true); }; var i:int; while (i < ar.length) { if (ZoMathTools.distance(position, Global.p.position.add(ar[i])) <= mysize){ if (((!(Global.p.isInvincible())) && (!(Global.p.comparePlanetLanded(this, true))))){ return (true); }; }; i++; }; return (false); } public function set gate(v:int):void{ _gate = v; } public function get need():int{ return (_need); } public function update():void{ isInFrustrum(); var touch:Boolean; if (active){ if (radius > 0){ angle = (angle + (speed / 100)); position = initPos.add(new Point((Math.cos(angle) * radius), (Math.sin(angle) * radius))); }; if (infrustrum){ touch = avatarTouch(); if (type == sun){ if (sunLight < 100){ if (touch){ sunGrowSpeed = (sunGrowSpeed + sunGrow); } else { sunGrowSpeed = (sunGrowSpeed + sunUnGrow); }; sunGrowSpeed = ZoMathTools.threshold(-(sunGrowSpeedMax), sunGrowSpeedMax, sunGrowSpeed); if ((sunLight + sunGrowSpeed) > sunLightMin){ sunLight = (sunLight + sunGrowSpeed); }; } else { if (sunLight >= 100){ if (light.symbol.currentAnim == "growing"){ ZoSoundEngine.getSound("sun_explode").playSound(); light.symbol.playAnim("ring"); }; if (touch){ Global.p.killPlayer(0); }; light.symbol.update(); }; }; }; if (Global.p.isFlying()){ if (touch){ if (type == cp){ Global.p.setMotion(this); active = false; } else { if (type == end){ if (((Global.lvl.allKeyCollected) && (Global.lvl.hasExit()))){ Global.p.setMotion(this, true); }; } else { Global.p.stop(this); }; }; }; }; if (isGate()){ if (Global.p.comparePlanetLanded(this, true)){ if (((((lvl_press.alpha + alphaDir) < alphaIntv.x)) || (((lvl_press.alpha + alphaDir) > alphaIntv.y)))){ alphaDir = (alphaDir * -1); }; lvl_press.alpha = (lvl_press.alpha + alphaDir); } else { lvl_press.alpha = 1; }; }; }; }; if (explode){ if (disappear){ if (symbol.scaleX <= 0){ if (!star.visible){ active = false; symbol.scaleX = (symbol.scaleY = 0); star.symbol.playAnim("go", 1); star.visible = true; } else { if (star.symbol.hasFinishedPlaying("go")){ disappear = (visible = false); } else { star.symbol.update(); }; }; } else { symbol.scaleX = (symbol.scaleX - 0.1); symbol.scaleY = (symbol.scaleY - 0.1); }; }; }; } public function get gate():int{ return (_gate); } public function isSun():Boolean{ if (light){ return (true); }; return (false); } public function getXML():XMLList{ params.@pos = ((owner.x + ",") + owner.y); return (params); } public function clickable(flag:Boolean):void{ if (isGate()){ mouseActive = flag; }; } public static function getStandardXML(type:uint, pos:Point):XMLList{ return (new XMLList((((((("<collision type=\"" + type) + "\" pos=\"") + pos.x) + ",") + pos.y) + "\" />"))); } } }//package
Section 69
//Collisionable_editor_bottom (Collisionable_editor_bottom) package { import mx.core.*; public class Collisionable_editor_bottom extends BitmapAsset { } }//package
Section 70
//Collisionable_editor_end (Collisionable_editor_end) package { import mx.core.*; public class Collisionable_editor_end extends BitmapAsset { } }//package
Section 71
//Collisionable_editor_start (Collisionable_editor_start) package { import mx.core.*; public class Collisionable_editor_start extends BitmapAsset { } }//package
Section 72
//Collisionable_editor_top (Collisionable_editor_top) package { import mx.core.*; public class Collisionable_editor_top extends BitmapAsset { } }//package
Section 73
//Collisionable_sheet_cadenas (Collisionable_sheet_cadenas) package { import mx.core.*; public class Collisionable_sheet_cadenas extends BitmapAsset { } }//package
Section 74
//Collisionable_sheet_debug_red (Collisionable_sheet_debug_red) package { import mx.core.*; public class Collisionable_sheet_debug_red extends BitmapAsset { } }//package
Section 75
//Collisionable_sheet_exit (Collisionable_sheet_exit) package { import mx.core.*; public class Collisionable_sheet_exit extends BitmapAsset { } }//package
Section 76
//Collisionable_sheet_exp (Collisionable_sheet_exp) package { import mx.core.*; public class Collisionable_sheet_exp extends BitmapAsset { } }//package
Section 77
//Collisionable_sheet_exp_end (Collisionable_sheet_exp_end) package { import mx.core.*; public class Collisionable_sheet_exp_end extends BitmapAsset { } }//package
Section 78
//Collisionable_sheet_gate (Collisionable_sheet_gate) package { import mx.core.*; public class Collisionable_sheet_gate extends BitmapAsset { } }//package
Section 79
//Collisionable_sheet_gate_halo (Collisionable_sheet_gate_halo) package { import mx.core.*; public class Collisionable_sheet_gate_halo extends BitmapAsset { } }//package
Section 80
//Collisionable_sheet_logo (Collisionable_sheet_logo) package { import mx.core.*; public class Collisionable_sheet_logo extends BitmapAsset { } }//package
Section 81
//Collisionable_sheet_p10 (Collisionable_sheet_p10) package { import mx.core.*; public class Collisionable_sheet_p10 extends BitmapAsset { } }//package
Section 82
//Collisionable_sheet_p120 (Collisionable_sheet_p120) package { import mx.core.*; public class Collisionable_sheet_p120 extends BitmapAsset { } }//package
Section 83
//Collisionable_sheet_p145 (Collisionable_sheet_p145) package { import mx.core.*; public class Collisionable_sheet_p145 extends BitmapAsset { } }//package
Section 84
//Collisionable_sheet_p170 (Collisionable_sheet_p170) package { import mx.core.*; public class Collisionable_sheet_p170 extends BitmapAsset { } }//package
Section 85
//Collisionable_sheet_p20 (Collisionable_sheet_p20) package { import mx.core.*; public class Collisionable_sheet_p20 extends BitmapAsset { } }//package
Section 86
//Collisionable_sheet_p250 (Collisionable_sheet_p250) package { import mx.core.*; public class Collisionable_sheet_p250 extends BitmapAsset { } }//package
Section 87
//Collisionable_sheet_p30 (Collisionable_sheet_p30) package { import mx.core.*; public class Collisionable_sheet_p30 extends BitmapAsset { } }//package
Section 88
//Collisionable_sheet_p320 (Collisionable_sheet_p320) package { import mx.core.*; public class Collisionable_sheet_p320 extends BitmapAsset { } }//package
Section 89
//Collisionable_sheet_p365 (Collisionable_sheet_p365) package { import mx.core.*; public class Collisionable_sheet_p365 extends BitmapAsset { } }//package
Section 90
//Collisionable_sheet_p45 (Collisionable_sheet_p45) package { import mx.core.*; public class Collisionable_sheet_p45 extends BitmapAsset { } }//package
Section 91
//Collisionable_sheet_p60 (Collisionable_sheet_p60) package { import mx.core.*; public class Collisionable_sheet_p60 extends BitmapAsset { } }//package
Section 92
//Collisionable_sheet_p70 (Collisionable_sheet_p70) package { import mx.core.*; public class Collisionable_sheet_p70 extends BitmapAsset { } }//package
Section 93
//Collisionable_sheet_p80 (Collisionable_sheet_p80) package { import mx.core.*; public class Collisionable_sheet_p80 extends BitmapAsset { } }//package
Section 94
//Collisionable_sheet_start (Collisionable_sheet_start) package { import mx.core.*; public class Collisionable_sheet_start extends BitmapAsset { } }//package
Section 95
//Collisionable_sheet_sun_200_on (Collisionable_sheet_sun_200_on) package { import mx.core.*; public class Collisionable_sheet_sun_200_on extends BitmapAsset { } }//package
Section 96
//Collisionable_sheet_sun_45_on (Collisionable_sheet_sun_45_on) package { import mx.core.*; public class Collisionable_sheet_sun_45_on extends BitmapAsset { } }//package
Section 97
//Collisionable_sheet_sun_80_on (Collisionable_sheet_sun_80_on) package { import mx.core.*; public class Collisionable_sheet_sun_80_on extends BitmapAsset { } }//package
Section 98
//Collisionable_sheet_sun_off (Collisionable_sheet_sun_off) package { import mx.core.*; public class Collisionable_sheet_sun_off extends BitmapAsset { } }//package
Section 99
//EndScreen (EndScreen) package { import flash.events.*; import flash.display.*; public class EndScreen extends Sprite { protected var aimTimer:int;// = 60 protected var timer:int;// = 0 public var screen:Class; protected var screen1:Sprite; public var showed:Boolean;// = false public function EndScreen(){ screen = EndScreen_screen; screen1 = new Sprite(); super(); addChild(new screen()); visible = false; } protected function update(e:Event=null):void{ if (timer < aimTimer){ timer++; } else { addEventListener(MouseEvent.MOUSE_UP, kill); removeEventListener(Event.ENTER_FRAME, update); }; } public function init():void{ trace(("END > end screen ! " + showed)); if (!showed){ showed = true; addEventListener(Event.ENTER_FRAME, update); visible = true; }; } public function kill(e:MouseEvent=null):void{ visible = false; removeEventListener(MouseEvent.MOUSE_UP, kill); } } }//package
Section 100
//EndScreen_screen (EndScreen_screen) package { import mx.core.*; public class EndScreen_screen extends BitmapAsset { } }//package
Section 101
//Enemy (Enemy) package { import flash.geom.*; import flash.display.*; import zomg.sound.*; import zomg.*; import zomg.tools.*; public class Enemy extends ZoSprite { protected var params:XMLList; private var editor_turret:Class; private var editor_tracker1:Class; protected var dir:Point; private var editor_escan:Class; protected var setContinueFlying:Number;// = 0 protected var chasing:Boolean;// = false protected var owner:Object; protected var timerAim:Number; private var editor_bar:Class; protected var timer:Number;// = 0 protected var lifespan:Number;// = 0 protected var speed:Number;// = 0 public var type:int;// = 0 protected var grid:Sprite; private var sheet_turret:Class; protected var gridMask:Sprite; protected var pos:Point; private var sheet_tracker:Class; protected var end:Point; private var sheet_scan:Class; private var sheet_bullet:Class; protected var symbols:Array; protected var distance:Number;// = 0 protected var myZone:int;// = 0 protected var endPos:Sprite; protected var symb:Sprite; public static var BULLET:int = 4; public static var BAR:int = 1; public static var TURRET:int = 3; protected static var frequency:Number = 60; public static var SCAN:int = 0; public static var TRACKER:int = 2; public function Enemy(type:uint, initPos:Point, values:XMLList=null, owner:Object=null, inEditor:Boolean=false){ var s:String; var _local11:Point; sheet_tracker = Enemy_sheet_tracker; sheet_scan = Enemy_sheet_scan; sheet_turret = Enemy_sheet_turret; sheet_bullet = Enemy_sheet_bullet; editor_bar = Enemy_editor_bar; editor_tracker1 = Enemy_editor_tracker1; editor_escan = Enemy_editor_escan; editor_turret = Enemy_editor_turret; dir = new Point(); endPos = new Sprite(); timerAim = frequency; name = "ENEMY"; if (owner){ this.owner = owner; }; this.type = type; symbols = new Array(); var bmp:Bitmap; var size:Point = new Point(); var simpleSheet:Boolean; var op:String = ""; if (!inEditor){ setZone(); }; if (values){ pos = ZoTools.transformToPoint(values.@pos); op = values.@op; params = values; }; if (op.length > 0){ s = ""; s = (s + (((("<enemy type=\"" + values.@type) + "\" pos=\"") + values.@pos) + "\"")); switch (type){ case TRACKER: s = (s + ((" speed=\"" + 2) + "\" ")); s = (s + ((" zone=\"" + 50) + "\" ")); s = (s + ((" zoneactive=\"" + 100) + "\" ")); s = (s + ((" fixe=\"" + 1) + "\" ")); break; case SCAN: s = (s + ((" size=\"" + 30) + "\" ")); s = (s + ((" speed=\"" + 1) + "\" ")); s = (s + ((" dir=\"" + 1) + "\" ")); break; case BAR: s = (s + ((((" end=\"" + pos.x) + ",") + pos.y) + "\" ")); s = (s + ((" size=\"" + 30) + "\" ")); s = (s + ((" speed=\"" + 1) + "\" ")); s = (s + ((" nb=\"" + 1) + "\" ")); break; case TURRET: s = (s + ((" firefreq=\"" + 1) + "\" ")); s = (s + ((" rotate=\"" + 1) + "\" ")); s = (s + ((" bulletSpeed=\"" + 2) + "\" ")); s = (s + ((" bulletLife =\"" + 2) + "\" ")); break; }; s = (s + "/>"); params = new XMLList(s); }; if (!inEditor){ switch (type){ case SCAN: createScan(); size.x = Number(params.@size); simpleSheet = true; setContinueFlying = 0.3; break; case BAR: createBAR(); size.x = Number(params.@size); simpleSheet = true; break; case TRACKER: bmp = new sheet_tracker(); size = new Point(20, 20); break; case TURRET: bmp = new sheet_turret(); size = new Point(49, 43); simpleSheet = true; break; case BULLET: name = (name + " BULLET"); bmp = new sheet_bullet(); size = new Point(25, 25); simpleSheet = true; setContinueFlying = 0.4; visible = (active = false); break; }; } else { switch (type){ case TRACKER: bmp = new editor_tracker1(); size = new Point(20, 20); break; case SCAN: bmp = new editor_escan(); size = new Point(20, 20); break; case BAR: bmp = new editor_bar(); size = new Point(20, 20); break; case TURRET: bmp = new editor_turret(); size = new Point(20, 20); break; }; simpleSheet = true; }; super(bmp, size, initPos, new Point(), 0, simpleSheet); if (type == BULLET){ active = false; }; if (!inEditor){ switch (type){ case TRACKER: symbol.addAnim("idle", size, 12, new Point(), 4); symbol.addAnim("active", size, 12, new Point((myZone + 1), 0), 4); symbol.playAnim("idle"); break; case TURRET: symbol.addAnim("prepare", size, 3, new Point(), 4); symbol.addAnim("shoot", size, 5, new Point(1, 0), 4); symbol.playAnim("prepare", 1); break; case BULLET: symbol.addAnim("0", new Point(25, 25), 1, new Point(0, 0)); symbol.addAnim("1", new Point(25, 25), 1, new Point(0, 1)); symbol.addAnim("2", new Point(25, 25), 1, new Point(0, 2)); symbol.addAnim("3", new Point(25, 25), 1, new Point(0, 3)); symbol.addAnim("4", new Point(25, 25), 1, new Point(0, 4)); symbol.addAnim("5", new Point(25, 25), 1, new Point(0, 5)); }; } else { switch (type){ case BAR: endPos.graphics.lineStyle(3, 0xFF); endPos.graphics.moveTo(-5, 0); endPos.graphics.lineTo(5, 0); endPos.graphics.moveTo(0, -5); endPos.graphics.lineTo(0, 5); addChild(endPos); _local11 = ZoTools.transformToPoint(params.@end); endPos.x = (_local11.x - owner.x); endPos.y = (_local11.y - owner.y); break; }; }; } protected function turretShot(initPos:Point, dir:Point, speed:Number=1, lifespan:Number=1):void{ Global.lvl.bManager.addElement(initPos, new XMLList((((((((("<params dir=\"" + dir.x) + ",") + dir.y) + "\" speed=\"") + speed) + "\" lifespan=\"") + lifespan) + "\"/>"))); symbol.playAnim("shoot", 1); ZoSoundEngine.getSound("turret_shoot").playSound(); } protected function createScan():void{ var s:Sprite = new Sprite(); s.addChild(ZoColor.getImageFromSheet(new sheet_scan(), new Point(34, 300), new Point(0, myZone))); if (params.@dir > 0){ s.scaleX = 1; } else { s.scaleX = -1; }; s.scaleY = (Number(params.@size) / 300); symb = s; symb.rotation = -90; addChild(symb); } public function setBulletParams(initPos:Point, par:XMLList):void{ if (type == BULLET){ position = initPos; params = par; speed = Number(params.@speed); dir = ZoTools.transformToPoint(params.@dir); lifespan = Number(params.@lifespan); if (lifespan > 5){ lifespan = 5; }; active = true; timer = 0; setZone(); symbol.playAnim(("" + myZone)); }; } public function setZone():void{ myZone = Global.lvl.currentZone; } public function colide(obj:Object):Boolean{ var p:Player = (obj as Player); if (!p.isInvincible()){ if (type == SCAN){ if (ZoMathTools.distance(position, p.position) < size.x){ if (inFront(p, 5)){ return (true); }; }; } else { if (type == BULLET){ if (ZoMathTools.distance(position, p.position) < (6 + 2)){ return (true); }; } else { if (type == TURRET){ if (ZoMathTools.distance(position, p.position) < (size.x / 2)){ return (true); }; } else { if (ZoMathTools.distance(position, p.position) < (size.x + 2)){ return (true); }; }; }; }; }; return (false); } public function isBullet():Boolean{ if (type == BULLET){ return (true); }; return (false); } public function reset():void{ position = pos; rotation = 0; active = (visible = true); switch (type){ case TRACKER: chasing = false; break; case BAR: rotation = ZoMathTools.dirRotation(pos, end); break; case BULLET: clear(); break; }; } public function clear():void{ if (type == BULLET){ } else { owner.removeChild(this); Global.lvl.allEn = ZoTools.removeArrayElement(Global.lvl.allEn, this); active = (visible = false); }; } public function update():void{ var clean:Boolean; var pos:Point; var p:Player; var oldState:Boolean; var ar:Array; var posRef:Point; var zoneDist:Number; var i:uint; isInFrustrum(); switch (type){ case BULLET: if (active){ clean = false; if (timer < (lifespan * 60)){ x = (x + (dir.x * speed)); y = (y + (dir.y * speed)); timer++; } else { clean = true; }; if (clean){ Global.lvl.bManager.clean(this); }; }; break; case TURRET: if (timer < (Number(params.@firefreq) * 60)){ if (((!((symbol.currentAnim == "prepare"))) && (symbol.hasFinishedPlaying("shoot")))){ symbol.playAnim("prepare", 1); }; timer++; } else { timer = 0; pos = ZoMathTools.destinationPoint(position, direction, (size.x / 3)); turretShot(pos, direction, Number(params.@bulletSpeed), Number(params.@bulletLife)); }; rotation = (rotation + Number(params.@rotate)); break; case SCAN: rotation = (rotation + (params.@speed * params.@dir)); break; case TRACKER: if (active){ p = Global.p; oldState = chasing; if (params.@zone <= 0){ chasing = true; } else { posRef = position; if (params.@fixe){ posRef = ZoTools.transformToPoint(params.@pos); }; zoneDist = params.@zone; if (((chasing) && ((params.@zoneactive > 0)))){ zoneDist = params.@zoneactive; }; if (ZoMathTools.distance(posRef, p.position) > zoneDist){ chasing = false; } else { chasing = true; }; }; if (p.isInvincible()){ chasing = false; }; if (chasing){ if (symbol.currentAnim == "idle"){ symbol.playAnim("active"); }; } else { if (symbol.currentAnim == "active"){ symbol.playAnim("idle"); }; }; if (chasing){ direction = getTowardObjDir(p); } else { if (timer < timerAim){ timer++; if (ZoMathTools.distance(position, posRef) > params.@zone){ direction = getTowardVecDir(ZoTools.transformToPoint(params.@pos)); timer = 0; }; } else { timer = 0; direction = new Point(ZoMathTools.randomBetween(-1, 1), ZoMathTools.randomBetween(-1, 1)); }; }; position = new Point((x + (direction.x * params.@speed)), (y + (direction.y * params.@speed))); ar = Global.lvl.getPlanetInFrustrum(); i = 0; while (i < ar.length) { if (ar[i].isSunOn()){ if (ZoMathTools.distance(ar[i].position, position) < ar[i].getRadius()){ visible = (active = false); }; }; i++; }; }; break; }; if (infrustrum){ if (colide(Global.p)){ if (Global.p.isAlive()){ Global.p.killPlayer(setContinueFlying); }; }; if (symbol){ if (symbol.currentAnimLength() > 1){ symbol.update(); }; }; }; } public function getXML():XMLList{ params.@pos = ((owner.x + ",") + owner.y); switch (type){ case BAR: params.@end = (((owner.x + endPos.x) + ",") + (owner.y + endPos.y)); break; }; return (params); } protected function createBAR():void{ var e:Sprite; pos = ZoTools.transformToPoint(params.@pos); end = ZoTools.transformToPoint(params.@end); speed = Number(params.@speed); dir = ZoMathTools.normalize(new Point((end.x - pos.x), (end.y - pos.y))); distance = ZoMathTools.distance(pos, end); var s:Sprite = new Sprite(); s.graphics.lineStyle(5, 0); s.graphics.moveTo(0, 0); s.graphics.lineTo(params.@size, 0); var bmpData:BitmapData = new BitmapData(s.width, s.height, true, 0); bmpData.draw(s); var i:Number = 0; while (i < params.@nb) { e = new Sprite(); e.addChild(new Bitmap(bmpData)); e.x = (((params.@size * 2) + 10) * i); symbols.push(e); addChild(e); i++; }; rotation = ZoMathTools.dirRotation(pos, end); } } }//package
Section 102
//Enemy_editor_bar (Enemy_editor_bar) package { import mx.core.*; public class Enemy_editor_bar extends BitmapAsset { } }//package
Section 103
//Enemy_editor_escan (Enemy_editor_escan) package { import mx.core.*; public class Enemy_editor_escan extends BitmapAsset { } }//package
Section 104
//Enemy_editor_tracker1 (Enemy_editor_tracker1) package { import mx.core.*; public class Enemy_editor_tracker1 extends BitmapAsset { } }//package
Section 105
//Enemy_editor_turret (Enemy_editor_turret) package { import mx.core.*; public class Enemy_editor_turret extends BitmapAsset { } }//package
Section 106
//Enemy_sheet_bullet (Enemy_sheet_bullet) package { import mx.core.*; public class Enemy_sheet_bullet extends BitmapAsset { } }//package
Section 107
//Enemy_sheet_scan (Enemy_sheet_scan) package { import mx.core.*; public class Enemy_sheet_scan extends BitmapAsset { } }//package
Section 108
//Enemy_sheet_tracker (Enemy_sheet_tracker) package { import mx.core.*; public class Enemy_sheet_tracker extends BitmapAsset { } }//package
Section 109
//Enemy_sheet_turret (Enemy_sheet_turret) package { import mx.core.*; public class Enemy_sheet_turret extends BitmapAsset { } }//package
Section 110
//Game (Game) package { import flash.geom.*; import flash.display.*; import zomg.sound.*; import zomg.*; import zomg.tools.*; import zomg.gui.*; import zomg.olr.*; import flash.ui.*; public class Game extends Sprite { private var api_nk:Class; public var k:ZoKeys; protected var appLoaded:Boolean;// = false public var lvl_bg:Sprite; protected var pauseKey:Boolean;// = false protected var pauseScreen:PauseMenu; protected var useSponsor:Boolean;// = false protected var result:ResultScreen; public var bgColor:ZoBackground; protected var _state:uint; protected var lvl:LevelManager; protected var camera:Sprite; protected var useSS:Boolean;// = true public var trans:ZoSprite; protected var _useBg:Boolean;// = true public var endScreen:EndScreen; protected var _screenNumber:int;// = -1 public var meta_bg_cloud:Sprite; public var transitAllow:Boolean;// = false protected var gui:GUI; public var meta_bg:Sprite; protected var timerAim:Number;// = 5 public var appSize:Point; public var bg:Background; protected var timer:int;// = 0 protected var debug:DebugTool; public var unlockScreen:Unlock; protected var mouseClick:Boolean;// = false public var htp:HowToPlay; protected var splash:MovieClip; public var questionScreen:Question; protected var s:Stage; public var sscreen_sponsor:Class; protected var pauseScreenIdle:Number;// = 10 public static var NEW:uint = 1; public static var END:uint = 4; public static var UNPAUSE:uint = 6; public static var sheet_meta:Class = Game_sheet_meta; public static var SSCREEN:uint = 7; public static var LIVE:uint = 2; public static var sheet_vortex:Class = Game_sheet_vortex; public static var IDLE:uint = 0; public static var sheet_transition:Class = Game_sheet_transition; public static var sheet_meta_cloud:Class = Game_sheet_meta_cloud; public static var PAUSE:uint = 3; public static var MENU:uint = 5; public function Game(){ sscreen_sponsor = Game_sscreen_sponsor; api_nk = Game_api_nk; _state = IDLE; super(); addChild(new ZoBackground(new Point(800, 600))); Global.g = this; name = "[Sprite]Game"; s = Global.s; appSize = new Point(s.stageWidth, s.stageHeight); trans = new ZoSprite(new sheet_transition(), new Point(800, 600)); trans.symbol.addAnim("transitGo", new Point(800, 600), 3, new Point(0, 0), 4); trans.symbol.addAnim("transitBack", new Point(800, 600), 3, new Point(0, 0), 4, false, true); trans.visible = false; trans.x = (appSize.x / 2); trans.y = (appSize.y / 2); addChild(trans); splash = new api_nk(); splash.x = 400; splash.y = 300; if (useSS){ state = SSCREEN; screenNumber = 0; } else { showHtp(); state = LIVE; }; } public function showResult():void{ result.init(); state = MENU; } public function moveBg(move:Point):void{ var pos:Point; var posCloud:Point; if (!lvl.isCamFix()){ if (Global.lvl.isMeta()){ pos = new Point((meta_bg.x + (-(move.x) / 40)), (meta_bg.y + (-(move.y) / 30))); posCloud = new Point((meta_bg_cloud.x + (-(move.x) / 20)), (meta_bg_cloud.y + (-(move.y) / 15))); if ((((pos.x >= -200)) && ((pos.x <= 0)))){ meta_bg.x = pos.x; }; if ((((pos.y >= -200)) && ((pos.y <= 0)))){ meta_bg.y = pos.y; }; if ((((pos.x >= -200)) && ((pos.x <= 0)))){ meta_bg_cloud.x = posCloud.x; }; if ((((pos.y >= -200)) && ((pos.y <= 0)))){ meta_bg_cloud.y = posCloud.y; }; } else { pos = new Point((lvl_bg.x + (-(move.x) / 40)), (lvl_bg.y + (-(move.y) / 30))); lvl_bg.x = pos.x; lvl_bg.y = pos.y; bg.motion(move); }; }; } public function pauseGame():void{ if (state == LIVE){ state = PAUSE; }; } public function setCam(newPos:Point):void{ lvl.x = -((newPos.x - (Global.s.stageWidth / 2))); lvl.y = -((newPos.y - (Global.s.stageHeight / 2))); } public function get state():uint{ return (_state); } public function set state(v:uint):void{ _state = v; switch (v){ case IDLE: break; case LIVE: Global.mouse.activate(true); if (!appLoaded){ loadApp(); }; ZoSoundEngine.globalVolume = 1; lvl.visible = true; gui.visible = true; break; case PAUSE: ZoSoundEngine.globalVolume = 0.2; pauseScreen.pop(true); break; case UNPAUSE: pauseScreen.pop(false); timer = 0; timerAim = pauseScreenIdle; break; case END: ZoSoundEngine.globalVolume = 0.2; pauseScreen.pop(false); endScreen.visible = true; break; case SSCREEN: Global.mouse.activate(false); break; }; } protected function set screenNumber(v:int):void{ _screenNumber = v; switch (screenNumber){ case 0: timerAim = 230; addChild(splash); break; case 1: removeChild(splash); timerAim = 200; addChild(new OLRLogo(Global.s)); break; case 2: removeChildAt(1); showHtp(); timerAim = 0; break; case 3: state = LIVE; }; } public function get useBg():Boolean{ return (_useBg); } public function isLive():Boolean{ if (state == LIVE){ return (true); }; return (false); } public function toggleMetaBg():void{ if (useBg){ if (lvl.isMeta()){ meta_bg_cloud.visible = (meta_bg.visible = true); meta_bg_cloud.x = (meta_bg_cloud.y = (meta_bg.y = (meta_bg.x = -100))); lvl_bg.visible = false; } else { bg.visible = true; meta_bg_cloud.visible = (meta_bg.visible = false); lvl_bg.visible = true; lvl_bg.x = ZoMathTools.randomBetween(-300, 100, true); lvl_bg.y = ZoMathTools.randomBetween(-300, 100, true); }; } else { meta_bg_cloud.visible = (bg.visible = (lvl_bg.visible = (meta_bg.visible = false))); }; } public function update():void{ var _local3:Boolean; var s:String; switch (state){ case IDLE: break; case LIVE: if (!endScreen.visible){ lvl.update(); }; break; case MENU: if (!result.visible){ lvl.switchLevel(result.lvlToBuild); state = LIVE; }; break; case PAUSE: break; case UNPAUSE: if (timer < timerAim){ timer++; } else { state = LIVE; }; break; case SSCREEN: _local3 = false; if (screenNumber < 3){ if (timerAim > 0){ if (timer < timerAim){ timer++; } else { timer = 0; _local3 = true; }; }; if ((((screenNumber == 2)) && (!(htp.visible)))){ _local3 = true; }; if (_local3){ _local3 = true; screenNumber++; }; }; break; default: trace("Game >> main switch error game state"); }; if (appLoaded){ if (((k.getKeyStateByName("pause")) || (k.getKeyStateByName("menu")))){ if (!pauseKey){ pauseKey = true; if (state == PAUSE){ if (((!(htp.visible)) && (!(questionScreen.visible)))){ state = UNPAUSE; }; } else { if (state == LIVE){ state = PAUSE; }; }; }; } else { pauseKey = false; }; if (((k.getKeyStateByName("zoomIn")) && (Global.isDebug))){ setZoom(-0.01); } else { if (((k.getKeyStateByName("zoomOut")) && (Global.isDebug))){ setZoom(0.01); }; }; if (Global.isDebug){ s = (((("v" + Global.version) + "\n Frustrum (") + lvl.planetInFrustrum()) + ")\n"); }; }; } public function showEnd():void{ if (Global.globalStats.allLevelDone()){ endScreen.init(); addChild(endScreen); }; } public function reset():void{ if (state == PAUSE){ state = UNPAUSE; }; screensOff(true); state = LIVE; } public function showHtp():void{ if (!htp){ htp = new HowToPlay(); }; htp.init(); addChild(htp); } public function set useBg(v:Boolean):void{ _useBg = v; toggleMetaBg(); } private function loadApp():void{ bgColor = new ZoBackground(appSize); addChild(bgColor); bg = new Background(50); addChild(bg); meta_bg = new Sprite(); meta_bg.addChild(new sheet_meta()); meta_bg_cloud = new Sprite(); meta_bg_cloud.addChild(new sheet_meta_cloud()); meta_bg_cloud.alpha = 0.2; addChild(meta_bg); addChild(meta_bg_cloud); lvl_bg = new Sprite(); lvl_bg.addChild(new sheet_vortex()); lvl_bg.alpha = 0.2; addChild(lvl_bg); ManagerSound.loadSounds(); ZoSoundEngine.getSound("track_loop").playSound(); Global.cam = (camera = new Sprite()); addChild(camera); lvl = new LevelManager(); camera.addChild(lvl); Global.gui = (gui = new GUI()); addChild(Global.gui); addChild(trans); pauseScreen = new PauseMenu(Global.s); addChild(pauseScreen); endScreen = new EndScreen(); addChild(endScreen); unlockScreen = new Unlock(appSize); addChild(unlockScreen); questionScreen = new Question(new Point((appSize.x / 2), (appSize.y / 2))); addChild(questionScreen); Global.globalStats = new Stats(); k = new ZoKeys(s, new Array(new ZoKey(Keyboard.ESCAPE, "menu"), new ZoKey(80, "pause"), new ZoKey(66, "zoomOut"), new ZoKey(78, "zoomIn"), new ZoKey(Keyboard.ENTER, "go")), "main"); debug = new DebugTool(new Point((Global.s.stageWidth - 200), 0)); if (Global.isDebug){ addChild(debug); }; lvl.switchLevel(); result = new ResultScreen(); Global.result = result; result.x = ((appSize.x / 2) - (result.width / 2)); result.y = ((appSize.y / 2) - (result.height / 2)); addChild(result); appLoaded = true; state = LIVE; } public function setZoom(n:Number, add:Boolean=true):void{ if (add){ Global.zoomLevel = (Global.zoomLevel + n); } else { Global.zoomLevel = n; }; var delay:Number = 1; camera.scaleX = (camera.scaleY = Global.zoomLevel); camera.x = ((s.stageWidth * delay) * ((1 - Global.zoomLevel) / 2)); camera.y = ((s.stageHeight * delay) * ((1 - Global.zoomLevel) / 2)); } public function switchState(value:uint):void{ state = value; } protected function get screenNumber():int{ return (_screenNumber); } public function screensOff(force:Boolean=false):Boolean{ if (force){ htp.visible = false; unlockScreen.pop(null, false); questionScreen.pop(false); }; if (((((!(unlockScreen.visible)) && (!(questionScreen.visible)))) && (!(htp.visible)))){ return (true); }; return (false); } public function isIdle():Boolean{ if (state == IDLE){ return (true); }; return (false); } public function isPaused():Boolean{ if (state == PAUSE){ return (true); }; return (false); } } }//package
Section 111
//Game_api_nk (Game_api_nk) package { import mx.core.*; import flash.utils.*; public class Game_api_nk extends MovieClipLoaderAsset { public var dataClass:Class; private static var bytes:ByteArray = null; public function Game_api_nk(){ dataClass = Game_api_nk_dataClass; super(); initialWidth = (0x3200 / 20); initialHeight = (9600 / 20); } override public function get movieClipData():ByteArray{ if (bytes == null){ bytes = ByteArray(new dataClass()); }; return (bytes); } } }//package
Section 112
//Game_api_nk_dataClass (Game_api_nk_dataClass) package { import mx.core.*; public class Game_api_nk_dataClass extends ByteArrayAsset { } }//package
Section 113
//Game_sheet_meta (Game_sheet_meta) package { import mx.core.*; public class Game_sheet_meta extends BitmapAsset { } }//package
Section 114
//Game_sheet_meta_cloud (Game_sheet_meta_cloud) package { import mx.core.*; public class Game_sheet_meta_cloud extends BitmapAsset { } }//package
Section 115
//Game_sheet_transition (Game_sheet_transition) package { import mx.core.*; public class Game_sheet_transition extends BitmapAsset { } }//package
Section 116
//Game_sheet_vortex (Game_sheet_vortex) package { import mx.core.*; public class Game_sheet_vortex extends BitmapAsset { } }//package
Section 117
//Game_sscreen_sponsor (Game_sscreen_sponsor) package { import mx.core.*; public class Game_sscreen_sponsor extends BitmapAsset { } }//package
Section 118
//Global (Global) package { import flash.display.*; import api.*; import zomg.*; import zomg.tools.*; public class Global { public var FONT_GROTESQUE:Class; public var FONT_FUTURA:Class; public static var isDebug:Boolean = true; public static var kgg:Kgg; public static var cam:Sprite; public static var console:ZoConsole; public static var version:String = "0.2"; public static var lvlStats:Stats; public static var result:ResultScreen; public static var mouse:ZoCursor; public static var g:Game; public static var lvl:LevelManager; public static var p:Player; public static var zoomLevel:Number = 1; public static var s:Stage; public static var gui:GUI; public static var globalStats:Stats; public function Global(){ FONT_GROTESQUE = Global_FONT_GROTESQUE; FONT_FUTURA = Global_FONT_FUTURA; super(); } } }//package
Section 119
//Global_FONT_FUTURA (Global_FONT_FUTURA) package { import mx.core.*; public class Global_FONT_FUTURA extends FontAsset { } }//package
Section 120
//Global_FONT_GROTESQUE (Global_FONT_GROTESQUE) package { import mx.core.*; public class Global_FONT_GROTESQUE extends FontAsset { } }//package
Section 121
//GUI (GUI) package { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import zomg.*; import zomg.tools.*; import zomg.gui.*; public class GUI extends Sprite { protected var tf_lvlName:TextField; protected var timer:int;// = 0 protected var tf_lvlKey:TextField; protected var tf_lvlCoin:TextField; protected var aimTimer:Number;// = 1 protected var lvlCoin:Sprite; protected var allGui:Array; protected var lvlKey:Sprite; protected var tf_metaCoin:TextField; protected var aim:int;// = 0 protected var b:Btn_logo; protected var levelName:Sprite; protected var remain:int;// = -1 protected var metaCoin:Sprite; protected var multi:Number;// = 3 protected var l:LevelManager; public function GUI(){ var img:Bitmap; super(); l = Global.lvl; allGui = new Array(); lvlKey = new Sprite(); lvlKey.x = 5; lvlKey.y = 5; img = ZoColor.getImageFromSheet(new Collectable.sheet_key(), new Point(25, 13), new Point(1, 2)); lvlKey.addChild(img); img.y = 8; tf_lvlKey = ZoGUI.getStdTextField(new Point(300, 25), "1 / 3", {font:"futura", embed:true, size:20, bold:true, align:"left", color:0x222222}, new Point(30, 0), lvlKey); addChild(lvlKey); lvlCoin = new Sprite(); lvlCoin.x = lvlKey.x; lvlCoin.y = (lvlKey.y + 22); img = ZoColor.getImageFromSheet(new Collectable.sheet_cash(), new Point(13, 13), new Point(0, 0)); lvlCoin.addChild(img); img.x = 5; img.y = 9; tf_lvlCoin = ZoGUI.getStdTextField(new Point(300, 25), "1 / 3", {font:"futura", embed:true, size:20, bold:true, align:"left", color:0x222222}, new Point(30, 0), lvlCoin); addChild(lvlCoin); levelName = new Sprite(); levelName.addChild(ZoGUI.getStdTextField(new Point(30, 25), "LEVEL ", {font:"grotesque", embed:true, size:20, align:"left", color:0x222222, align:"right"}, new Point(), levelName)); tf_lvlName = ZoGUI.getStdTextField(new Point(300, 25), "##", {font:"futura", embed:true, size:20, align:"left", color:0x222222, align:"left"}, new Point(30, 0), levelName); levelName.x = ((Global.g.appSize.x / 2) - 50); levelName.y = (Global.g.appSize.y - 30); metaCoin = new Sprite(); var total:TextField = ZoGUI.getStdTextField(new Point(60, 25), "TOTAL", {font:"grotesque", embed:true, size:30, align:"left", bold:true, letterSpace:2, color:0xFFFFFF}, new Point(10, 5), metaCoin); img = Collectable.getIcon("cash"); img.x = total.x; img.y = 50; metaCoin.addChild(img); tf_metaCoin = ZoGUI.getStdTextField(new Point(60, 25), "x 0", {font:"futura", embed:true, size:25, align:"left", color:0xFFFFFF}, new Point(((img.x + img.width) + 5), (img.y - 12)), metaCoin); metaCoin.y = (metaCoin.x = 5); addChild(metaCoin); b = new Btn_logo(this, new Point(5, 60)); b.scaleX = (b.scaleY = 0.8); } public function updateGUI():void{ var i:uint; var nb:int; var total:int; if (Global.lvl.currentLevel == 0){ lvlCoin.visible = false; lvlKey.visible = false; metaCoin.visible = true; b.visible = true; } else { lvlCoin.visible = true; lvlKey.visible = true; metaCoin.visible = false; b.visible = false; }; nb = getKeyLeft(); total = getKeyLeft(true); tf_lvlKey.text = ((nb + " / ") + total); if (l.allKeyDone()){ l.allKeyCollected = true; } else { l.allKeyCollected = false; }; nb = l.getNbCollec(Collectable.CASH, false); total = l.getNbCollec(Collectable.CASH, false, true); tf_lvlCoin.text = ((nb + " / ") + total); tf_lvlName.text = Global.lvl.lvlName.toUpperCase(); } public function toggleElement(name:String, flag:Boolean):void{ var i:Number = 0; while (i < allGui.length) { if (allGui[i].name == name){ allGui[i].visible = flag; }; i++; }; } public function bumpCash():void{ var i:Number = 0; while (i < allGui.length) { if (allGui[i].name == "red"){ allGui[i].bump(); }; i++; }; } protected function goToNumber(e:Event):void{ var sign:int; if (timer < aimTimer){ timer++; } else { timer = 0; sign = ZoMathTools.sign((aim - remain)); remain = (remain + (sign * multi)); if (sign > 0){ if (remain > aim){ remain = aim; } else { if (sign < 0){ if (remain < aim){ remain = aim; }; }; }; }; tf_metaCoin.text = ("x " + remain); if (remain == aim){ removeEventListener(Event.ENTER_FRAME, goToNumber); }; }; } public function getKeyLeft(total:Boolean=false):int{ var tot:int; var i:int; var nb:int; i = 0; while (i < l.allColl.length) { if (l.allColl[i].type == Collectable.KEY){ tot++; if (l.allColl[i].isTaken()){ nb++; }; }; i++; }; if (total){ return (tot); }; return (nb); } public function updateRemain():void{ aim = Global.globalStats.getRemaining(); if (remain != aim){ addEventListener(Event.ENTER_FRAME, goToNumber); }; } public function setElementText(name:String, txt:String):void{ var i:Number = 0; while (i < allGui.length) { if (allGui[i].name == name){ allGui[i].setElementText(txt); }; i++; }; } public function resetGUI():void{ updateGUI(); } } }//package
Section 122
//HowToPlay (HowToPlay) package { import flash.events.*; import flash.geom.*; import flash.display.*; import zomg.*; public class HowToPlay extends Sprite { protected var timerAim:Number;// = 15 public var sscreen_htp:Class; protected var screen1:Sprite; protected var screen2:Sprite; protected var timer:int;// = 0 public function HowToPlay(){ sscreen_htp = HowToPlay_sscreen_htp; screen1 = new Sprite(); screen2 = new Sprite(); super(); name = "HTP"; screen1.addChild(ZoColor.getImageFromSheet(new sscreen_htp(), new Point(800, 600), new Point(0, 0))); screen2.addChild(ZoColor.getImageFromSheet(new sscreen_htp(), new Point(800, 600), new Point(0, 1))); addChild(screen1); addChild(screen2); screen2.mouseEnabled = (screen1.mouseEnabled = false); visible = false; new Btn_logo(this, new Point(62, 498)); } public function update(e:Event=null):void{ if (timer < timerAim){ timer++; } else { timer = 0; screen1.visible = !(screen1.visible); screen2.visible = !(screen2.visible); }; } public function init():void{ timer = 0; screen1.visible = true; screen2.visible = false; addEventListener(MouseEvent.MOUSE_UP, kill); addEventListener(Event.ENTER_FRAME, update); visible = true; } public function kill(e:MouseEvent=null):void{ if (e.target.name == "HTP"){ visible = false; removeEventListener(MouseEvent.MOUSE_UP, kill); removeEventListener(Event.ENTER_FRAME, update); }; } } }//package
Section 123
//HowToPlay_sscreen_htp (HowToPlay_sscreen_htp) package { import mx.core.*; public class HowToPlay_sscreen_htp extends BitmapAsset { } }//package
Section 124
//LevelManager (LevelManager) package { import flash.geom.*; import flash.display.*; import flash.utils.*; import zomg.sound.*; import zomg.*; import zomg.tools.*; import com.*; public class LevelManager extends Sprite { protected var zoneA:int;// = 0 protected var xml:XML; protected var limits:Sprite; protected var zoneB:int;// = 0 protected var exit:Collisionable; public var allEn:Array; public var allColl:Array; protected var levelC:Sprite; public var bg:Background; protected var startLevel:uint;// = 0 public var timer:StopWatch; public var levelBounds:Rectangle; protected var levels:Array; protected var p:Player; protected var cm:Bitmap; public var displayList:Array; public var currentLevel:int;// = 0 protected var _map:Bitmap; protected var stats:Stats; public var endpos:Point; public var oldLevel:int;// = 0 public var levelToLoad:int;// = 0 protected var trans:ZoSprite; protected var levelLoaded:Boolean;// = false protected var planetStart:Collisionable; public var levelSize:Point; protected var door:Collisionable; protected var state:uint;// = 0 protected var bounds:Border; public var startpos:Point; public var spec:Object; public var currentZone:int;// = 0 public var lvlName:String;// = "" public var allAsset:Array; public var lvlstartpos:Point; public var allKeyCollected:Boolean;// = false public var bManager:ManagerBullet; protected var _objectif:uint;// = 0 public static var TIMER:uint = 2; protected static var boundEcart:Number = 100; public static var LIVE:uint = 1; public static var EXIT:uint = 1; public static var OPEN:uint = 2; public static var xmlFile:Class = LevelManager_xmlFile; public static var IDLE:uint = 0; public static var TRANSIT:uint = 4; public static var END:uint = 3; public static var MENU:uint = 0; public function LevelManager(){ displayList = new Array(); startpos = new Point(); endpos = new Point(); levelSize = new Point(); lvlstartpos = new Point(); super(); Global.lvl = this; levelC = this; Global.p = (p = new Player(this)); var file:ByteArray = new xmlFile(); xml = new XML(file.readUTFBytes(file.length)); bg = Global.g.bg; bManager = new ManagerBullet(levelC); trans = Global.g.trans; bounds = new Border(); } protected function setLevelBoundsRect():void{ var i:uint; var ecart:Number = boundEcart; levelBounds = new Rectangle(allAsset[0].x, allAsset[0].y, allAsset[0].x, allAsset[0].y); i = 0; while (i < allAsset.length) { levelBounds = levelBoundsPointTreat(levelBounds, allAsset[i].position); i++; }; levelBounds = levelBoundsPointTreat(levelBounds, startpos); if (endpos.length > 1){ levelBounds = levelBoundsPointTreat(levelBounds, endpos); }; levelBounds.x = (levelBounds.x - ecart); levelBounds.y = (levelBounds.y - ecart); levelBounds.width = (levelBounds.width + ecart); levelBounds.height = (levelBounds.height + ecart); } public function updateAll():void{ var i:uint; i = 0; while (i < allEn.length) { allEn[i].update(); i++; }; bManager.update(); i = 0; while (i < allColl.length) { allColl[i].update(); i++; }; i = 0; while (i < allAsset.length) { allAsset[i].update(); if (allAsset[i].isSunOn()){ Global.globalStats.setAchievement("lighSun", 1); }; i++; }; bounds.update(); } public function inMenu():Boolean{ if (currentLevel == 0){ return (true); }; return (false); } public function levelDone():void{ var multiplier:Number = 1000; var timeScore:Number = 100000; var oldCash:int = (Global.result.oldCash = Global.globalStats.levelDone[currentLevel]); var newCash:int = (Global.result.newCash = getNbCollec(Collectable.CASH, false)); if (newCash > oldCash){ Global.globalStats.levelDone[currentLevel] = newCash; }; timer.stop(); var oldTime:Number = (Global.result.oldTime = Global.globalStats.levelTime[currentLevel]); var newTime:Number = (Global.result.newTime = timer.getElapsedTime()); if (newTime < oldTime){ Global.globalStats.levelTime[currentLevel] = newTime; }; Global.result.lvlName = lvlName; Global.globalStats.lastPlayed = (Global.result.lvlNum = currentLevel); Global.g.showResult(); state = IDLE; Global.globalStats.cookie("save"); } protected function clearLevel():Boolean{ var i:Number = 0; if (allAsset){ i = 0; while (i < allAsset.length) { removeChild(allAsset[i]); allAsset[i] = null; i++; }; i = 0; while (i < allEn.length) { if (!allEn[i].isBullet()){ removeChild(allEn[i]); allEn[i] = null; } else { bManager.clean(allEn[i]); }; i++; }; i = 0; while (i < allColl.length) { removeChild(allColl[i]); allColl[i] = null; i++; }; p.remove(); removeChild(bounds); if (bg){ bg.visible = false; }; }; if ((numChildren - bManager.countElement()) == 0){ return (true); }; trace((((("LVLM > Couldn't remove level (numChild:" + numChildren) + " - bullet:") + bManager.countElement()) + ") | CHECK NUM CHILDREN IN LVLM")); return (false); } protected function myLevel():int{ var gate:int; var lvl:int; var xm:XML = xml.level[0]; var i:int; var lvls:Array = new Array(0, 0, 0, 0); var lvlsDone:Array = new Array(0, 0, 0, 0); i = 0; while (i < xm.collision.length()) { gate = int(xm.collision[i].@gate); lvl = int(xm.collision[i].@level); var _local8 = lvls; var _local9 = lvl; var _local10 = (_local8[_local9] + 1); _local8[_local9] = _local10; if (Global.globalStats.levelDone[gate] >= 0){ _local8 = lvlsDone; _local9 = lvl; _local10 = (_local8[_local9] + 1); _local8[_local9] = _local10; }; i++; }; var ret:int; if (lvlsDone[1] >= zoneA){ if (lvlsDone[2] >= zoneB){ ret = 3; } else { ret = 2; }; } else { ret = 1; }; return (ret); } public function setLevel(xm:XML):void{ var col:Collisionable; var e:Enemy; var c:Collectable; var top:Point; var bottom:Point; var lvlNum:int = int(xm.@num); var id:int; allAsset = new Array(); allEn = new Array(); allColl = new Array(); var i:uint; objectif = uint(xm.@type); startpos = ZoTools.transformToPoint(xm.@start); endpos = ZoTools.transformToPoint(xm.@end); lvlstartpos = startpos; if (xm.@top){ top = ZoTools.transformToPoint(xm.@top); bottom = ZoTools.transformToPoint(xm.@bottom); levelBounds = new Rectangle(top.x, top.y, bottom.x, bottom.y); bounds.init(top, bottom); } else { Global.console.addLine("ERROR > Old school level bounds", "LM"); if (xm.collision.length() > 0){ setLevelBoundsRect(); }; }; currentZone = int(getLevelZone(uint(lvlNum))); var cameraFix:Boolean = Boolean(int(xm.@camfix)); if (lvlNum == 0){ bg.visible = false; } else { bg.init(currentZone, !(cameraFix)); }; addChild(bounds); if (lvlNum == 0){ id = Collisionable.logotype; } else { id = Collisionable.start; }; door = new Collisionable(id, startpos, null, false); addChild(door); allAsset.push(door); if (objectif == EXIT){ exit = new Collisionable(Collisionable.end, endpos, null, false); addChild(exit); allAsset.push(exit); }; levelSize = ZoTools.transformToPoint(xm.@size); var myLvl:int; if (int(xm.@num) < 1){ myLvl = myLevel(); }; var build:Boolean; var list:Array = new Array(); i = 0; while (i < xm.collision.length()) { if (myLvl > 0){ if (xm.collision[i].@level > 0){ if (xm.collision[i].@level > myLvl){ build = false; }; }; }; if (((build) && ((xm.collision[i].@sun <= 0)))){ list.push(i); }; i++; }; i = 0; while (i < xm.collision.length()) { if (xm.collision[i].@sun > 0){ list.push(i); }; i++; }; var ind:int; i = 0; while (i < list.length) { ind = list[i]; col = new Collisionable(uint(xm.collision[ind].@type), ZoTools.transformToPoint(xm.collision[ind].@pos), new XMLList(xm.collision[ind].toXMLString())); addChild(col); allAsset.push(col); if (lvlNum == 0){ if (Global.globalStats.lastPlayed == 0){ planetStart = col; } else { if (col.isGate()){ if (col.gate == Global.globalStats.lastPlayed){ planetStart = col; lvlstartpos = col.position; }; }; }; if (planetStart){ planetStart.mouseActive = true; }; }; i++; }; i = 0; while (i < xm.enemy.length()) { e = new Enemy(uint(xm.enemy[i].@type), ZoTools.transformToPoint(xm.enemy[i].@pos), new XMLList(xm.enemy[i].toXMLString()), this); addChild(e); allEn.push(e); i++; }; i = 0; while (i < xm.collect.length()) { c = new Collectable(uint(xm.collect[i].@type), ZoTools.transformToPoint(xm.collect[i].@pos), p, this); addChild(c); allColl.push(c); i++; }; bManager.bringFront(); addChild(p); addChild(p.retic); currentLevel = int(xm.@num); var z:Number = 0; if (xm.@zoom > 0){ z = Number(xm.@zoom); } else { z = 1; }; Global.g.setZoom(z, false); p.toggleUseCamera(!(cameraFix)); p.reset(planetStart); i = 0; while (i < allAsset.length) { allAsset[i].isInFrustrum(); i++; }; lvlName = xm.@name; bManager.reset(); updateMeta(); } protected function setLevelBoundsCircle():void{ var p:Number; var i:Number = 0; var dist:Number = 0; i = 0; while (i < allAsset.length) { p = ZoMathTools.distance(new Point(), allAsset[i].position); if (p > dist){ dist = p; }; i++; }; limits = new Sprite(); limits.graphics.lineStyle(10, 0x345600); limits.graphics.drawCircle(0, 0, (Math.round(dist) + 100)); addChild(limits); } protected function resetLevelVars():void{ if (isMeta()){ p.position = lvlstartpos; } else { p.position = startpos; }; Global.g.toggleMetaBg(); allKeyCollected = false; Global.gui.updateGUI(); timer = new StopWatch(); timer.start(); } public function loadLevel():void{ if (clearLevel()){ oldLevel = currentLevel; setLevel(xml.level[levelToLoad]); resetLevelVars(); if (currentLevel != 0){ Global.globalStats.lastPlayed = currentLevel; Global.globalStats.cookie("save"); }; levelLoaded = true; }; } public function isMeta():Boolean{ if (currentLevel == 0){ return (true); }; return (false); } public function get map():Bitmap{ return (_map); } public function set objectif(v:uint):void{ _objectif = v; } public function updateMeta():void{ var gateNum:Number; var lvlUnlocked:Boolean; var done:Boolean; var lvlHS:int; var over:Boolean; var i:int; if (currentLevel == 0){ i = 0; while (i < allAsset.length) { if (allAsset[i].isGate()){ gateNum = allAsset[i].gate; if (allAsset[i].need <= 0){ Global.globalStats.levelUnlocked[gateNum] = true; }; lvlUnlocked = Global.globalStats.levelUnlocked[gateNum]; done = Global.globalStats.levelDone[gateNum]; lvlHS = int(Global.globalStats.levelDone[gateNum]); over = p.comparePlanetLanded(allAsset[i], true); allAsset[i].setLocked(lvlUnlocked, done, lvlHS, getNbCollecXML(gateNum, Collectable.CASH), over); }; i++; }; }; } public function getPlanetInFrustrum():Array{ var planetsToCheck:Array = new Array(); var i:Number = 0; while (i < allAsset.length) { if (((((allAsset[i].infrustrum) && (allAsset[i].isPlanet()))) && (allAsset[i].visible))){ planetsToCheck.push(allAsset[i]); }; i++; }; return (planetsToCheck); } public function resetLevel(transition:Boolean=false):void{ var i:Number; if (transition){ state = TRANSIT; } else { i = 0; while (i < allAsset.length) { allAsset[i].reset(); i++; }; i = 0; while (i < allEn.length) { allEn[i].reset(); i++; }; bManager.reset(); i = 0; while (i < allColl.length) { allColl[i].reset(); i++; }; p.reset(planetStart); resetLevelVars(); if (currentLevel == 0){ updateMeta(); } else { exit.symbol.playAnim("idle"); }; }; } public function getLevelName(ind:uint):String{ return (xml.level[ind].@name); } public function setPlanetPaid(planet:Collisionable):void{ Global.globalStats.levelUnlocked[planet.gate] = true; Global.globalStats.used = (Global.globalStats.used + planet.need); updateMeta(); Global.gui.updateGUI(); Global.gui.updateRemain(); } public function isCamFix():Boolean{ return (!(Global.p.useCamFollow)); } public function getPrice(num:int=1):int{ var price:int = xml.level[0].collision[(num - 1)].@need; return (price); } public function outOfScreen(obj:DisplayObject):Boolean{ var bounds:Rectangle = levelBounds; var pt:Point = obj.localToGlobal(new Point()); var gap:Number = 300; var s:Stage = Global.s; if ((((((((pt.x < (0 - gap))) || ((pt.x > (s.stageWidth + gap))))) || ((pt.y < (0 - gap))))) || ((pt.y > (s.stageHeight + gap))))){ return (true); }; return (false); } public function get objectif():uint{ return (_objectif); } protected function getLevelZone(ind:uint):String{ var ind = ind; return (xml.level[0].collision.(@gate == ind).@zone); } protected function levelBoundsPointTreat(rec:Rectangle, pt:Point):Rectangle{ rec.x = Math.min(pt.x, rec.x); rec.y = Math.min(pt.y, rec.y); rec.width = Math.max(pt.x, rec.width); rec.height = Math.max(pt.y, rec.height); return (rec); } public function allKeyDone():Boolean{ var tot:int; var nb:int; var i:uint; while (i < allColl.length) { if (allColl[i].type == Collectable.KEY){ tot++; if (allColl[i].isDone()){ nb++; }; }; i++; }; if (nb == tot){ return (true); }; return (false); } public function switchLevel(num:int=-1):void{ if (num < 0){ num = 0; }; levelToLoad = num; levelLoaded = false; state = TRANSIT; } public function set map(bmp:Bitmap):void{ _map = bmp; } public function gateOpen():void{ var planet:Collisionable; if (isMeta()){ planet = Global.p.planetLandedOnLast; if (planet){ if (planet.isGate()){ if (!Global.globalStats.levelUnlocked[planet.gate]){ payForPlanet(planet); } else { if (Global.globalStats.levelUnlocked[planet.gate]){ switchLevel(planet.gate); }; }; }; }; }; } public function outOfLevel(obj:Object):Boolean{ var bounds:Rectangle = levelBounds; if ((((((((obj.x < bounds.x)) || ((obj.x > bounds.width)))) || ((obj.y < bounds.y)))) || ((obj.y > bounds.height)))){ return (true); }; return (false); } public function countLevel():int{ Global.console.addLine(("nbLvl : " + xml.level[0].collision.length()), "LM"); return (xml.level[0].collision.length()); } public function update():void{ var i:uint; switch (state){ case IDLE: break; case LIVE: if (Global.g.screensOff()){ p.update(); }; updateAll(); if (currentLevel > 0){ if (((p.isFlying()) && ((door.symbol.currentAnim == "idle")))){ door.symbol.playAnim("close", 1); } else { if ((((door.symbol.currentAnim == "close")) && (!(door.symbol.hasFinishedPlaying("close"))))){ door.symbol.update(); } else { if (door.symbol.hasFinishedPlaying("close")){ door.visible = false; }; }; }; if (allKeyCollected){ if (exit.symbol.currentAnim == "idle"){ exit.symbol.playAnim("open", 1); } else { if (!exit.symbol.hasFinishedPlaying("open")){ exit.symbol.update(); }; }; }; }; break; case OPEN: if (door.symbol.hasFinishedPlaying("open")){ door.symbol.playAnim("idle"); p.visible = true; state = LIVE; } else { door.symbol.update(); }; break; case TRANSIT: if (((!(trans.visible)) && (!((trans.symbol.currentAnim == "transitGo"))))){ trans.symbol.playAnim("transitGo", 1); trans.visible = true; } else { if ((((trans.symbol.currentAnim == "transitGo")) && (trans.symbol.hasFinishedPlaying("transitGo")))){ if (!levelLoaded){ loadLevel(); } else { resetLevel(); }; trans.symbol.playAnim("transitBack", 1); } else { if (trans.symbol.hasFinishedPlaying("transitBack")){ trans.visible = false; if (currentLevel != 0){ p.visible = false; p.updateCam(); door.visible = true; door.symbol.playAnim("open", 1); ZoSoundEngine.getSound("door_open").playSound(); state = OPEN; } else { Global.gui.updateRemain(); if (Global.globalStats.allLevelDone()){ if (Global.kgg){ Global.kgg.k.stats.submit("GameEnd", 1); }; Global.g.showEnd(); } else { if (Global.kgg){ Global.kgg.k.stats.submit("GameEnd", 0); }; }; state = LIVE; }; } else { trans.symbol.update(); }; }; }; break; }; if ((((state == OPEN)) || ((state == TRANSIT)))){ if (levelLoaded){ updateAll(); }; }; } public function getNbCollecXML(lvl:int=1, type:int=0):int{ var xm:XMLList; var total:int; var i:int; var x:XML = xml.level[lvl]; if (x){ xm = new XMLList(x.toXMLString()); total = 0; i = 0; while (i < xm.collect.length()) { if (int(xm.collect[i].@type) == type){ total++; }; i++; }; } else { trace(("LM > error, no level " + lvl)); }; return (total); } public function hasExit():Boolean{ if (objectif == EXIT){ return (true); }; return (false); } public function getNbCollec(type:int=0, stillInGame:Boolean=false, max:Boolean=false):int{ var i:int; var left:int; var collected:int; var total:int; i = 0; while (i < allColl.length) { if (allColl[i].type == type){ total++; if (allColl[i].isDone()){ collected++; } else { left++; }; }; i++; }; if (max){ return (total); }; if (stillInGame){ return (left); }; return (collected); } public function getNearestEnemies():Enemy{ var i:int; var near:Number = 50; var dist:Number = 0; var ind = -1; i = 0; while (i < allEn.length) { dist = ZoMathTools.distance(p.position, allEn[i].position); if (dist < near){ near = dist; ind = i; }; i++; }; if (ind > -1){ return (allEn[ind]); }; return (null); } public function getNearestPlanet(distnear:Number=600):Collisionable{ var i:int; var near:Number = distnear; var dist:Number = 0; var ind = -1; i = 0; while (i < allAsset.length) { dist = ZoMathTools.distance(p.position, allAsset[i].position); if (dist < near){ near = dist; ind = i; }; i++; }; if (ind > -1){ return (allAsset[ind]); }; return (null); } public function payForPlanet(planet:Collisionable):void{ var canUnlock:Boolean; if (Global.globalStats.getRemaining() >= planet.need){ canUnlock = true; } else { trace("Player > Not enough minerals"); }; Global.g.unlockScreen.pop(planet, true, canUnlock); } public function planetInFrustrum():int{ var i:uint; var nb:int; if (allAsset){ i = 0; while (i < allAsset.length) { if (allAsset[i].infrustrum){ nb++; }; i++; }; }; return (nb); } } }//package
Section 125
//LevelManager_xmlFile (LevelManager_xmlFile) package { import mx.core.*; public class LevelManager_xmlFile extends ByteArrayAsset { } }//package
Section 126
//Main (Main) package { import flash.events.*; import flash.geom.*; import flash.display.*; import api.*; import com.hires.*; import zomg.*; import zomg.tools.*; public class Main extends Sprite { protected var game:Game; protected var fpsDisplay:FPSStats; public static var sheet_cursor:Class = Main_sheet_cursor; public function Main():void{ super(); if (stage){ init(); } else { addEventListener(Event.ADDED_TO_STAGE, init); }; } private function init(e:Event=null):void{ removeEventListener(Event.ADDED_TO_STAGE, init); var url:String = this.loaderInfo.loaderURL; if (url.indexOf("http://") != -1){ Global.isDebug = false; }; if (url.indexOf("kongregate.com") > -1){ addChild(new Kgg(stage)); }; Global.s = stage; Global.console = new ZoConsole(stage, new FPSStats()); Global.mouse = new ZoCursor(stage, true, new sheet_cursor(), new Point(26, 26)); Global.mouse.symbol.addAnim("menu", new Point(26, 26), 1, new Point(0, 1)); Global.mouse.symbol.addAnim("menuWhite", new Point(26, 26), 1, new Point(0, 2)); game = new Game(); addChild(game); if (Global.isDebug){ addChild(Global.console); }; addChild(Global.mouse); addEventListener(Event.ENTER_FRAME, loop); addEventListener(Event.ACTIVATE, flashActive); addEventListener(Event.DEACTIVATE, flashDeactive); } private function flashActive(event:Event):void{ } private function flashDeactive(event:Event):void{ game.pauseGame(); } protected function loop(e:Event=null):void{ game.update(); } } }//package
Section 127
//Main_sheet_cursor (Main_sheet_cursor) package { import mx.core.*; public class Main_sheet_cursor extends BitmapAsset { } }//package
Section 128
//ManagerBullet (ManagerBullet) package { import flash.geom.*; import flash.display.*; import zomg.tools.*; public class ManagerBullet { public var elmtsUsed:Array; public var elmts:Array; protected var owner:Sprite; public function ManagerBullet(owner:Sprite){ var e:Enemy; super(); this.owner = owner; elmtsUsed = new Array(); elmts = new Array(); var i:uint; while (i < 100) { e = new Enemy(Enemy.BULLET, new Point()); elmts.push(e); owner.addChild(e); i++; }; } public function update():void{ var i:int; i = 0; while (i < elmtsUsed.length) { elmtsUsed[i].update(); i++; }; } public function addElement(pos:Point, params:XMLList):void{ var e:Enemy = getFirstAvailable(); if (e){ e.setBulletParams(pos, params); makeAvailable(e, false); } else { trace("bManager >> No bullet available !"); }; } public function countElement():int{ return ((elmts.length + elmtsUsed.length)); } protected function getFirstAvailable():Enemy{ var i:int; i = 0; while (i < elmts.length) { if (!elmts[i].active){ return (elmts[i]); }; i++; }; return (null); } public function clean(elmt:Enemy):void{ makeAvailable(elmt, true); } public function reset():void{ var i:uint; while (elmtsUsed.length > 0) { clean(elmtsUsed[i]); }; } public function bringFront():void{ var i:uint; i = 0; while (i < elmts.length) { owner.addChild(elmts[i]); i++; }; i = 0; while (i < elmtsUsed.length) { owner.addChild(elmtsUsed[i]); i++; }; } protected function makeAvailable(e:Enemy, flag:Boolean=false):void{ if (!flag){ elmts = ZoTools.removeArrayElement(elmts, e); elmtsUsed.push(e); } else { elmtsUsed = ZoTools.removeArrayElement(elmtsUsed, e); elmts.push(e); }; e.active = (e.visible = !(flag)); } } }//package
Section 129
//ManagerSound (ManagerSound) package { import zomg.sound.*; public class ManagerSound { public static var snd_door_open:Class = ManagerSound_snd_door_open; public static var snd_turret_shoot:Class = ManagerSound_snd_turret_shoot; public static var snd_sun_explode:Class = ManagerSound_snd_sun_explode; public static var snd_meta_buy:Class = ManagerSound_snd_meta_buy; public static var snd_menu_bip:Class = ManagerSound_snd_menu_bip; public static var snd_collect_key:Class = ManagerSound_snd_collect_key; public static var snd_player_die:Class = ManagerSound_snd_player_die; public static var snd_collect:Class = ManagerSound_snd_collect; public static var snd_planet_dis:Class = ManagerSound_snd_planet_dis; public static var track_loop:Class = ManagerSound_track_loop; public function ManagerSound(){ super(); } public static function loadSounds():void{ ZoSoundEngine.setEngineInfo(1); ZoSoundEngine.addSound(track_loop, "track_loop", "music", 0); ZoSoundEngine.addSound(snd_collect, "collect", "fx", 1); ZoSoundEngine.addSound(snd_collect_key, "collect_key", "fx", 1); ZoSoundEngine.addSound(snd_player_die, "player_die", "fx", 1); ZoSoundEngine.addSound(snd_door_open, "door_open", "fx", 1); ZoSoundEngine.addSound(snd_turret_shoot, "turret_shoot", "fx", 1); ZoSoundEngine.addSound(snd_meta_buy, "meta_buy", "fx", 1); ZoSoundEngine.addSound(snd_planet_dis, "planet_dis", "fx", 1); ZoSoundEngine.addSound(snd_sun_explode, "sun_explode", "fx", 1); ZoSoundEngine.addSound(snd_menu_bip, "bip", "fx", 1); ZoSoundEngine.getSound("collect").myVolume = 0.37; ZoSoundEngine.getSound("planet_dis").myVolume = 0.38; ZoSoundEngine.getSound("turret_shoot").myVolume = 0; ZoSoundEngine.getSound("sun_explode").myVolume = 0; ZoSoundEngine.getSound("bip").myVolume = 0; } } }//package
Section 130
//ManagerSound_snd_collect (ManagerSound_snd_collect) package { import mx.core.*; public class ManagerSound_snd_collect extends SoundAsset { } }//package
Section 131
//ManagerSound_snd_collect_key (ManagerSound_snd_collect_key) package { import mx.core.*; public class ManagerSound_snd_collect_key extends SoundAsset { } }//package
Section 132
//ManagerSound_snd_door_open (ManagerSound_snd_door_open) package { import mx.core.*; public class ManagerSound_snd_door_open extends SoundAsset { } }//package
Section 133
//ManagerSound_snd_menu_bip (ManagerSound_snd_menu_bip) package { import mx.core.*; public class ManagerSound_snd_menu_bip extends SoundAsset { } }//package
Section 134
//ManagerSound_snd_meta_buy (ManagerSound_snd_meta_buy) package { import mx.core.*; public class ManagerSound_snd_meta_buy extends SoundAsset { } }//package
Section 135
//ManagerSound_snd_planet_dis (ManagerSound_snd_planet_dis) package { import mx.core.*; public class ManagerSound_snd_planet_dis extends SoundAsset { } }//package
Section 136
//ManagerSound_snd_player_die (ManagerSound_snd_player_die) package { import mx.core.*; public class ManagerSound_snd_player_die extends SoundAsset { } }//package
Section 137
//ManagerSound_snd_sun_explode (ManagerSound_snd_sun_explode) package { import mx.core.*; public class ManagerSound_snd_sun_explode extends SoundAsset { } }//package
Section 138
//ManagerSound_snd_turret_shoot (ManagerSound_snd_turret_shoot) package { import mx.core.*; public class ManagerSound_snd_turret_shoot extends SoundAsset { } }//package
Section 139
//ManagerSound_track_loop (ManagerSound_track_loop) package { import mx.core.*; public class ManagerSound_track_loop extends SoundAsset { } }//package
Section 140
//PauseMenu (PauseMenu) package { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import zomg.sound.*; import api.*; import zomg.gui.*; public class PauseMenu extends Sprite { private var sheet_soundButton:Class; protected var container:Sprite; protected var quality_med:ZoButton; protected var quality_low:ZoButton; protected var quality_hig:ZoButton; protected var sndFx:ZoButton; protected var btn:Array; private var sheet_btn_ghig:Class; private var bmp_pauseback:Class; protected var backg:Bitmap; private var sheet_btn_gmed:Class; protected var mouseClick:Boolean;// = false private var sheet_btn_glow:Class; protected var sndMusic:ZoButton; public function PauseMenu(s:Stage){ var b:ZoButton; sheet_btn_glow = PauseMenu_sheet_btn_glow; sheet_btn_gmed = PauseMenu_sheet_btn_gmed; sheet_btn_ghig = PauseMenu_sheet_btn_ghig; bmp_pauseback = PauseMenu_bmp_pauseback; sheet_soundButton = PauseMenu_sheet_soundButton; btn = new Array(); container = new Sprite(); super(); var soundPos:Point = new Point(125, 340); backg = new bmp_pauseback(); container.addChild(backg); var pt:Point = new Point(140, 170); var size:Point = new Point(300, 40); var o:Object = {size:24, font:"futura", embed:true, align:"center", color:0, letterSpace:6}; btn.push(toggleListener(ZoGUI.getStdTextField(size, "CONTINUE", o, pt, container, "backgame"))); btn.push(toggleListener(ZoGUI.getStdTextField(size, "RETRY", o, new Point(pt.x, (pt.y + 30)), container, "retry"))); btn.push(toggleListener(ZoGUI.getStdTextField(size, "HOW TO PLAY", o, new Point(pt.x, (pt.y + 60)), container, "htp"))); btn.push(toggleListener(ZoGUI.getStdTextField(size, "BACK TO MENU", o, new Point(pt.x, (pt.y + 90)), container, "backmenu"))); btn.push(toggleListener(ZoGUI.getStdTextField(size, "ERASE DATA", o, new Point(pt.x, (pt.y + 120)), container, "delete"))); btn.push(toggleListener(ZoGUI.getStdTextField(size, "MORE GAME", o, new Point(pt.x, (pt.y + 150)), container, "more"))); sndFx = new ZoButton(new sheet_soundButton(), new Point(11, 11), "fx", true); container.addChild(sndFx); sndFx.addEventListener(MouseEvent.MOUSE_UP, toggleFx); sndFx.x = 300; sndFx.y = 399; sndMusic = new ZoButton(new sheet_soundButton(), new Point(11, 11), "music", true); container.addChild(sndMusic); sndMusic.addEventListener(MouseEvent.MOUSE_UP, toggleMusic); sndMusic.x = 355; sndMusic.y = sndFx.y; quality_low = new ZoButton(new sheet_btn_glow(), new Point(21, 11), StageQuality.LOW, true); container.addChild(quality_low); quality_low.addEventListener(MouseEvent.MOUSE_UP, quality); quality_low.x = 158; quality_med = new ZoButton(new sheet_btn_gmed(), new Point(35, 11), StageQuality.MEDIUM, true); container.addChild(quality_med); quality_med.addEventListener(MouseEvent.MOUSE_UP, quality); quality_med.x = (quality_low.x + 38); quality_hig = new ZoButton(new sheet_btn_ghig(), new Point(23, 11), StageQuality.HIGH, true); container.addChild(quality_hig); quality_hig.addEventListener(MouseEvent.MOUSE_UP, quality); quality_hig.x = (quality_med.x + 40); quality_hig.y = (quality_med.y = (quality_low.y = 400)); addChild(container); quality(); container.x = ((s.stageWidth / 2) - (container.width / 2)); container.y = ((s.stageHeight / 2) - (container.height / 2)); visible = false; } protected function quality(e:MouseEvent=null):void{ var btn:ZoButton; var qual:String = StageQuality.HIGH; if (e){ qual = e.target.name; }; Global.s.quality = qual; if ((((qual == StageQuality.MEDIUM)) || ((qual == StageQuality.LOW)))){ Global.g.useBg = false; }; if (qual == StageQuality.HIGH){ Global.g.useBg = true; }; switch (qual){ case StageQuality.LOW: btn = quality_low; break; case StageQuality.MEDIUM: btn = quality_med; break; case StageQuality.HIGH: btn = quality_hig; break; }; quality_low.switchAnim(); quality_med.switchAnim(); quality_hig.switchAnim(); btn.switchAnim("mouseOver"); } public function pop(flag:Boolean):void{ var ar:Array; var i:uint; visible = flag; if (Global.lvl.currentLevel == 0){ ar = new Array(1, 0, 1, 0, 1, 1); } else { ar = new Array(1, 1, 1, 1, 1, 1); }; i = 0; while (i < btn.length) { toggleListener(btn[i], ar[i]); i++; }; if (flag){ Global.mouse.symbol.playAnim("menu"); } else { Global.mouse.symbol.playAnim("idle"); }; addChild(container); } protected function out(e:MouseEvent):void{ (e.target as TextField).textColor = 0; } protected function toggleFx(e:MouseEvent):void{ ZoSoundEngine.muting(!(ZoSoundEngine.muteFx), ZoSoundEngine.muteMusic); feedback(); } public function update():void{ var i:uint; i = 0; while (i < btn.length) { btn[i].update(); i++; }; sndFx.update(); sndMusic.update(); } protected function over(e:MouseEvent):void{ (e.target as TextField).textColor = 0xDDDDDD; } protected function toggleMusic(e:MouseEvent):void{ ZoSoundEngine.muting(ZoSoundEngine.muteFx, !(ZoSoundEngine.muteMusic)); feedback(); } protected function button(e:MouseEvent):void{ var unpause:Boolean; switch (e.target.name){ case "backgame": unpause = true; break; case "backmenu": Global.lvl.switchLevel(0); unpause = true; break; case "htp": Global.g.showHtp(); break; case "retry": Global.lvl.resetLevel(true); unpause = true; break; case "delete": Global.g.questionScreen.pop(true); break; case "more": MochiBot.track(this, "5ee274a2", "http://www.ninjakiwi.com/"); break; }; if (unpause){ Global.g.switchState(Game.UNPAUSE); }; PauseMenu.feedback(); } protected function toggleListener(tf:TextField, flag:Boolean=false):TextField{ if (flag){ tf.addEventListener(MouseEvent.MOUSE_OVER, over); tf.addEventListener(MouseEvent.MOUSE_OUT, out); tf.addEventListener(MouseEvent.MOUSE_UP, button); tf.textColor = 0; } else { tf.removeEventListener(MouseEvent.MOUSE_OVER, over); tf.removeEventListener(MouseEvent.MOUSE_OUT, out); tf.removeEventListener(MouseEvent.MOUSE_UP, button); tf.textColor = 0x555555; }; return (tf); } public static function feedback():void{ ZoSoundEngine.getSound("bip").playSound(); } } }//package
Section 141
//PauseMenu_bmp_pauseback (PauseMenu_bmp_pauseback) package { import mx.core.*; public class PauseMenu_bmp_pauseback extends BitmapAsset { } }//package
Section 142
//PauseMenu_sheet_btn_ghig (PauseMenu_sheet_btn_ghig) package { import mx.core.*; public class PauseMenu_sheet_btn_ghig extends BitmapAsset { } }//package
Section 143
//PauseMenu_sheet_btn_glow (PauseMenu_sheet_btn_glow) package { import mx.core.*; public class PauseMenu_sheet_btn_glow extends BitmapAsset { } }//package
Section 144
//PauseMenu_sheet_btn_gmed (PauseMenu_sheet_btn_gmed) package { import mx.core.*; public class PauseMenu_sheet_btn_gmed extends BitmapAsset { } }//package
Section 145
//PauseMenu_sheet_soundButton (PauseMenu_sheet_soundButton) package { import mx.core.*; public class PauseMenu_sheet_soundButton extends BitmapAsset { } }//package
Section 146
//Player (Player) package { import flash.geom.*; import flash.display.*; import zomg.sound.*; import zomg.*; import zomg.tools.*; import flash.ui.*; public class Player extends ZoSprite { protected var jumpButton:Boolean;// = false public var planetLandedOn:Collisionable; protected var planetLandedGapDir:Point; protected var arrow:PlayerArrow; protected var aimTimer:Number;// = 0 public var _collectableZone:Number;// = 0 protected var continueFlying:Number;// = 0 protected var aimTimerColideBox:Number;// = 15 protected var lvl:LevelManager; protected var jumpMouseButton:Boolean;// = false protected var inFrontAngle:Number;// = 20 protected var noMove:Boolean;// = true protected var angleAllow:Number;// = 100 public var planetLandedOnLast:Collisionable; protected var timer:Number;// = 0 protected var _speed:Number;// = 3 protected var collectableZoneImg:Sprite; protected var aimTimerDeath:Number;// = 30 protected var colisionRadius:Number;// = 1 protected var debug:DebugTool; protected var k:ZoKeys; protected var endPos:Point; public var retic:ZoSprite; protected var upgradeMaxSpeed:Number;// = 0 protected var lastCP:Collisionable; protected var dir:Point; public var _state:uint; public var useCamFollow:Boolean;// = true protected var planetsNearMe:Array; protected var rayLength:Number;// = 1500 protected var owner:Sprite; protected var inGame:Boolean;// = false protected var gateButton:Boolean;// = false protected var camButton:Boolean;// = false protected var inExit:Boolean;// = false protected var planetLandedGap:Point; protected static var looseSpeedTimerStep:Number = 30; protected static var collectableZoneStepLoose:Number = 0.3; protected static var collectableZoneStep:Number = 0.5; protected static var looseSpeed:Number = 0.5; protected static var maxSpeed:Number = 10; public static var FLYING:uint = 1; public static var MOVE:uint = 7; public static var JETPACK:uint = 5; public static var IDLE:uint = 0; protected static var initSpeed:Number = 8; public static var EXIT:uint = 4; protected static var collectableZoneMin:Number = 30; public static var DEAD:uint = 2; protected static var addSpeed:Number = 2; public static var sheet_reticule:Class = Player_sheet_reticule; protected static var collectableZoneMax:Number = 60; public static var LANDING:uint = 6; public static var sheet_avatar:Class = Player_sheet_avatar; public static var AIMING:uint = 3; public function Player(owner:Object){ dir = new Point(); collectableZoneImg = new Sprite(); _state = IDLE; name = "PLAYER"; if ((owner as LevelManager)){ inGame = true; this.lvl = (owner as LevelManager); } else { this.owner = (owner as Sprite); }; var size:Point = new Point(40, 30); super(new sheet_avatar(), size, new Point()); symbol.addAnim("idle", size, 22, new Point(0, 0), 5); symbol.addAnim("jump", size, 4, new Point(1, 0), 5); symbol.addAnim("land", size, 6, new Point(2, 0), 2); symbol.addAnim("death", size, 6, new Point(3, 0), 3); debug = new DebugTool(new Point(-5, -30)); addChild(debug); k = new ZoKeys(Global.s, new Array(new ZoKey(Keyboard.SPACE, "jump"), new ZoKey(Keyboard.ENTER, "open"), new ZoKey(87, "menu"), new ZoKey(88, "win"), new ZoKey(83, "die")), "player"); arrow = new PlayerArrow(this); addChild(arrow); aimTimer = looseSpeedTimerStep; retic = new ZoSprite(new sheet_reticule(), new Point(45, 45), new Point(), new Point(), 0, true); retic.name = "PLAYER RETICULE"; retic.mouseChildren = false; mouseChildren = false; state = IDLE; } public function comparePlanetLanded(planet:Collisionable, last:Boolean=false):Boolean{ if ((((planet == planetLandedOnLast)) && (last))){ return (true); }; if (((!(last)) && ((planet == planetLandedOn)))){ return (true); }; return (false); } protected function movePlayer(move:Point):void{ position = new Point((this.x + move.x), (this.y + move.y)); Global.g.moveBg(move); } protected function jump():void{ if (planetLandedOn){ if (planetLandedOn.isGate()){ lvl.updateMeta(); }; }; state = FLYING; if (planetLandedOn){ planetLandedOn.hasToDestroy(); }; if (planetLandedOn){ planetLandedOn.mouseActive = false; }; if (planetLandedOnLast){ planetLandedOnLast.mouseActive = false; }; planetLandedOn = null; } public function set state(v:uint):void{ var planetdir:Point; _state = v; switch (v){ case IDLE: symbol.playAnim("idle"); break; case FLYING: noMove = false; symbol.playAnim("jump"); retic.visible = (arrow.visible = false); arrow.toggle(); speed = initSpeed; symbol.rotation = ZoMathTools.getAngleVector180(dir); fly(); break; case LANDING: if (planetLandedOn){ planetdir = ZoMathTools.getDirectionVec(planetLandedOn.position, position); symbol.rotation = ZoMathTools.getAngleVector180(planetdir); symbol.playAnim("land", 1); }; state = AIMING; break; case AIMING: if (symbol.currentAnim == "jump"){ symbol.playAnim("idle"); }; timer = 0; speed = 0; colisionRadius = 0.1; arrow.visible = true; if (!arrow.active){ arrow.toggle(); }; break; case DEAD: if (!Global.lvl.inMenu()){ Global.globalStats.setAchievement("nbDeath", 1, true); }; ZoSoundEngine.getSound("player_die").playSound(); symbol.playAnim("death", 1); timer = 0; break; case MOVE: if (planetLandedOn){ endPos = planetLandedOn.position; } else { endPos = Global.lvl.endpos; }; break; case EXIT: break; default: trace("Plyr switch state error !"); break; }; } public function stop(p:Collisionable):void{ var dir:Point; var radiusNeeded:Number; var destPt:Point; speed = 0; planetLandedOn = p; if (planetLandedOn.isGate()){ p.clickable(true); state = MOVE; } else { dir = ZoMathTools.getDirectionVec(planetLandedOn.position, position); radiusNeeded = (p.getRadius() + (size.y / 4)); destPt = new Point((p.x + (radiusNeeded * dir.x)), (p.y + (radiusNeeded * dir.y))); position = destPt; planetLandedGap = new Point((x - planetLandedOn.position.x), (y - planetLandedOn.position.y)); state = LANDING; }; } public function updateCam():void{ if (useCamFollow){ Global.g.setCam(position); } else { Global.g.setCam(new Point()); }; } public function get speed():Number{ return (_speed); } protected function aim():void{ var arrowAngle:Number; var planetAngle:Number; var arrowAngleReal:Number; var pt:Point; arrow.update(); dir = arrow.getDir(); var canShoot:Boolean; var dist:Number = 0; if (planetLandedOn){ arrowAngle = arrow.getRotation(); planetAngle = ZoMathTools.getAngleVector(planetLandedOn.position, position); arrowAngleReal = (arrowAngle - planetAngle); if (arrowAngleReal < -180){ arrowAngleReal = (arrowAngleReal + 360); } else { if (arrowAngleReal > 180){ arrowAngleReal = (arrowAngleReal - 360); }; }; arrowAngleReal = Math.abs(arrowAngleReal); if (arrowAngleReal > angleAllow){ canShoot = false; }; }; retic.visible = (arrow.visible = canShoot); if (canShoot){ pt = cursorDestination(); if (pt.length != 0){ dist = ZoMathTools.distance(position, pt); } else { dist = rayLength; }; if (((k.getKeyStateByName("jump")) && (!(jumpButton)))){ jumpButton = true; jump(); } else { if (((!(k.getKeyStateByName("jump"))) && (jumpButton))){ jumpButton = false; }; }; if (((Global.mouse.left) && (!(jumpMouseButton)))){ jumpMouseButton = true; jump(); } else { if (((!(Global.mouse.left)) && (jumpMouseButton))){ jumpMouseButton = false; }; }; retic.position = pt; }; if (dist >= (rayLength - 10)){ retic.visible = false; }; if (planetLandedOn){ if (planetLandedOn.isMoving()){ position = new Point((planetLandedOn.position.x + planetLandedGap.x), (planetLandedOn.position.y + planetLandedGap.y)); }; }; } public function reset(planetOn:Collisionable=null):void{ inExit = false; noMove = true; state = AIMING; collectableZone = collectableZoneMin; planetLandedOnLast = planetOn; planetLandedOn = null; resetDir(); updateCam(); symbol.playAnim("idle"); visible = true; } public function get collectableZone():Number{ return (_collectableZone); } public function isFlying():Boolean{ if (state == FLYING){ return (true); }; return (false); } override public function set position(pt:Point):void{ _position = pt; this.x = pt.x; this.y = pt.y; } protected function endLevel():void{ state = IDLE; Global.lvl.levelDone(); } protected function fly():void{ var move:Point; if (inGame){ if (timer < aimTimerColideBox){ timer++; } else { colisionRadius = 0.5; }; if (((!((state == DEAD))) && (Global.lvl.outOfLevel(this)))){ killPlayer(0.4); }; if (speed < 0){ speed = 0; }; move = new Point((dir.x * speed), (dir.y * speed)); movePlayer(move); }; } public function remove():void{ lvl.removeChild(this); lvl.removeChild(retic); } public function set speed(v:Number):void{ _speed = v; } public function get state():uint{ return (_state); } protected function getPlanetInFront():Array{ var ptangle:Number; var dist:Number; var i:uint; var ar:Array = lvl.getPlanetInFrustrum(); var planet:Array = new Array(); var pt:Point = new Point(); var elmtPos:Point = new Point(); var arrowAngle:Number = ZoMathTools.getVectorAngle(dir); var outplanet:Array = new Array(); i = 0; while (i < ar.length) { if (((!((ar[i] == planetLandedOn))) && (!((ar[i] == planetLandedOnLast))))){ pt = ZoMathTools.getDirectionVec(position, ar[i].position); ptangle = ZoMathTools.getVectorAngle(pt); dist = ZoMathTools.distance(position, ar[i].position); if (ZoMathTools.isNearValue(arrowAngle, ptangle, ZoMathTools.getAdjAngle(dist, ar[i].getRadius()), true)){ if (ar[i] != planetLandedOn){ planet.push(ar[i]); }; }; }; i++; }; return (planet); } public function getColisionPoints():Array{ return (getCirclePoints(colisionRadius, 6)); } public function toggleUseCamera(flag:Boolean=true):void{ useCamFollow = flag; } public function set collectableZone(v:Number):void{ _collectableZone = v; collectableZoneImg.graphics.clear(); collectableZoneImg.graphics.beginFill(0xFF0000, 0.1); collectableZoneImg.graphics.drawCircle(0, 0, collectableZone); collectableZoneImg.graphics.endFill(); } public function setMotion(p:Collisionable, exit:Boolean=false):void{ planetLandedOn = p; state = MOVE; if (exit){ inExit = true; }; } public function resetDir():void{ symbol.rotation = -90; } public function isAlive():Boolean{ if ((((state == FLYING)) || ((state == AIMING)))){ return (true); }; return (false); } public function update():void{ var _local3:Number; var sp:Number; var dir:Point; switch (state){ case IDLE: break; case FLYING: fly(); Global.globalStats.setAchievement("distance", speed, true); break; case AIMING: if (symbol.hasFinishedPlaying("land")){ if (symbol.currentAnim != "idle"){ symbol.playAnim("idle"); }; }; aim(); if (((k.getKeyStateByName("open")) && (!(gateButton)))){ gateButton = true; } else { if (((!(k.getKeyStateByName("open"))) && (gateButton))){ gateButton = false; lvl.gateOpen(); }; }; break; case DEAD: if (symbol.hasFinishedPlaying("death")){ visible = false; timer++; } else { if (continueFlying > 0){ speed = (speed - continueFlying); fly(); }; }; if (timer == aimTimerDeath){ lvl.resetLevel(true); }; break; case MOVE: _local3 = ZoMathTools.distance(position, endPos); if (_local3 > 5){ if (_local3 > 300){ position = endPos; } else { sp = 4; if (planetLandedOn){ if (planetLandedOn.isCP()){ sp = 5; }; }; dir = ZoMathTools.getDirectionVec(position, endPos); movePlayer(new Point((dir.x * sp), (dir.y * sp))); }; } else { if (planetLandedOn){ if (planetLandedOn.isGate()){ planetLandedOnLast = planetLandedOn; planetLandedOn = null; resetDir(); lvl.updateMeta(); state = AIMING; } else { if (planetLandedOn.isCP()){ state = AIMING; } else { if (planetLandedOn.isExit()){ endLevel(); }; }; }; } else { Global.console.addLine("Player > Arrived nowhere DEBUG"); endLevel(); }; }; break; default: trace("PLAYER >> main switch error game state"); break; }; if (Global.isDebug){ if (k.getKeyStateByName("menu")){ Global.lvl.switchLevel(0); } else { if (k.getKeyStateByName("die")){ reset(); }; }; }; updateCam(); symbol.update(); } protected function cursorDestination():Point{ var dist:Number; var close:int; var pt:Point; var i:uint; var ar:Array = getPlanetInFront(); var endPos:Point = ZoMathTools.destinationPoint(position, dir, rayLength); if (ar.length > 0){ dist = 10000; close = -1; i = 0; while (i < ar.length) { if (ZoMathTools.distance(position, ar[i].position) < dist){ dist = ZoMathTools.distance(position, ar[i].position); close = i; }; i++; }; if (close >= 0){ pt = ZoMathTools.circleInter(position, endPos, ar[close].position, ar[close].getRadius()); if (pt.length != 0){ return (pt); }; }; }; return (new Point()); } public function killPlayer(dontstop:Number=0.1):void{ if (state != DEAD){ state = DEAD; continueFlying = dontstop; }; } public function isInvincible():Boolean{ if ((((state == EXIT)) || ((noMove == true)))){ return (true); }; return (false); } protected function touchExit():Boolean{ if (ZoMathTools.distance(position, Global.lvl.endpos) < 50){ return (true); }; return (false); } } }//package
Section 147
//Player_sheet_avatar (Player_sheet_avatar) package { import mx.core.*; public class Player_sheet_avatar extends BitmapAsset { } }//package
Section 148
//Player_sheet_reticule (Player_sheet_reticule) package { import mx.core.*; public class Player_sheet_reticule extends BitmapAsset { } }//package
Section 149
//PlayerArrow (PlayerArrow) package { import flash.geom.*; import zomg.*; import zomg.tools.*; public class PlayerArrow extends ZoSprite { protected var p:Player; protected var _state:uint;// = 0 private var sheet:Class; public static var NO:uint = 1; public static var OK:uint = 0; public function PlayerArrow(plyr:Player){ sheet = PlayerArrow_sheet; p = plyr; name = "PLAYER ARROW"; active = false; var size:Point = new Point(25, 25); super(new sheet(), size, new Point()); symbol.addAnim("yes", size, 1, new Point()); symbol.addAnim("no", size, 1, new Point(0, 1)); addChild(symbol); state = OK; symbol.x = symbol.width; } public function set state(v:uint):void{ switch (v){ case OK: visible = true; symbol.playAnim("yes"); break; case NO: visible = false; symbol.playAnim("no"); break; }; _state = v; } public function getRotation():Number{ if (rotation > 0){ return ((360 - rotation)); }; return (-(rotation)); } public function update():void{ if (active){ rotate(); }; } public function get state():uint{ return (_state); } public function toggle():Boolean{ toggleActive(); if (!active){ update(); }; return (active); } public function getDir():Point{ return (ZoMathTools.normalize(new Point(p.mouseX, p.mouseY))); } protected function rotate():void{ var value:Number = (Math.atan2(p.mouseY, p.mouseX) / (Math.PI / 180)); rotation = value; } } }//package
Section 150
//PlayerArrow_sheet (PlayerArrow_sheet) package { import mx.core.*; public class PlayerArrow_sheet extends BitmapAsset { } }//package
Section 151
//PreloaderAPI (PreloaderAPI) package { import flash.events.*; import flash.display.*; import mochi.as3.*; import flash.utils.*; import zomg.*; import zomg.tools.*; public dynamic class PreloaderAPI extends MovieClip { private var did_load:Boolean; public static var GAME_OPTIONS:Object = {id:"b9b4c93784819402", res:"800x600"}; public static var mochi:Boolean = true; public static var MAIN_CLASS:String = "Main"; public function PreloaderAPI(){ var f:Function; var opts:Object; var k:String; super(); trace(("Preload > API : mochi :" + mochi)); var url:String = this.loaderInfo.loaderURL; var lock:Boolean; trace("Preloader > don't use sitelock"); if (lock){ addChild(new DebugFatalError((("SITE LOCKED !\ndomain: \"" + ZoSitelock.domain) + "\" not allowed."), stage)); } else { if (url.indexOf("kongregate.com") > -1){ new ZoPreloader(this); } else { if (_slot1.mochi){ f = function (ev:IOErrorEvent):void{ }; loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f); opts = {}; for (k in GAME_OPTIONS) { opts[k] = GAME_OPTIONS[k]; }; opts.ad_started = function ():void{ did_load = true; }; opts.ad_finished = function ():void{ var mainClass:Class = Class(getDefinitionByName(MAIN_CLASS)); var app:Object = new (mainClass); addChild((app as DisplayObject)); }; opts.clip = this; if (url.indexOf("ile://")){ opts.skip = true; }; MochiAd.showPreGameAd(opts); } else { new ZoPreloader(this); }; }; }; } } }//package
Section 152
//Question (Question) package { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import zomg.sound.*; import zomg.gui.*; public class Question extends Sprite { protected var timerAim:int;// = 60 protected var no:TextField; protected var timer:int;// = 0 protected var yes:TextField; protected var overColor:uint;// = 0xFFFFFF protected var outColor:uint;// = 0 protected var inactiveColor:uint;// = 0x222222 public static var sheet:Class = Question_sheet; public function Question(size:Point){ super(); addChild(new sheet()); yes = ZoGUI.getStdTextField(new Point(50, 30), "YES", {font:"futura", embed:true, size:25, letterSpace:1, underline:true, bold:true}, new Point(70, 250), this, "yes"); no = ZoGUI.getStdTextField(new Point(50, 30), "NO", {font:"futura", embed:true, size:25, letterSpace:1, underline:true, bold:true}, new Point(145, 250), this, "no"); visible = false; x = 75; y = 30; } protected function toggleListener(tf:TextField, flag:Boolean=false):TextField{ if (flag){ tf.addEventListener(MouseEvent.MOUSE_OVER, over); tf.addEventListener(MouseEvent.MOUSE_OUT, out); tf.addEventListener(MouseEvent.MOUSE_UP, button); tf.textColor = outColor; } else { tf.removeEventListener(MouseEvent.MOUSE_OVER, over); tf.removeEventListener(MouseEvent.MOUSE_OUT, out); tf.removeEventListener(MouseEvent.MOUSE_UP, button); }; return (tf); } public function pop(flag:Boolean=true):void{ var i:uint; timer = 0; if (flag){ toggleListener(yes, true); toggleListener(no, true); Global.mouse.symbol.playAnim("menuWhite"); } else { toggleListener(yes, false); toggleListener(no, false); Global.mouse.symbol.playAnim("idle"); }; visible = flag; } protected function button(e:MouseEvent=null):void{ var unpause:Boolean; var yes:Boolean; if (e){ if (e.target.name == "no"){ yes = false; } else { if (e.target.name == "yes"){ yes = true; }; }; }; PauseMenu.feedback(); pop(false); if (yes){ ZoSoundEngine.getSound("meta_buy").playSound(); Global.globalStats.cookie("clear"); }; } protected function over(e:MouseEvent):void{ (e.target as TextField).textColor = overColor; } protected function out(e:MouseEvent):void{ (e.target as TextField).textColor = outColor; } } }//package
Section 153
//Question_sheet (Question_sheet) package { import mx.core.*; public class Question_sheet extends BitmapAsset { } }//package
Section 154
//ResultScreen (ResultScreen) package { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import api.*; import zomg.gui.*; import com.*; public class ResultScreen extends Sprite { public var lvlNum:int;// = 0 protected var btn_retry:TextField; protected var tf_time_best:TextField; public var newTime:Number;// = 0 public var oldTime:Number;// = 0 protected var tf_cash_current:TextField; public var lvlToBuild:int;// = 0 protected var outColor:uint;// = 0x111111 protected var myMask:Sprite; protected var tf_time_current:TextField; protected var tf_cash_complete:TextField; protected var img:Sprite; private var sheet_back:Class; public var lvlName:String;// = "" protected var btn_more:TextField; protected var becomeClickable:uint;// = 20 protected var tf_time_complete:TextField; protected var tf_cash_best:TextField; protected var mouseDown:Boolean;// = false protected var btn_back:TextField; protected var overColor:uint;// = 0xEEEEEE protected var clickable:uint;// = 0 public var newCash:int;// = 0 protected var tf_lvlNum:TextField; public var oldCash:int;// = 0 public function ResultScreen(){ sheet_back = ResultScreen_sheet_back; img = new Sprite(); myMask = new Sprite(); super(); addChild(new sheet_back()); tf_lvlNum = ZoGUI.getStdTextField(new Point(598, 40), "LVL # COMPLETED", {size:20, font:"futura", embed:true, letterSpace:1, align:"center"}, new Point(0, 155)); addChild(tf_lvlNum); tf_cash_current = ZoGUI.getStdTextField(new Point(200, 35), "0/0", {size:33, font:"grotesque", embed:true}, new Point(210, 328), this); tf_cash_best = ZoGUI.getStdTextField(new Point(200, 40), "0/0", {size:33, font:"grotesque", embed:true}, new Point(380, 328), this); tf_cash_complete = ZoGUI.getStdTextField(new Point(200, 50), "RECORD!", {size:33, font:"grotesque", embed:true, color:0xFFFFFF}, new Point(450, 328), this); tf_time_current = ZoGUI.getStdTextField(new Point(200, 35), "0'00", {size:33, font:"grotesque", letterSpace:1, embed:true}, new Point(210, 398), this); tf_time_best = ZoGUI.getStdTextField(new Point(200, 35), "0'00", {size:33, font:"grotesque", letterSpace:1, embed:true}, new Point(380, 398), this); tf_time_complete = ZoGUI.getStdTextField(new Point(200, 50), "RECORD!", {size:33, font:"grotesque", embed:true, color:0xFFFFFF}, new Point(450, 398), this); btn_retry = ZoGUI.getStdTextField(new Point(100, 30), "RETRY", {size:25, font:"futura", embed:true, letterSpace:1}, new Point(100, 480), this, "retry"); btn_more = ZoGUI.getStdTextField(new Point(200, 30), "MORE GAMES", {size:25, font:"futura", embed:true, letterSpace:1}, new Point((btn_retry.x + 90), 480), this, "more"); btn_back = ZoGUI.getStdTextField(new Point(200, 30), "CONTINUE", {size:25, font:"futura", embed:true, letterSpace:1}, new Point((btn_retry.x + 280), 480), this, "back"); visible = false; } public function init():void{ var cashTotal:int = Global.lvl.getNbCollec(Collectable.CASH, false, true); tf_lvlNum.text = String((((("LEVEL " + lvlNum) + " ") + lvlName) + "\nCOMPLETED !")).toUpperCase(); tf_cash_best.text = (tf_cash_current.text = ((newCash + " / ") + cashTotal)); if (newCash > oldCash){ tf_cash_complete.visible = true; } else { tf_cash_complete.visible = false; tf_cash_best.text = ((oldCash + " / ") + cashTotal); }; tf_time_best.text = (tf_time_current.text = ("" + StopWatch.formatTime(newTime))); if (newTime < oldTime){ tf_time_complete.visible = true; } else { tf_time_best.text = ("" + StopWatch.formatTime(oldTime)); tf_time_complete.visible = false; }; pop(true); } protected function toggleListener(tf:TextField, flag:Boolean=false):TextField{ if (flag){ tf.addEventListener(MouseEvent.MOUSE_OVER, over); tf.addEventListener(MouseEvent.MOUSE_OUT, out); tf.addEventListener(MouseEvent.MOUSE_UP, button); tf.textColor = outColor; } else { tf.removeEventListener(MouseEvent.MOUSE_OVER, over); tf.removeEventListener(MouseEvent.MOUSE_OUT, out); tf.removeEventListener(MouseEvent.MOUSE_UP, button); }; return (tf); } protected function button(e:MouseEvent):void{ var unpause:Boolean; switch (e.target.name){ case "retry": lvlToBuild = lvlNum; break; case "back": lvlToBuild = 0; break; case "more": MochiBot.track(this, "5ee274a2", "http://www.ninjakiwi.com/"); break; }; PauseMenu.feedback(); pop(false); } public function pop(flag:Boolean=false):void{ toggleListener(btn_back, flag); toggleListener(btn_retry, flag); toggleListener(btn_more, flag); if (flag){ Global.mouse.symbol.playAnim("menu"); } else { Global.mouse.symbol.playAnim("idle"); }; visible = flag; } protected function out(e:MouseEvent):void{ (e.target as TextField).textColor = outColor; } protected function over(e:MouseEvent):void{ (e.target as TextField).textColor = overColor; } } }//package
Section 155
//ResultScreen_sheet_back (ResultScreen_sheet_back) package { import mx.core.*; public class ResultScreen_sheet_back extends BitmapAsset { } }//package
Section 156
//Stats (Stats) package { import flash.net.*; public class Stats { public var achivements:Object; public var myState:SharedObject; public var levelUnlocked:Array; public var lastPlayed:int;// = 0 public var name:String;// = "Stats" protected var lastLevelNum:int;// = 0 public var levelDone:Array; public var levelTime:Array; public var used:int;// = 0 public function Stats(){ levelDone = new Array(); levelUnlocked = new Array(); levelTime = new Array(); super(); lastLevelNum = Global.lvl.countLevel(); if (!cookie("load")){ newCookie(); }; } public function getRemaining():int{ return ((getAllCount() - getUsed())); } public function getUsed():int{ var num:int; var i:uint; while (i < levelDone.length) { if (levelUnlocked[i]){ num = (num + Global.lvl.getPrice(i)); }; i++; }; return (num); } public function levelRemain():int{ var num:int; var i:uint = 1; while (i < levelDone.length) { if (levelDone[i] <= 0){ num++; }; i++; }; return (num); } public function allLevelDone():Boolean{ var done:Boolean; var i:uint = 1; var total:int; i = 0; while (i < levelDone.length) { if (levelDone[i] > 0){ total++; }; i++; }; if (Global.kgg){ Global.kgg.k.stats.submit("LevelDone", total); }; trace(("Level done :" + total)); if (total < lastLevelNum){ done = false; }; return (done); } public function newCookie():void{ levelDone = new Array(); levelUnlocked = new Array(); levelTime = new Array(); var i:uint; while (i <= lastLevelNum) { levelDone.push(-1); levelUnlocked.push(false); levelTime.push(999999); i++; }; achivements = {nbDeath:0, lightSun:0, cash:0, distance:0}; lastPlayed = 0; used = 0; Global.console.addLine((((((("New COOKIE ! (nbLvl:" + lastLevelNum) + ",Length:") + levelTime.length) + ",") + levelDone.length) + ")"), "Stats"); cookie("save"); } public function getAllCount():int{ var nb:int; var add:int; var i:int; while (i < levelDone.length) { if (levelDone[i] < 0){ add = 0; } else { add = levelDone[i]; }; nb = (nb + add); i++; }; return (nb); } public function setAchievement(what:String="", value:int=0, incr:Boolean=false):void{ if (what.length > 0){ if (incr){ value = (achivements[what] + value); }; achivements[what] = value; }; } public function getAchievement(what:String=""):String{ return (String(achivements[what])); } public function cookie(fct:String="load"):Boolean{ switch (fct){ case "load": myState = SharedObject.getLocal("OLR_galaxy"); if (myState.data.version){ if (myState.data.version == Global.version){ levelDone = myState.data.levelDone; levelUnlocked = myState.data.levelUnlocked; levelTime = myState.data.levelTime; used = myState.data.used; achivements = myState.data.ach; lastPlayed = myState.data.last; Global.console.addLine((("Cookie valid and loaded (v" + myState.data.version) + ")"), "Stats"); if (allLevelDone()){ Global.g.endScreen.showed = true; }; return (true); } else { Global.console.addLine(("Old version cookie : " + myState.data.version), "Stats"); }; } else { Global.console.addLine("No cookie", "Stats"); }; break; case "save": myState = SharedObject.getLocal("OLR_galaxy"); myState.data.version = Global.version; myState.data.levelDone = levelDone; myState.data.levelUnlocked = levelUnlocked; myState.data.levelTime = levelTime; myState.data.used = used; myState.data.ach = achivements; myState.data.last = lastPlayed; Global.console.addLine("saving cookie", "Stats"); myState.flush(); break; case "clear": if (myState){ newCookie(); Global.g.endScreen.showed = false; Global.g.reset(); Global.lvl.switchLevel(0); Global.console.addLine("Cookie deleted", name); }; break; }; return (false); } } }//package
Section 157
//Unlock (Unlock) package { import flash.events.*; import flash.geom.*; import flash.display.*; import flash.text.*; import zomg.sound.*; import zomg.gui.*; public class Unlock extends Sprite { protected var timerAim:int;// = 60 protected var no:TextField; protected var timer:int;// = 0 protected var need:TextField; protected var planet:Collisionable; protected var enterBtn:Boolean;// = false protected var yes:TextField; protected var overColor:uint;// = 0xDDDDDD protected var outColor:uint;// = 0x888888 protected var inactiveColor:uint;// = 0x222222 public static var sheet_unlock:Class = Unlock_sheet_unlock; public function Unlock(size:Point){ super(); addChild(new sheet_unlock()); need = ZoGUI.getStdTextField(new Point(100, 30), "00", {font:"futura", embed:true, size:25, letterSpace:1, color:0xFFFFFF}, new Point(87, 172), this, "num"); yes = ZoGUI.getStdTextField(new Point(50, 30), "YES", {font:"futura", embed:true, size:25, letterSpace:1, underline:true, bold:true}, new Point(105, 230), this, "yes"); no = ZoGUI.getStdTextField(new Point(50, 30), "NO", {font:"futura", embed:true, size:25, letterSpace:1, underline:true, bold:true}, new Point(185, 230), this, "no"); visible = false; x = ((size.x / 2) - (width / 2)); y = ((size.y / 2) - (height / 2)); } public function pop(pla:Collisionable=null, flag:Boolean=true, canUnlock:Boolean=false):void{ var i:uint; timer = 0; if (flag){ planet = pla; if (canUnlock){ toggleListener(yes, true); stage.addEventListener(KeyboardEvent.KEY_UP, pressOk); } else { yes.textColor = inactiveColor; }; toggleListener(no, true); need.text = String(planet.need); Global.mouse.symbol.playAnim("menuWhite"); } else { toggleListener(yes, false); toggleListener(no, false); stage.removeEventListener(KeyboardEvent.KEY_UP, pressOk); Global.mouse.symbol.playAnim("idle"); }; visible = flag; } protected function over(e:MouseEvent):void{ (e.target as TextField).textColor = overColor; } protected function out(e:MouseEvent):void{ (e.target as TextField).textColor = outColor; } protected function toggleListener(tf:TextField, flag:Boolean=false):TextField{ if (flag){ tf.addEventListener(MouseEvent.MOUSE_OVER, over); tf.addEventListener(MouseEvent.MOUSE_OUT, out); tf.addEventListener(MouseEvent.MOUSE_UP, button); tf.textColor = outColor; } else { tf.removeEventListener(MouseEvent.MOUSE_OVER, over); tf.removeEventListener(MouseEvent.MOUSE_OUT, out); tf.removeEventListener(MouseEvent.MOUSE_UP, button); }; return (tf); } protected function button(e:MouseEvent=null):void{ var unpause:Boolean; var yes:Boolean; if (e){ if (e.target.name == "no"){ yes = false; } else { if (e.target.name == "yes"){ yes = true; }; }; }; if (yes){ ZoSoundEngine.getSound("meta_buy").playSound(); Global.lvl.setPlanetPaid(planet); }; PauseMenu.feedback(); pop(null, false); } protected function pressOk(e:Event):void{ button(); } } }//package
Section 158
//Unlock_sheet_unlock (Unlock_sheet_unlock) package { import mx.core.*; public class Unlock_sheet_unlock extends BitmapAsset { } }//package

Library Items

Symbol 1 Sound {ManagerSound_snd_door_open} [ManagerSound_snd_door_open]
Symbol 2 Sound {ManagerSound_snd_turret_shoot} [ManagerSound_snd_turret_shoot]
Symbol 3 Sound {ManagerSound_track_loop} [ManagerSound_track_loop]
Symbol 4 Sound {ManagerSound_snd_sun_explode} [ManagerSound_snd_sun_explode]
Symbol 5 Sound {ManagerSound_snd_collect_key} [ManagerSound_snd_collect_key]
Symbol 6 Sound {ManagerSound_snd_player_die} [ManagerSound_snd_player_die]
Symbol 7 Sound {ManagerSound_snd_planet_dis} [ManagerSound_snd_planet_dis]
Symbol 8 Sound {ManagerSound_snd_menu_bip} [ManagerSound_snd_menu_bip]
Symbol 9 Sound {ManagerSound_snd_meta_buy} [ManagerSound_snd_meta_buy]
Symbol 10 Sound {ManagerSound_snd_collect} [ManagerSound_snd_collect]
Symbol 11 Bitmap {Collisionable_sheet_p320}
Symbol 12 Bitmap {Enemy_sheet_scan}
Symbol 13 Bitmap {Collisionable_sheet_p20}
Symbol 14 Font {Global_FONT_GROTESQUE}
Symbol 15 Bitmap {PlayerArrow_sheet}
Symbol 16 Bitmap {Collisionable_sheet_exit}
Symbol 17 MovieClip {Game_api_nk}
Symbol 18 Bitmap {Game_sheet_transition}
Symbol 19 Bitmap {Collisionable_sheet_p365}
Symbol 20 Bitmap {Collisionable_sheet_p60}
Symbol 21 Bitmap {Question_sheet}
Symbol 22 Bitmap {Game_sheet_vortex}
Symbol 23 Bitmap {Collectable_sheet_key}
Symbol 24 Bitmap {Collisionable_sheet_logo}
Symbol 25 Bitmap {PauseMenu_sheet_btn_ghig}
Symbol 26 Bitmap {Collisionable_sheet_sun_45_on}
Symbol 27 Bitmap {Game_sheet_meta_cloud}
Symbol 28 Bitmap {Collisionable_sheet_p145}
Symbol 29 Bitmap {Collisionable_editor_bottom}
Symbol 30 Bitmap {Collisionable_sheet_start}
Symbol 31 BinaryData {Game_api_nk_dataClass}
Symbol 32 BinaryData {LevelManager_xmlFile}
Symbol 33 Bitmap {Collisionable_sheet_p10}
Symbol 34 Bitmap {PauseMenu_sheet_btn_glow}
Symbol 35 Bitmap {Unlock_sheet_unlock}
Symbol 36 Bitmap {Enemy_editor_bar}
Symbol 37 Bitmap {Collisionable_editor_end}
Symbol 38 Bitmap {Collisionable_sheet_debug_red}
Symbol 39 Bitmap {Enemy_editor_tracker1}
Symbol 40 Bitmap {EndScreen_screen}
Symbol 41 Bitmap {ResultScreen_sheet_back}
Symbol 42 Bitmap {Collisionable_editor_start}
Symbol 43 Bitmap {Collisionable_editor_top}
Symbol 44 Bitmap {Collectable_sheet_cash}
Symbol 45 Bitmap {Background_sheet_stars}
Symbol 46 Bitmap {HowToPlay_sscreen_htp}
Symbol 47 Font {zomg.olr.OLRLogo_FONT}
Symbol 48 Bitmap {Main_sheet_cursor}
Symbol 49 Bitmap {PauseMenu_sheet_btn_gmed}
Symbol 50 Bitmap {Collisionable_sheet_gate_halo}
Symbol 51 Bitmap {Collisionable_sheet_sun_off}
Symbol 52 Bitmap {Enemy_sheet_tracker}
Symbol 53 Bitmap {Collisionable_sheet_cadenas}
Symbol 54 Bitmap {Collisionable_sheet_p45}
Symbol 55 Bitmap {Enemy_sheet_turret}
Symbol 56 Bitmap {Enemy_sheet_bullet}
Symbol 57 Bitmap {Game_sheet_meta}
Symbol 58 Bitmap {Game_sscreen_sponsor}
Symbol 59 Bitmap {Collisionable_sheet_exp}
Symbol 60 Bitmap {Collisionable_sheet_sun_200_on}
Symbol 61 Bitmap {Player_sheet_reticule}
Symbol 62 Bitmap {Collisionable_sheet_p80}
Symbol 63 Bitmap {Enemy_editor_turret}
Symbol 64 Bitmap {Collisionable_sheet_p170}
Symbol 65 Bitmap {Btn_logo_img}
Symbol 66 Bitmap {Player_sheet_avatar}
Symbol 67 Bitmap {Btn_logo_img2}
Symbol 68 Bitmap {zomg.ZoCursor_sheet_cursor}
Symbol 69 Bitmap {Collisionable_sheet_p120}
Symbol 70 Bitmap {Collisionable_sheet_p30}
Symbol 71 Bitmap {PauseMenu_sheet_soundButton}
Symbol 72 Font {Global_FONT_FUTURA}
Symbol 73 Bitmap {PauseMenu_bmp_pauseback}
Symbol 74 Bitmap {Collisionable_sheet_sun_80_on}
Symbol 75 Bitmap {Enemy_editor_escan}
Symbol 76 Bitmap {Collisionable_sheet_gate}
Symbol 77 Bitmap {Collisionable_sheet_p250}
Symbol 78 Bitmap {Collisionable_sheet_exp_end}
Symbol 79 Bitmap {Collisionable_sheet_p70}

Special Tags

FileAttributes (69)Timeline Frame 1Access network only, Metadata present, AS3.
SWFMetaData (77)Timeline Frame 1458 bytes "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'><rdf:Description rdf:about='' xmlns ..."
ScriptLimits (65)Timeline Frame 1MaxRecursionDepth: 1000, ScriptTimeout: 60 seconds
ExportAssets (56)Timeline Frame 2Symbol 1 as "ManagerSound_snd_door_open"
ExportAssets (56)Timeline Frame 2Symbol 2 as "ManagerSound_snd_turret_shoot"
ExportAssets (56)Timeline Frame 2Symbol 3 as "ManagerSound_track_loop"
ExportAssets (56)Timeline Frame 2Symbol 4 as "ManagerSound_snd_sun_explode"
ExportAssets (56)Timeline Frame 2Symbol 5 as "ManagerSound_snd_collect_key"
ExportAssets (56)Timeline Frame 2Symbol 6 as "ManagerSound_snd_player_die"
ExportAssets (56)Timeline Frame 2Symbol 7 as "ManagerSound_snd_planet_dis"
ExportAssets (56)Timeline Frame 2Symbol 8 as "ManagerSound_snd_menu_bip"
ExportAssets (56)Timeline Frame 2Symbol 9 as "ManagerSound_snd_meta_buy"
ExportAssets (56)Timeline Frame 2Symbol 10 as "ManagerSound_snd_collect"
EnableDebugger2 (64)Timeline Frame 131 bytes "u.$1$pe$uibutF3zby90b4UG11XKc/."
DebugMX1 (63)Timeline Frame 1
SerialNumber (41)Timeline Frame 1

Labels

"PreloaderAPI"Frame 1
"start"Frame 2




http://swfchan.com/19/91103/info.shtml
Created: 28/3 -2019 02:39:30 Last modified: 28/3 -2019 02:39:30 Server time: 24/01 -2021 19:22:46