Section 1
//AnimatedObject (animation.AnimatedObject)
package animation {
import flash.display.*;
import physic.*;
import managers.resources.*;
import managers.objects.*;
import flash.filters.*;
public final class AnimatedObject extends Bitmap implements IAnimatedObject {
private var bNeedUpdate:Boolean;// = false
private var _bLoop:Boolean;// = false
private var position:Vec2;
private var currentAnim:String;// = ""
private var bJustStarted:Boolean;// = false
private var currentSpeedFactor:Number;// = 1
private var bAnimIsPlaying:Boolean;// = false
private var _scaleY:Number;// = 1
private var _scaleX:Number;// = 1
private var _data:AnimatedObjectData;// = null
private var _cosValue:Number;// = 1
private var _dataName:String;// = ""
private var triggerParam:Object;// = null
private var triggerFunction:Function;// = null
private var delta:Vec2;
private var mirror:Boolean;// = false
private var _sinValue:Number;// = 0
private var currentTime:Number;// = 0
private var debugSprite:Sprite;
public function AnimatedObject(name:String=""){
var name = name;
position = Vec2.ZERO;
debugSprite = new Sprite();
delta = new Vec2();
super(null, PixelSnapping.AUTO, true);
setData(name);
if (Physic.SHOW_DEBUG_STUFF){
var _local3 = debugSprite.graphics;
with (_local3) {
clear();
beginFill(0xFF00);
drawCircle(0, 0, 5);
endFill();
};
if (GameLayerManager.getInstance().isInitialized()){
GameLayerManager.getInstance().getLayer(GameLayerManager.LAYER_FOREGROUND_1).addChild(debugSprite);
};
};
}
override public function set rotation(value:Number):void{
super.rotation = value;
var angle:Number = ((super.rotation * Math.PI) / 180);
_cosValue = Math.cos(angle);
_sinValue = Math.sin(angle);
bNeedUpdate = true;
}
private function numberModulo(val:Number, mod:Number):Number{
while (val > mod) {
val = (val - mod);
};
return (val);
}
public function getData():String{
return (_dataName);
}
public function setLoop(loop:Boolean=true):void{
if (loop){
bAnimIsPlaying = true;
};
_bLoop = loop;
bNeedUpdate = true;
}
public function setData(name:String, offset_unused:Vec2=null):void{
_data = null;
_dataName = name;
playAnimIndex(0, false);
}
public function hasAnimNamed(anim:String):Boolean{
if (dataIsBinded()){
return (_data.hasAnimNamed(anim));
};
return (false);
}
private function dataIsBinded():Boolean{
if (((!(_data)) && (!((_dataName == ""))))){
_data = (ResourceManager.getInstance().getResource(_dataName) as AnimatedObjectData);
};
return (!((_data == null)));
}
public function stopAnim():void{
bAnimIsPlaying = false;
}
override public function get scaleY():Number{
return (_scaleY);
}
public function playIdleAnim(anim:String):void{
playAnim(anim, true);
if (dataIsBinded()){
currentTime = (_data.getAnimDuration(currentAnim) * Math.random());
};
}
public function getRelativeDirection(dir:Vec2, ignoreMirror:Boolean=false):Vec2{
if (((mirror) && (!(ignoreMirror)))){
return (new Vec2(-(((dir.x * _cosValue) + (dir.y * _sinValue))), ((dir.y * _cosValue) - (dir.x * _sinValue))));
};
return (new Vec2(((dir.x * _cosValue) - (dir.y * _sinValue)), ((dir.y * _cosValue) + (dir.x * _sinValue))));
}
public function playAnim(anim:String, loop:Boolean=true):void{
if (((!(bAnimIsPlaying)) || (!((currentAnim == anim))))){
currentAnim = anim;
currentTime = 0;
bJustStarted = true;
bAnimIsPlaying = true;
};
_bLoop = loop;
bNeedUpdate = true;
}
override public function get scaleX():Number{
return (_scaleX);
}
public function setTime(time:Number):void{
currentTime = time;
bNeedUpdate = true;
}
public function playAnimIndex(anim:int, loop:Boolean=true):void{
if (dataIsBinded()){
playAnim(_data.getAnimNameByIndex(anim), loop);
};
}
override public function get x():Number{
return (position.x);
}
override public function get y():Number{
return (position.y);
}
public function getCurrentAnimation():String{
return (currentAnim);
}
public function set scale($s:Number):void{
_scaleX = $s;
_scaleY = $s;
bNeedUpdate = true;
}
override public function set scaleX(value:Number):void{
_scaleX = value;
bNeedUpdate = true;
}
public function isPlaying():Boolean{
return (bAnimIsPlaying);
}
override public function set scaleY(value:Number):void{
_scaleY = value;
bNeedUpdate = true;
}
public function getAnchor(name:String):Vec2{
var origin:Vec2;
var p:Vec2;
if (dataIsBinded()){
origin = _data.getAnchor("origin", currentAnim, currentTime);
p = _data.getAnchor(name, currentAnim, currentTime).clone();
if (mirror){
delta.x = ((origin.x - p.x) * _scaleX);
} else {
delta.x = ((p.x - origin.x) * _scaleX);
};
delta.y = ((p.y - origin.y) * _scaleY);
p.x = (position.x + ((delta.x * _cosValue) - (delta.y * _sinValue)));
p.y = (position.y + ((delta.y * _cosValue) + (delta.x * _sinValue)));
return (p);
};
return (null);
}
public function setSpeedFactor(factor:Number):void{
currentSpeedFactor = factor;
}
public function setMirror(b:Boolean):void{
mirror = b;
bNeedUpdate = true;
}
public function getMirror():Boolean{
return (mirror);
}
public function update(timeElapsed:Number, skipVisual:Boolean=false, skipTriggers:Boolean=false):void{
var playedThisFrame:Boolean;
var animDuration:Number;
var elapsedTime:Number;
var offset:Vec2;
var origin:Vec2;
var bitmap:BitmapData;
if (((dataIsBinded()) && (bNeedUpdate))){
playedThisFrame = false;
if (bAnimIsPlaying){
playedThisFrame = true;
animDuration = _data.getAnimDuration(currentAnim);
if (animDuration == 0){
return;
};
elapsedTime = (timeElapsed * currentSpeedFactor);
currentTime = (currentTime + elapsedTime);
if (_bLoop){
currentTime = numberModulo(currentTime, animDuration);
} else {
if (currentTime > animDuration){
currentTime = animDuration;
bNeedUpdate = false;
bAnimIsPlaying = false;
};
};
};
if (!skipVisual){
bitmap = _data.getBitmapData(currentAnim, currentTime);
if (super.bitmapData != bitmap){
super.bitmapData = bitmap;
};
};
offset = _data.getOffset(currentAnim, currentTime);
origin = _data.getAnchor("origin", currentAnim, currentTime);
if (mirror){
delta.x = ((origin.x - offset.x) * _scaleX);
super.scaleX = -(_scaleX);
} else {
delta.x = ((offset.x - origin.x) * _scaleX);
super.scaleX = _scaleX;
};
delta.y = ((offset.y - origin.y) * _scaleY);
super.scaleY = _scaleY;
super.x = (position.x + ((delta.x * _cosValue) - (delta.y * _sinValue)));
super.y = (position.y + ((delta.y * _cosValue) + (delta.x * _sinValue)));
debugSprite.alpha = 0.6;
debugSprite.x = position.x;
debugSprite.y = position.y;
if (!skipTriggers){
if (((!((triggerFunction == null))) && (playedThisFrame))){
_data.checkTriggers(this, currentAnim, elapsedTime, currentTime, bJustStarted, triggerFunction, triggerParam);
};
};
bJustStarted = false;
};
}
public function getCurrentTime():Number{
return (currentTime);
}
override public function set visible(value:Boolean):void{
super.visible = value;
bNeedUpdate = true;
}
public function setTriggerFunction(fn:Function=null, param:Object=null):void{
triggerFunction = fn;
triggerParam = param;
}
override public function set y(_y:Number):void{
position.y = _y;
bNeedUpdate = true;
}
public function hasAnchor(name:String):Boolean{
if (dataIsBinded()){
return (_data.hasAnchor(name, currentAnim, currentTime));
};
return (false);
}
override public function set x(_x:Number):void{
position.x = _x;
bNeedUpdate = true;
}
override public function set bitmapData(_b:BitmapData):void{
throw ("You can't set bitmapData directly, use AnimatedObject.setData()");
}
public function destroy():void{
_dataName = "";
_data = null;
super.bitmapData = null;
if (Physic.SHOW_DEBUG_STUFF){
if (debugSprite.parent){
debugSprite.parent.removeChild(debugSprite);
};
};
}
public static function updateAnimation(obj:DisplayObject, deltaTime:Number):void{
var i:int;
if ((obj is AnimatedObject)){
(obj as AnimatedObject).update(deltaTime);
} else {
if ((obj is DisplayObjectContainer)){
i = 0;
while (i < (obj as DisplayObjectContainer).numChildren) {
updateAnimation((obj as DisplayObjectContainer).getChildAt(i), deltaTime);
i++;
};
};
};
}
}
}//package animation
Section 2
//AnimatedObjectData (animation.AnimatedObjectData)
package animation {
import debug.*;
import flash.display.*;
import physic.*;
import managers.resources.*;
public final class AnimatedObjectData implements ICompiledResource {
private var animationList:Array;
public var debugString:String;// = ""
public function AnimatedObjectData(){
animationList = new Array();
super();
}
public function checkTriggers(thisObject:AnimatedObject, animId:String, elapsedTime:Number, currentTime:Number, bJustStarted:Boolean, callback:Function, param:Object):void{
var anim:Animation;
if (callback != null){
anim = getAnimation(animId);
if (anim){
anim.checkTriggers(thisObject, elapsedTime, currentTime, bJustStarted, callback, param);
};
};
}
public function getAnimNameByIndex(animId:int):String{
if ((((animId >= 0)) && ((animId < animationList.length)))){
return ((animationList[animId] as Animation).name);
};
return ("");
}
public function toString():String{
var iterator:Animation;
var totalSize:uint;
var frameCount:int;
var str:String = "";
for each (iterator in animationList) {
str = (str + (((iterator.name + "[") + iterator.totalFrames) + "] "));
frameCount = (frameCount + iterator.totalFrames);
totalSize = (totalSize + iterator.debugGetSize());
};
str = (str + (((("\n TOTAL IMAGE COUNT = [" + frameCount) + "] ") + Math.ceil((totalSize / 0x0400))) + " KB"));
return (str);
}
private function getAnimation(animId:String):Animation{
var iterator:Animation;
for each (iterator in animationList) {
if (iterator.name == animId){
return (iterator);
};
};
return (null);
}
public function hasAnchor(name:String, animId:String, animTime:Number):Boolean{
var anim:Animation = getAnimation(animId);
if (anim){
return (anim.hasAnchor(name, animTime));
};
return (false);
}
public function getOffset(animId:String, animTime:Number):Vec2{
var anim:Animation = getAnimation(animId);
if (anim){
return (anim.getImageOffset(animTime));
};
return (AnimationAnchor.DEFAULT);
}
public function getAnchor(name:String, animId:String, animTime:Number):Vec2{
var anim:Animation = getAnimation(animId);
if (anim){
return (anim.getAnchor(name, animTime));
};
return (AnimationAnchor.DEFAULT);
}
public function hasAnimNamed(animId:String):Boolean{
var iterator:Animation;
for each (iterator in animationList) {
if (iterator.name == animId){
return (true);
};
};
return (false);
}
public function getBitmapData(animId:String, animTime:Number):BitmapData{
var anim:Animation = getAnimation(animId);
if (anim){
return (anim.getImage(animTime));
};
return (null);
}
public function serialization():void{
}
public function destroy():void{
while (animationList.length > 0) {
(animationList.pop() as Animation).destroy();
};
}
public function getAnimDuration(animId:String):Number{
var anim:Animation = getAnimation(animId);
if (anim){
return (anim.getDuration());
};
return (0);
}
public function deserialization():void{
}
public function createFromMovieClipArray(resourceName:String, obj:DisplayObject, sceneIndex:int, $stage:Stage):Boolean{
if (!((!((obj == null))) && ((obj is MovieClip)))){
return (false);
};
var mc:MovieClip = (obj as MovieClip);
if (sceneIndex >= mc.scenes.length){
return (false);
};
var s:Scene = mc.currentScene;
var anim:Animation = new Animation(resourceName, mc, s.numFrames, s.name, this, $stage);
animationList.push(anim);
mc.nextScene();
mc.stop();
return (true);
}
}
}//package animation
Section 3
//Animation (animation.Animation)
package animation {
import debug.*;
import flash.display.*;
import physic.*;
import flash.geom.*;
public final class Animation {
public var totalFrames:int;// = 0
public var name:String;// = ""
public var frameArray:Array;
public var duration:Number;// = 0
public var imageArray:Array;
public function Animation(resourceName:String, mc:MovieClip, frameCount:int, animName:String, animatedObjectData:AnimatedObjectData, $stage:Stage){
var frameRate:Number;
var yo:AnimationFrame;
var frame:AnimationFrame;
var pos3:Point;
var pos5:Point;
var temp:BitmapData;
var unique:Boolean;
var lbl:FrameLabel;
var q:int;
var i:int;
var iterator:BitmapData;
var w:MovieClip;
var optimizedFrame:AnimationFrame;
var currentFrame:AnimationFrame;
imageArray = new Array();
frameArray = new Array();
super();
var matrix:Matrix = new Matrix();
frameRate = mc.loaderInfo.frameRate;
var currentTime:Number = 0;
var currentFrameStartTime:Number = 0;
var currentFrameDurationTime:Number = 0;
var currentFrameImageIndex:int;
var currentFrameLabel:String;
var timeBetweenFrames:Number = (1 / frameRate);
var previousIndex:int;
var tempFrameList:Array = new Array();
var k:int;
while (k < frameCount) {
frame = new AnimationFrame();
tempFrameList.push(frame);
frame.startTime = currentTime;
frame.duration = timeBetweenFrames;
matrix = mc.transform.concatenatedMatrix.clone();
matrix.invert();
pos3 = matrix.transformPoint(new Point((mc.transform.pixelBounds.x - 20), (mc.transform.pixelBounds.y - 20)));
pos5 = matrix.transformPoint(new Point(((mc.transform.pixelBounds.x + mc.transform.pixelBounds.width) + 20), ((mc.transform.pixelBounds.y + mc.transform.pixelBounds.height) + 20)));
matrix.identity();
matrix.translate(-(pos3.x), -(pos3.y));
temp = null;
if (((((pos5.x - pos3.x) > 0)) && (((pos5.y - pos3.y) > 0)))){
temp = new BitmapData((pos5.x - pos3.x), (pos5.y - pos3.y), true, 0xFFFFFF);
temp.draw(mc, matrix, null, null, null, true);
} else {
animatedObjectData.debugString = (animatedObjectData.debugString + "WARNING: FRAME SIZE IS NULL\n");
Debug.warning("WARNING: FRAME SIZE IS NULL", resourceName, animName);
};
unique = true;
if (temp != null){
i = 0;
while (i < imageArray.length) {
iterator = (imageArray[i] as AnimationImage).bitmapData;
if (iterator != null){
if (temp.compare(iterator) == 0){
unique = false;
frame.imageIndex = i;
break;
};
};
i++;
};
};
if (unique){
frame.imageIndex = imageArray.length;
imageArray.push(new AnimationImage(temp, new Vec2(pos3.x, pos3.y)));
};
for each (lbl in mc.currentLabels) {
if ((lbl.frame - 1) == k){
frame.label = lbl.name;
};
};
q = 0;
while (q < mc.numChildren) {
w = (mc.getChildAt(q) as MovieClip);
if (w != null){
frame.addAnchor(new AnimationAnchor(w.name, w.x, w.y));
};
q++;
};
currentTime = (currentTime + timeBetweenFrames);
if ((k + 1) < frameCount){
mc.nextFrame();
};
k++;
};
duration = currentTime;
optimizedFrame = null;
for each (currentFrame in tempFrameList) {
if (optimizedFrame == null){
optimizedFrame = currentFrame;
} else {
if (((((!((currentFrame.label == null))) || (!((currentFrame.imageIndex == optimizedFrame.imageIndex))))) || (!(currentFrame.compareAnchors(optimizedFrame))))){
frameArray.push(optimizedFrame);
optimizedFrame = currentFrame;
} else {
optimizedFrame.duration = (optimizedFrame.duration + currentFrame.duration);
};
};
};
frameArray.push(optimizedFrame);
while (tempFrameList.length > 0) {
tempFrameList.pop();
};
totalFrames = frameArray.length;
name = animName;
animatedObjectData.debugString = (animatedObjectData.debugString + (((((((("\n ANIMATION name[" + name) + "] totalFrames[") + totalFrames) + "] totalImages[") + imageArray.length) + "] duration[") + Math.round((duration * 1000))) + "]\n"));
for each (yo in frameArray) {
animatedObjectData.debugString = (animatedObjectData.debugString + ((" " + yo) + "\n"));
};
frameArray.reverse();
}
private function getFrameIndex(time:Number):int{
var i:int;
while (i < frameArray.length) {
if (frameArray[i].startTime <= time){
return (i);
};
i++;
};
return (-1);
}
public function checkTriggers(thisObject:AnimatedObject, elapsedTime:Number, currentTime:Number, bJustStarted:Boolean, callback:Function, param:Object):void{
var a:int;
var b:int;
if (elapsedTime >= duration){
a = frameArray.length;
b = 0;
} else {
a = (bJustStarted) ? frameArray.length : getFrameIndex(numberModulo((currentTime - elapsedTime), duration));
b = getFrameIndex(currentTime);
};
var cur:int = a;
if (cur != b){
do {
cur = (((cur - 1) + frameArray.length) % frameArray.length);
if (frameArray[cur].label != null){
callback(thisObject, this.name, frameArray[cur].label, param);
};
} while (cur != b);
};
}
public function debugGetSize():uint{
var img:AnimationImage;
var i:uint;
for each (img in imageArray) {
if (img.bitmapData){
i = (i + ((img.bitmapData.width * img.bitmapData.height) * 4));
};
};
return (i);
}
public function getImage(time:Number):BitmapData{
return ((imageArray[getFrame(time).imageIndex] as AnimationImage).bitmapData);
}
public function getImageOffset(time:Number):Vec2{
return ((imageArray[getFrame(time).imageIndex] as AnimationImage).offset);
}
private function getOrigin(mc:MovieClip):void{
var w:MovieClip;
var str:String = "";
str = (str + (("MC num [" + mc.numChildren) + "] "));
var first:Boolean;
str = (str + "[");
var q:int;
while (q < mc.numChildren) {
w = (mc.getChildAt(q) as MovieClip);
if (w != null){
if (!first){
str = (str + ", ");
};
str = (str + (((((w.name + "(") + w.x) + ",") + w.y) + ")"));
first = false;
};
q++;
};
str = (str + "]");
Debug.trace(str);
}
public function hasAnchor(name:String, time:Number):Boolean{
return (getFrame(time).hasAnchor(name));
}
public function getDuration():Number{
return (duration);
}
public function getAnchor(name:String, time:Number):Vec2{
return (getFrame(time).getAnchor(name));
}
private function getFrame(time:Number):AnimationFrame{
var frame:AnimationFrame;
for each (frame in frameArray) {
if (frame.startTime <= time){
return (frame);
};
};
return (null);
}
public function destroy():void{
while (imageArray.length > 0) {
(imageArray.pop() as AnimationImage).destroy();
};
}
private function numberModulo(v:Number, m:Number):Number{
while (v < 0) {
v = (v + m);
};
while (v >= m) {
v = (v - m);
};
return (v);
}
}
}//package animation
Section 4
//AnimationAnchor (animation.AnimationAnchor)
package animation {
import physic.*;
final class AnimationAnchor {
public var position:Vec2;
public var name:String;
public static const DEFAULT:Vec2 = new Vec2(0, 0);
function AnimationAnchor(n:String, x:Number, y:Number){
position = new Vec2(0, 0);
super();
name = n;
position.x = x;
position.y = y;
}
}
}//package animation
Section 5
//AnimationConversionTool (animation.AnimationConversionTool)
package animation {
import flash.events.*;
import debug.*;
import flash.display.*;
import managers.resources.*;
public final class AnimationConversionTool extends Sprite {
private var _movieClip:MovieClip;
private var _sceneIndex:int;
private var _animatedObjectData:AnimatedObjectData;
private var _resource:Resource;
private var id:int;// = 0
private static var uid:int = 0;
private static var lockFrame:int = 0;
public function AnimationConversionTool(mc:MovieClip, resource:Resource){
super();
id = ++uid;
mc.stop();
this.visible = false;
_resource = resource;
_animatedObjectData = new AnimatedObjectData();
_movieClip = mc;
_sceneIndex = 0;
this.addChild(_movieClip);
this.addEventListener(Event.ADDED_TO_STAGE, addedToStage);
}
private function addedToStage(event:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
this.stage.addEventListener(Event.ENTER_FRAME, enterFrame);
}
private function enterFrame(event:Event):void{
var b:Boolean;
if ((((lockFrame == 0)) || ((lockFrame == id)))){
lockFrame = id;
b = _animatedObjectData.createFromMovieClipArray(_resource._id, _movieClip, _sceneIndex, this.stage);
_sceneIndex++;
if (!b){
_resource._loader = null;
_resource._data = _animatedObjectData;
_resource._isLoaded = true;
_animatedObjectData.debugString = ((((("Compiled AnimatedObjectData : " + _resource._id) + " ") + _animatedObjectData) + "\n\n") + _animatedObjectData.debugString);
DebugFileWriter.SaveFile((("debug/animatedObjectData_" + _resource._id) + ".txt"), _animatedObjectData.debugString);
this.stage.removeEventListener(Event.ENTER_FRAME, enterFrame);
this.removeChild(_movieClip);
this.parent.removeChild(this);
_movieClip = null;
_animatedObjectData = null;
lockFrame = 0;
};
};
}
}
}//package animation
Section 6
//AnimationFrame (animation.AnimationFrame)
package animation {
import physic.*;
final class AnimationFrame {
private var anchorList:Array;
public var duration:Number;// = 0
public var startTime:Number;// = 0
public var imageIndex:int;// = 0
public var label:String;// = null
function AnimationFrame(){
anchorList = new Array();
super();
}
public function Debug_GetAnchorList():Array{
var iterator:AnimationAnchor;
var list:Array = [];
for each (iterator in anchorList) {
list.push(iterator.name);
};
return (list);
}
public function hasAnchor(name:String):Boolean{
var iterator:AnimationAnchor;
for each (iterator in anchorList) {
if (iterator.name == name){
return (true);
};
};
return (false);
}
public function getAnchor(name:String):Vec2{
var iterator:AnimationAnchor;
for each (iterator in anchorList) {
if (iterator.name == name){
return (iterator.position);
};
};
return (AnimationAnchor.DEFAULT);
}
public function toString():String{
var a:AnimationAnchor;
var s:String = ((((((("FRAME startTime=" + Math.round((startTime * 1000))) + " duration=") + Math.round((duration * 1000))) + " imageIndex=") + imageIndex) + " label=") + label);
for each (a in anchorList) {
s = (s + ((((((" [" + a.name) + " ") + Math.round(a.position.x)) + ",") + Math.round(a.position.y)) + "]"));
};
return (s);
}
public function compareAnchors(otherFrame:AnimationFrame):Boolean{
var anchor:AnimationAnchor;
if (this.anchorList.length != otherFrame.anchorList.length){
return (false);
};
for each (anchor in otherFrame.anchorList) {
if (((!((this.getAnchor(anchor.name).x == anchor.position.x))) || (!((this.getAnchor(anchor.name).y == anchor.position.y))))){
return (false);
};
};
return (true);
}
public function addAnchor(anchor:AnimationAnchor):void{
anchorList.push(anchor);
}
}
}//package animation
Section 7
//AnimationImage (animation.AnimationImage)
package animation {
import flash.display.*;
import physic.*;
public final class AnimationImage {
public var bitmapData:BitmapData;
public var offset:Vec2;
public function AnimationImage(data:BitmapData, pos:Vec2){
super();
bitmapData = data;
offset = pos;
}
public function destroy():void{
bitmapData.dispose();
bitmapData = null;
offset = null;
}
}
}//package animation
Section 8
//IAnimatedObject (animation.IAnimatedObject)
package animation {
import physic.*;
public interface IAnimatedObject extends IDisplayableObject {
function getCurrentAnimation():String;
function isPlaying():Boolean;
function playAnim(_arg1:String, _arg2:Boolean=true):void;
function update(_arg1:Number, _arg2:Boolean=false, _arg3:Boolean=false):void;
function getAnchor(void:String):Vec2;
function playAnimIndex(_arg1:int, _arg2:Boolean=true):void;
function hasAnimNamed(anim:String):Boolean;
function hasAnchor(anim:String):Boolean;
function getCurrentTime():Number;
function stopAnim():void;
function setSpeedFactor(:Number):void;
function setTriggerFunction(_arg1:Function=null, _arg2:Object=null):void;
}
}//package animation
Section 9
//IDisplayableObject (animation.IDisplayableObject)
package animation {
import physic.*;
public interface IDisplayableObject {
function getData():String;
function setMirror(:Boolean):void;
function set rotation(:Number):void;
function set visible(:Boolean):void;
function get rotation():Number;
function get y():Number;
function set scaleX(:Number):void;
function setData(_arg1:String, _arg2:Vec2=null):void;
function set scaleY(:Number):void;
function get scaleX():Number;
function get scaleY():Number;
function set x(:Number):void;
function set y(:Number):void;
function set scale(:Number):void;
function getMirror():Boolean;
function get x():Number;
function get visible():Boolean;
function destroy():void;
function set alpha(:Number):void;
function get alpha():Number;
}
}//package animation
Section 10
//Image (animation.Image)
package animation {
import flash.display.*;
import physic.*;
import flash.geom.*;
import managers.resources.*;
public final class Image extends Bitmap implements IDisplayableObject {
private var _position:Vec2;
private var _data:ImageData;// = null
private var _cosValue:Number;// = 1
private var _offset:Vec2;
private var _dataName:String;// = ""
private var _sinValue:Number;// = 0
private var _mirror:Boolean;// = false
private var _scaleX:Number;// = 1
private var _scaleY:Number;// = 1
public function Image(name:String="", offset:Vec2=null){
_position = new Vec2();
_offset = new Vec2();
super();
setData(name, offset);
}
override public function get y():Number{
return (_position.y);
}
override public function set y(_y:Number):void{
_position.y = _y;
update();
}
public function debugShowMask(alphaThreshold:int=0):void{
var u:int;
var pixel:uint;
var v:int;
while (v < _data.bitmapData.height) {
u = 0;
while (u < _data.bitmapData.width) {
pixel = _data.bitmapData.getPixel32(u, v);
_data.bitmapData.setPixel32(u, v, ((((pixel >> 24) & 0xFF))>alphaThreshold) ? 4294967295 : 0);
u++;
};
v++;
};
}
override public function set bitmapData(_b:BitmapData):void{
throw ("You can't set bitmapData directly, use Image.setData()");
}
override public function set rotation(value:Number):void{
super.rotation = value;
var angle:Number = ((super.rotation * Math.PI) / 180);
_cosValue = Math.cos(angle);
_sinValue = Math.sin(angle);
update();
}
public function set scale($s:Number):void{
_scaleX = $s;
_scaleY = $s;
update();
}
public function setOffset(offset:Vec2):void{
_offset.x = offset.x;
_offset.y = offset.y;
update();
}
override public function set scaleX(_s:Number):void{
_scaleX = _s;
update();
}
override public function set scaleY(_s:Number):void{
_scaleY = _s;
update();
}
public function getData():String{
return (_dataName);
}
public function setData(name:String, offset:Vec2=null):void{
if (((name) && (!((name == ""))))){
if (name == _dataName){
return;
};
_data = (ResourceManager.getInstance().getResource(name) as ImageData);
if (_data){
if (offset){
_offset.x = offset.x;
_offset.y = offset.y;
} else {
_offset.x = (-(_data.bitmapData.width) / 2);
_offset.y = (-(_data.bitmapData.height) / 2);
};
_dataName = name;
super.bitmapData = _data.bitmapData;
update();
return;
} else {
trace("Invalid Image Data:", name);
};
};
super.bitmapData = null;
_data = null;
_dataName = "";
}
override public function get height():Number{
return (super.height);
}
public function getMirror():Boolean{
return (_mirror);
}
public function hitPoint(pos:Vec2, alphaThreshold:int=0):Boolean{
var texelPosition:Point;
var pixelAlphaValue:uint;
if (_data){
texelPosition = this.globalToLocal(pos.toPoint());
pixelAlphaValue = ((super.bitmapData.getPixel32(texelPosition.x, texelPosition.y) >> 24) & 0xFF);
return ((pixelAlphaValue > alphaThreshold));
};
return (false);
}
public function setMirror(b:Boolean):void{
_mirror = b;
update();
}
override public function get width():Number{
return (super.width);
}
private function update():void{
if (_mirror){
super.x = (_position.x - (((-(_offset.x) * _scaleX) * _cosValue) - ((_offset.y * _scaleY) * _sinValue)));
super.y = (_position.y + (((_offset.y * _scaleY) * _cosValue) + ((-(_offset.x) * _scaleX) * _sinValue)));
super.scaleX = -(_scaleX);
} else {
super.x = (_position.x + (((_offset.x * _scaleX) * _cosValue) - ((_offset.y * _scaleY) * _sinValue)));
super.y = (_position.y + (((_offset.y * _scaleY) * _cosValue) + ((_offset.x * _scaleX) * _sinValue)));
super.scaleX = _scaleX;
};
super.scaleY = _scaleY;
}
override public function set visible(value:Boolean):void{
super.visible = value;
}
override public function set x(_x:Number):void{
_position.x = _x;
update();
}
override public function get x():Number{
return (_position.x);
}
public function destroy():void{
super.bitmapData = null;
_data = null;
_dataName = "";
}
}
}//package animation
Section 11
//ImageConversionTool (animation.ImageConversionTool)
package animation {
import flash.events.*;
import flash.display.*;
import managers.resources.*;
public final class ImageConversionTool extends Sprite {
private var _imageData:ImageData;// = null
private var _resource:Resource;
private var _bitmap:Bitmap;// = null
public function ImageConversionTool(bmp:Bitmap, resource:Resource){
super();
this.visible = false;
_resource = resource;
_imageData = new ImageData();
_bitmap = bmp;
this.addEventListener(Event.ADDED_TO_STAGE, addedToStage);
}
private function enterFrame(event:Event):void{
_imageData.bitmapData = _bitmap.bitmapData;
if (_resource._loader){
(_resource._loader as Loader).unload();
_resource._loader = null;
};
_resource._data = _imageData;
_resource._isLoaded = true;
this.stage.removeEventListener(Event.ENTER_FRAME, enterFrame);
this.parent.removeChild(this);
_imageData = null;
}
private function addedToStage(event:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
this.stage.addEventListener(Event.ENTER_FRAME, enterFrame);
}
}
}//package animation
Section 12
//ImageData (animation.ImageData)
package animation {
import flash.display.*;
import managers.resources.*;
final class ImageData implements ICompiledResource {
public var bitmapData:BitmapData;// = null
function ImageData(){
super();
}
public function getBitmapWidth():int{
return ((bitmapData) ? bitmapData.width : 0);
}
public function getBitmapHeight():int{
return ((bitmapData) ? bitmapData.height : 0);
}
public function destroy():void{
bitmapData.dispose();
bitmapData = null;
}
}
}//package animation
Section 13
//SwfAnimation (animation.SwfAnimation)
package animation {
import debug.*;
import flash.display.*;
import physic.*;
public final class SwfAnimation {
public var name:String;// = ""
public var frameArray:Array;
public var totalFrames:int;// = 0
public var duration:Number;// = 0
public static var debugExcludedList:Array = [];
public function SwfAnimation(resourceName:String, mc:MovieClip, frameCount:int, animName:String, swfObjectData:SwfObjectData, validAnchorNameList:Array){
var frameRate:Number;
var yo:AnimationFrame;
var frame:AnimationFrame;
var lbl:FrameLabel;
var q:int;
var w:MovieClip;
var excludedName:String;
frameArray = new Array();
super();
frameRate = mc.loaderInfo.frameRate;
var currentTime:Number = 0;
var currentFrameStartTime:Number = 0;
var currentFrameDurationTime:Number = 0;
var currentFrameImageIndex:int;
var currentFrameLabel:String;
var timeBetweenFrames:Number = (1 / frameRate);
var previousIndex:int;
var k:int;
while (k < frameCount) {
frame = new AnimationFrame();
frameArray.push(frame);
frame.startTime = currentTime;
frame.duration = timeBetweenFrames;
frame.imageIndex = (k + 1);
for each (lbl in mc.currentLabels) {
if ((lbl.frame - 1) == k){
frame.label = lbl.name;
};
};
q = 0;
while (q < mc.numChildren) {
w = (mc.getChildAt(q) as MovieClip);
if (w != null){
if (validateName(validAnchorNameList, w.name)){
frame.addAnchor(new AnimationAnchor(w.name, w.x, w.y));
} else {
excludedName = "instance";
if (w.name.indexOf(excludedName) < 0){
if (debugExcludedList.indexOf(w.name) < 0){
debugExcludedList.push(w.name);
};
};
};
};
q++;
};
currentTime = (currentTime + timeBetweenFrames);
if ((k + 1) < frameCount){
mc.nextFrame();
};
k++;
};
duration = currentTime;
totalFrames = frameArray.length;
name = animName;
swfObjectData.debugString = (swfObjectData.debugString + (((((("\n ANIMATION name[" + name) + "] totalFrames[") + totalFrames) + "] duration[") + Math.round((duration * 1000))) + "]\n"));
for each (yo in frameArray) {
swfObjectData.debugString = (swfObjectData.debugString + ((" " + yo) + "\n"));
};
frameArray.reverse();
}
public function Debug_GetTriggerList():Array{
var list:Array = [];
var i:int = (frameArray.length - 1);
while (i >= 0) {
if (((frameArray[i].label) && (!((frameArray[i].label == ""))))){
list.push((((frameArray[i].label + " [Frame ") + ((frameArray.length - i) - 1)) + "]"));
};
i--;
};
return (list);
}
private function validateName(validAnchorNameList:Array, name:String):Boolean{
var excludedName:String;
if (validAnchorNameList == null){
excludedName = "instance";
if (name.indexOf(excludedName) >= 0){
return (false);
};
return (true);
};
return ((validAnchorNameList.indexOf(name) >= 0));
}
private function getFrameIndex(time:Number):int{
var i:int;
while (i < frameArray.length) {
if (frameArray[i].startTime <= time){
return (i);
};
i++;
};
return (-1);
}
public function checkTriggers(thisObject:SwfObject, elapsedTime:Number, currentTime:Number, bJustStarted:Boolean, callback:Function, param:Object):void{
var a:int;
var b:int;
if (elapsedTime >= duration){
a = frameArray.length;
b = 0;
} else {
a = (bJustStarted) ? frameArray.length : getFrameIndex(numberModulo((currentTime - elapsedTime), duration));
b = getFrameIndex(currentTime);
};
var cur:int = a;
if (cur != b){
do {
cur = (((cur - 1) + frameArray.length) % frameArray.length);
if (frameArray[cur].label != null){
callback(thisObject, this.name, frameArray[cur].label, param);
};
} while (cur != b);
};
}
public function Debug_GetTimeFromFrame(frame:int):Number{
if ((((frame < frameArray.length)) && ((frame > 0)))){
return (frameArray[((frameArray.length - frame) - 1)].startTime);
};
return (0);
}
public function getImage(time:Number):int{
return (getFrame(time).imageIndex);
}
public function getDuration():Number{
return (duration);
}
public function Debug_GetTrigger(time:Number):String{
return (getFrame(time).label);
}
public function hasAnchor(name:String, time:Number):Boolean{
return (getFrame(time).hasAnchor(name));
}
public function getAnchor(name:String, time:Number):Vec2{
return (getFrame(time).getAnchor(name));
}
private function getFrame(time:Number):AnimationFrame{
var frame:AnimationFrame;
for each (frame in frameArray) {
if (frame.startTime <= time){
return (frame);
};
};
return (null);
}
public function Debug_GetAnchorListByFrame(frameIndex:int):Array{
if ((((frameIndex < 0)) || ((frameIndex >= frameArray.length)))){
return ([]);
};
return (frameArray[frameIndex].Debug_GetAnchorList());
}
public function destroy():void{
}
private function getOrigin(mc:MovieClip):void{
var w:MovieClip;
var str:String = "";
str = (str + (("MC num [" + mc.numChildren) + "] "));
var first:Boolean;
str = (str + "[");
var q:int;
while (q < mc.numChildren) {
w = (mc.getChildAt(q) as MovieClip);
if (w != null){
if (!first){
str = (str + ", ");
};
str = (str + (((((w.name + "(") + w.x) + ",") + w.y) + ")"));
first = false;
};
q++;
};
str = (str + "]");
Debug.trace(str);
}
public function Debug_GetAnchorList(time:Number):Array{
return (getFrame(time).Debug_GetAnchorList());
}
private function numberModulo(v:Number, m:Number):Number{
while (v < 0) {
v = (v + m);
};
while (v >= m) {
v = (v - m);
};
return (v);
}
}
}//package animation
Section 14
//SwfAnimationConversionTool (animation.SwfAnimationConversionTool)
package animation {
import flash.events.*;
import debug.*;
import flash.display.*;
import managers.resources.*;
public final class SwfAnimationConversionTool extends Sprite {
private var _movieClip:MovieClip;
private var _sceneIndex:int;
private var _swfObjectData:SwfObjectData;
private var _resource:Resource;
private var id:int;// = 0
private static const DISABLE_LOCK:Boolean = true;
private static var uid:int = 0;
private static var lockFrame:int = 0;
public static var validAnchorNameList:Array = null;
public function SwfAnimationConversionTool(mc:MovieClip, resource:Resource){
super();
id = ++uid;
mc.stop();
this.visible = false;
_resource = resource;
_swfObjectData = new SwfObjectData();
_sceneIndex = 0;
_movieClip = mc;
this.addChild(_movieClip);
this.addEventListener(Event.ADDED_TO_STAGE, addedToStage);
}
private function addedToStage(event:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
this.stage.addEventListener(Event.ENTER_FRAME, enterFrame);
}
private function enterFrame(event:Event):void{
var b:Boolean;
if ((((((lockFrame == 0)) || ((lockFrame == id)))) || (DISABLE_LOCK))){
lockFrame = id;
b = _swfObjectData.createFromMovieClipArray(_resource._id, _movieClip, _sceneIndex, validAnchorNameList);
_sceneIndex++;
if (!b){
_resource._loader = null;
_resource._data = _swfObjectData;
_resource._isLoaded = true;
_swfObjectData.debugString = ((((("Compiled SwfObjectData : " + _resource._id) + " ") + _swfObjectData) + "\n\n") + _swfObjectData.debugString);
DebugFileWriter.SaveFile((("debug/swfObjectData_" + _resource._id) + ".txt"), _swfObjectData.debugString);
this.stage.removeEventListener(Event.ENTER_FRAME, enterFrame);
this.removeChild(_movieClip);
this.parent.removeChild(this);
_movieClip = null;
_swfObjectData = null;
lockFrame = 0;
};
};
}
}
}//package animation
Section 15
//SwfObject (animation.SwfObject)
package animation {
import flash.display.*;
import physic.*;
import global.*;
import managers.resources.*;
public final class SwfObject extends Sprite implements IAnimatedObject {
private var bNeedUpdate:Boolean;// = false
private var _bLoop:Boolean;// = false
private var _cloneData:MovieClip;
private var position:Vec2;
private var currentAnim:String;// = ""
private var bJustStarted:Boolean;// = false
private var currentSpeedFactor:Number;// = 1
private var bAnimIsPlaying:Boolean;// = false
private var _scaleY:Number;// = 1
private var _scaleX:Number;// = 1
private var iFrame:Number;// = 0
private var _data:SwfObjectData;// = null
private var _cosValue:Number;// = 1
private var triggerFunction:Function;// = null
private var _dataName:String;// = ""
private var triggerParam:Object;// = null
private var delta:Vec2;
private var mirror:Boolean;// = false
private var _sinValue:Number;// = 0
private var currentTime:Number;// = 0
public static var useClones:Boolean = true;
public function SwfObject(name:String=""){
position = Vec2.ZERO;
delta = new Vec2();
super();
setData(name);
}
private function recursiveGotoAndStop(mc:MovieClip, frame:int, scene:String):void{
var child:DisplayObject;
var i:int;
mc.gotoAndStop(frame, scene);
i = 0;
while (i < mc.numChildren) {
child = mc.getChildAt(i);
if ((child is MovieClip)){
recursiveGotoAndStop((child as MovieClip), (int((iFrame * 30)) % MovieClip(child).totalFrames), null);
};
i++;
};
}
private function numberModulo(val:Number, mod:Number):Number{
while (val > mod) {
val = (val - mod);
};
return (val);
}
public function getData():String{
return (_dataName);
}
public function setLoop(loop:Boolean=true):void{
if (loop){
bAnimIsPlaying = true;
};
_bLoop = loop;
bNeedUpdate = true;
}
public function setData(name:String, offset_unused:Vec2=null):void{
if (((((_data) && (_cloneData))) && (this.contains(_cloneData)))){
this.removeChild(_cloneData);
};
_data = null;
_dataName = ((name)==null) ? "" : name;
playAnimIndex(0, false);
}
public function hasAnimNamed(anim:String):Boolean{
if (dataIsBinded()){
return (_data.hasAnimNamed(anim));
};
return (false);
}
private function dataIsBinded():Boolean{
if (((!(_data)) && (!((_dataName == ""))))){
_data = (ResourceManager.getInstance().getResource(_dataName) as SwfObjectData);
if (_data){
if (useClones){
_cloneData = new ((Object(_data.data).constructor as Class));
} else {
_cloneData = _data.data;
};
this.addChild(_cloneData);
};
};
return (!((_data == null)));
}
public function stopAnim():void{
bAnimIsPlaying = false;
}
override public function get scaleY():Number{
return (_scaleY);
}
public function playIdleAnim(anim:String):void{
playAnim(anim, true);
if (dataIsBinded()){
currentTime = (_data.getAnimDuration(currentAnim) * Math.random());
};
}
public function getRelativeDirection(dir:Vec2, ignoreMirror:Boolean=false):Vec2{
if (((mirror) && (!(ignoreMirror)))){
return (new Vec2(-(((dir.x * _cosValue) + (dir.y * _sinValue))), ((dir.y * _cosValue) - (dir.x * _sinValue))));
};
return (new Vec2(((dir.x * _cosValue) - (dir.y * _sinValue)), ((dir.y * _cosValue) + (dir.x * _sinValue))));
}
public function playAnim(anim:String, loop:Boolean=true):void{
if (((!(bAnimIsPlaying)) || (!((currentAnim == anim))))){
currentAnim = anim;
currentTime = 0;
bJustStarted = true;
bAnimIsPlaying = true;
} else {
if (!loop){
currentTime = 0;
};
};
_bLoop = loop;
bNeedUpdate = true;
}
public function setTime(time:Number):void{
currentTime = time;
bNeedUpdate = true;
}
public function playAnimIndex(anim:int, loop:Boolean=true):void{
if (dataIsBinded()){
playAnim(_data.getAnimNameByIndex(anim), loop);
};
}
public function Debug_SetAnim(anim:String):void{
currentAnim = anim;
currentTime = 0;
bJustStarted = true;
bNeedUpdate = true;
}
public function Debug_GetCurrentCurrentTime():Number{
return (currentTime);
}
override public function get x():Number{
return (position.x);
}
override public function get scaleX():Number{
return (_scaleX);
}
override public function get y():Number{
return (position.y);
}
public function Debug_GetCurrentAnimationName():String{
return (currentAnim);
}
public function getCurrentAnimation():String{
return (currentAnim);
}
public function set scale($s:Number):void{
_scaleX = $s;
_scaleY = $s;
bNeedUpdate = true;
}
override public function set scaleX(value:Number):void{
_scaleX = value;
bNeedUpdate = true;
}
public function isPlaying():Boolean{
return (bAnimIsPlaying);
}
override public function set scaleY(value:Number):void{
_scaleY = value;
bNeedUpdate = true;
}
public function getAnchor(name:String):Vec2{
var origin:Vec2;
var p:Vec2;
if (dataIsBinded()){
origin = _data.getAnchor("origin", currentAnim, currentTime);
p = _data.getAnchor(name, currentAnim, currentTime).clone();
if (mirror){
delta.x = ((origin.x - p.x) * _scaleX);
} else {
delta.x = ((p.x - origin.x) * _scaleX);
};
delta.y = ((p.y - origin.y) * _scaleY);
p.x = (position.x + ((delta.x * _cosValue) - (delta.y * _sinValue)));
p.y = (position.y + ((delta.y * _cosValue) + (delta.x * _sinValue)));
return (p);
};
return (null);
}
public function setSpeedFactor(factor:Number):void{
currentSpeedFactor = factor;
}
public function Debug_GetCurrentFrame():int{
if (_data){
return (_data.getSwfFrame(currentAnim, currentTime));
};
return (0);
}
public function setMirror(b:Boolean):void{
mirror = b;
bNeedUpdate = true;
}
public function getMirror():Boolean{
return (mirror);
}
public function update(timeElapsed:Number, skipVisual:Boolean=false, skipTriggers:Boolean=false):void{
var playedThisFrame:Boolean;
var animDuration:Number;
var elapsedTime:Number;
var offset:Vec2;
var origin:Vec2;
iFrame = (iFrame + GameTimer.getDeltaTime());
if (((dataIsBinded()) && (bNeedUpdate))){
playedThisFrame = false;
if (bAnimIsPlaying){
playedThisFrame = true;
animDuration = _data.getAnimDuration(currentAnim);
if (animDuration == 0){
return;
};
elapsedTime = (timeElapsed * currentSpeedFactor);
currentTime = (currentTime + elapsedTime);
if (_bLoop){
currentTime = numberModulo(currentTime, animDuration);
} else {
if (currentTime > animDuration){
currentTime = animDuration;
bNeedUpdate = false;
bAnimIsPlaying = false;
};
};
};
if (!skipVisual){
recursiveGotoAndStop(_cloneData, _data.getSwfFrame(currentAnim, currentTime), currentAnim);
};
offset = _data.getOffset(currentAnim, currentTime);
origin = _data.getAnchor("origin", currentAnim, currentTime);
if (mirror){
delta.x = ((origin.x - offset.x) * _scaleX);
super.scaleX = -(_scaleX);
} else {
delta.x = ((offset.x - origin.x) * _scaleX);
super.scaleX = _scaleX;
};
delta.y = ((offset.y - origin.y) * _scaleY);
super.scaleY = _scaleY;
super.x = (position.x + ((delta.x * _cosValue) - (delta.y * _sinValue)));
super.y = (position.y + ((delta.y * _cosValue) + (delta.x * _sinValue)));
if (!skipTriggers){
if (((!((triggerFunction == null))) && (playedThisFrame))){
_data.checkTriggers(this, currentAnim, elapsedTime, currentTime, bJustStarted, triggerFunction, triggerParam);
};
};
bJustStarted = false;
};
}
public function Debug_SetCurrentFrame(frame:int):void{
if (_data){
currentTime = _data.Debug_GetTimeFromFrame(currentAnim, frame);
};
}
public function getCurrentTime():Number{
return (currentTime);
}
override public function set visible(value:Boolean):void{
super.visible = value;
bNeedUpdate = true;
}
public function setTriggerFunction(fn:Function=null, param:Object=null):void{
triggerFunction = fn;
triggerParam = param;
}
public function hasAnchor(name:String):Boolean{
if (dataIsBinded()){
return (_data.hasAnchor(name, currentAnim, currentTime));
};
return (false);
}
override public function set y(_y:Number):void{
position.y = _y;
bNeedUpdate = true;
}
override public function set x(_x:Number):void{
position.x = _x;
bNeedUpdate = true;
}
public function destroy():void{
_dataName = "";
_data = null;
while (this.numChildren > 0) {
this.removeChildAt(0);
};
}
override public function set rotation(value:Number):void{
super.rotation = value;
var angle:Number = ((super.rotation * Math.PI) / 180);
_cosValue = Math.cos(angle);
_sinValue = Math.sin(angle);
bNeedUpdate = true;
}
public static function stopAllRecursive(obj:DisplayObject):void{
var i:int;
if ((obj is DisplayObjectContainer)){
if ((obj is MovieClip)){
(obj as MovieClip).stop();
};
i = 0;
while (i < (obj as DisplayObjectContainer).numChildren) {
arguments.callee((obj as DisplayObjectContainer).getChildAt(i));
i++;
};
};
}
public static function updateAnimationRecursive(obj:DisplayObject, deltaTime:Number):void{
var i:int;
trace("asas");
if ((obj is SwfObject)){
(obj as SwfObject).update(deltaTime);
} else {
if ((obj is DisplayObjectContainer)){
i = 0;
while (i < (obj as DisplayObjectContainer).numChildren) {
arguments.callee((obj as DisplayObjectContainer).getChildAt(i), deltaTime);
i++;
};
};
};
}
public static function removeAllFrameScriptRecursive(obj:DisplayObject):void{
var i:int;
var mc:MovieClip;
var iterator:Scene;
if ((obj is DisplayObjectContainer)){
if ((obj is MovieClip)){
mc = (obj as MovieClip);
for each (iterator in mc.scenes) {
mc.gotoAndStop(0, iterator.name);
i = 0;
while (i < mc.totalFrames) {
mc.addFrameScript(i, null);
i++;
};
};
};
i = 0;
while (i < (obj as DisplayObjectContainer).numChildren) {
arguments.callee((obj as DisplayObjectContainer).getChildAt(i));
i++;
};
};
}
}
}//package animation
Section 16
//SwfObjectData (animation.SwfObjectData)
package animation {
import flash.display.*;
import physic.*;
import managers.resources.*;
import animation.*;
class SwfObjectData implements ICompiledResource {
private var animationList:Array;
public var debugString:String;// = ""
public var data:MovieClip;
function SwfObjectData(){
animationList = new Array();
super();
}
public function getSwfFrame(animId:String, animTime:Number):int{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.getImage(animTime));
};
return (0);
}
public function getOffset(animId:String, animTime:Number):Vec2{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (Vec2.ZERO);
};
return (AnimationAnchor.DEFAULT);
}
public function Debug_GetTimeFromFrame(animId:String, frame:int):Number{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.Debug_GetTimeFromFrame(frame));
};
return (0);
}
private function getAnimation(animId:String):SwfAnimation{
var iterator:SwfAnimation;
for each (iterator in animationList) {
if (iterator.name == animId){
return (iterator);
};
};
return (null);
}
public function deserialization():void{
}
public function destroy():void{
while (animationList.length > 0) {
(animationList.pop() as SwfAnimation).destroy();
};
}
public function Debug_GetAnchorListByFrame(animId:String, frameIndex:int):Array{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.Debug_GetAnchorListByFrame(frameIndex));
};
return ([]);
}
public function checkTriggers(thisObject:SwfObject, animId:String, elapsedTime:Number, currentTime:Number, bJustStarted:Boolean, callback:Function, param:Object):void{
var anim:SwfAnimation;
if (callback != null){
anim = getAnimation(animId);
if (anim){
anim.checkTriggers(thisObject, elapsedTime, currentTime, bJustStarted, callback, param);
};
};
}
public function Debug_GetFrameCount(animId:String):int{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.totalFrames);
};
return (0);
}
public function getAnimNameByIndex(animId:int):String{
if ((((animId >= 0)) && ((animId < animationList.length)))){
return ((animationList[animId] as SwfAnimation).name);
};
return ("");
}
public function getAnchor(name:String, animId:String, animTime:Number):Vec2{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.getAnchor(name, animTime));
};
return (AnimationAnchor.DEFAULT);
}
public function Debug_GetTriggerList(animId:String):Array{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.Debug_GetTriggerList());
};
return ([]);
}
public function hasAnimNamed(animId:String):Boolean{
var iterator:SwfAnimation;
for each (iterator in animationList) {
if (iterator.name == animId){
return (true);
};
};
return (false);
}
public function hasAnchor(name:String, animId:String, animTime:Number):Boolean{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.hasAnchor(name, animTime));
};
return (false);
}
public function serialization():void{
}
public function toString():String{
var iterator:SwfAnimation;
var frameCount:int;
var str:String = "";
for each (iterator in animationList) {
str = (str + (((iterator.name + "[") + iterator.totalFrames) + "] "));
frameCount = (frameCount + iterator.totalFrames);
};
str = (str + (("\n TOTAL IMAGE COUNT = [" + frameCount) + "] "));
return (str);
}
public function Debug_GetTrigger(animId:String, animTime:Number):String{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.Debug_GetTrigger(animTime));
};
return ("");
}
public function getAnimDuration(animId:String):Number{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.getDuration());
};
return (0);
}
public function Debug_GetAnchorList(animId:String, animTime:Number):Array{
var anim:SwfAnimation = getAnimation(animId);
if (anim){
return (anim.Debug_GetAnchorList(animTime));
};
return ([]);
}
public function createFromMovieClipArray(resourceName:String, obj:DisplayObject, sceneIndex:int, validAnchorNameList:Array=null):Boolean{
data = (obj as MovieClip);
if (!((!((obj == null))) && ((obj is MovieClip)))){
return (false);
};
var mc:MovieClip = (obj as MovieClip);
if (sceneIndex >= mc.scenes.length){
return (false);
};
trace(mc.scenes[sceneIndex].name, this.data, this.debugString);
mc.gotoAndStop(1, mc.scenes[sceneIndex].name);
var s:Scene = mc.currentScene;
var anim:SwfAnimation = new SwfAnimation(resourceName, mc, s.numFrames, s.name, this, validAnchorNameList);
animationList.push(anim);
mc.nextScene();
mc.stop();
return (true);
}
}
}//package animation
Section 17
//Debug (debug.Debug)
package debug {
import global.*;
import flash.external.*;
public class Debug {
public static const DEBUG_MODE:Boolean = false;
public function Debug(){
super();
}
public static function error(... _args):void{
var args = _args;
var str:String;
var i:uint;
while (i < args.length) {
if (str){
str = (str + (" " + String(args[i])));
} else {
str = String(args[i]);
};
i = (i + 1);
};
DebugDisplay._trace(str, DebugDisplay.FONT_TYPE_ERROR);
if (GlobalData.USE_EXTERNAL_CONSOLE){
ExternalInterface.call("console.log", str);
//unresolved jump
var _slot1 = error;
};
DebugDisplay.forceShowConsole();
}
public static function warning(... _args):void{
var args = _args;
var str:String;
var i:uint;
while (i < args.length) {
if (str){
str = (str + (" " + String(args[i])));
} else {
str = String(args[i]);
};
i = (i + 1);
};
DebugDisplay._trace(str, DebugDisplay.FONT_TYPE_WARNING);
if (GlobalData.USE_EXTERNAL_CONSOLE){
ExternalInterface.call("console.log", str);
//unresolved jump
var _slot1 = error;
};
}
public static function trace(... _args):void{
var args = _args;
var str:String;
var i:uint;
while (i < args.length) {
if (str){
str = (str + (" " + String(args[i])));
} else {
str = String(args[i]);
};
i = (i + 1);
};
DebugDisplay._trace(str, DebugDisplay.FONT_TYPE_NORMAL);
if (GlobalData.USE_EXTERNAL_CONSOLE){
ExternalInterface.call("console.log", str);
//unresolved jump
var _slot1 = error;
};
}
}
}//package debug
Section 18
//DebugDisplay (debug.DebugDisplay)
package debug {
import flash.events.*;
import flash.display.*;
import global.*;
import flash.utils.*;
import flash.text.*;
import flash.system.*;
import flash.filters.*;
public class DebugDisplay extends Sprite {
private const offsetY:Number = 464;
private var _staticTextField:TextField;
private var _minFPStime:Number;// = 0
private var _consoleString:String;
private var _consoleStringArray:Array;
private var _deltaTimeArray:Array;
private var _consoleTextField:TextField;
private var _avgFPS:Number;// = 0
private var _min:int;// = 0
private var _minFPS:Number;// = 0
private var maxTotalMemory:uint;// = 0
private var _lastTime:int;// = 0
public var staticStr:String;// = ""
private var _max:int;// = 0
private var _dynamicTextField:TextField;
private var _fps:int;// = 0
private var dynamicStr:String;// = ""
private static const CONSOLE_TRIGGER_KEY:uint = 8;
public static const FONT_TYPE_ERROR:int = 2;
private static const CONSOLE_LINES:uint = 46;
public static const FONT_TYPE_NORMAL:int = 0;
public static const FONT_TYPE_WARNING:int = 1;
private static var instance:DebugDisplay;
private static var displayTreeStr:String = "";
private static var showConsole:Boolean = false;
private static var keyIsDown:Boolean = false;
private static var childList:Array;
private static var displayTreeChildList:Array;
public static var childrenTreeStr:String = "";
public function DebugDisplay(){
_consoleStringArray = new Array();
_deltaTimeArray = new Array();
super();
instance = this;
this.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
this.addEventListener(Event.REMOVED_FROM_STAGE, handleRemovedFromStage);
if (GlobalData.DEBUG_USE_INTERNAL_CONSOLE){
this.filters = [new GlowFilter(0, 1, 6, 6)];
};
this.mouseChildren = false;
this.mouseEnabled = false;
}
public function handleAddedToStage(event:Event):void{
if (GlobalData.DEBUG_USE_INTERNAL_CONSOLE){
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUp);
};
Debug.trace("DebugDisplay: Added To Stage");
dynamicStr = "FPS";
staticStr = (((((((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY) + " ") + (Capabilities.avHardwareDisable) ? " [SOFTWARE]" : " [HARDWARE]") + "\n") + Capabilities.version.toString()) + (Capabilities.isDebugger) ? " [DEBUG]" : "");
var t:TextField = new TextField();
staticStr = GlobalData.getBuildName();
_staticTextField = new TextField();
_staticTextField.defaultTextFormat = new TextFormat(null, 9);
_staticTextField.embedFonts = false;
_staticTextField.selectable = false;
_staticTextField.tabEnabled = false;
_staticTextField.autoSize = "left";
_staticTextField.text = staticStr;
_staticTextField.scaleX = 1;
_staticTextField.scaleY = 1;
_staticTextField.textColor = 0xFFFFFF;
_staticTextField.sharpness = 1;
_staticTextField.x = 1;
_staticTextField.y = offsetY;
_staticTextField.cacheAsBitmap = true;
addChild(_staticTextField);
_dynamicTextField = new TextField();
_dynamicTextField.defaultTextFormat = new TextFormat(null, 9);
_dynamicTextField.embedFonts = false;
_dynamicTextField.selectable = false;
_dynamicTextField.tabEnabled = false;
_dynamicTextField.autoSize = "left";
_dynamicTextField.text = "Debug Display";
_dynamicTextField.scaleX = 1;
_dynamicTextField.scaleY = 1;
_dynamicTextField.textColor = 0xFFFFFF;
_dynamicTextField.sharpness = 1;
_dynamicTextField.x = 1;
_dynamicTextField.y = (offsetY - 10);
_dynamicTextField.cacheAsBitmap = false;
addChild(_dynamicTextField);
if (((GlobalData.DEBUG_USE_INTERNAL_CONSOLE) && (Debug.DEBUG_MODE))){
_consoleTextField = new TextField();
_consoleTextField.defaultTextFormat = new TextFormat(null, 10);
_consoleTextField.embedFonts = false;
_consoleTextField.selectable = false;
_consoleTextField.tabEnabled = false;
_consoleTextField.autoSize = "left";
_consoleTextField.text = staticStr;
_consoleTextField.scaleX = 1;
_consoleTextField.scaleY = 1;
_consoleTextField.textColor = 0xFFFFFF;
_consoleTextField.sharpness = 1;
_consoleTextField.x = 1;
_consoleTextField.y = 1;
_consoleTextField.cacheAsBitmap = true;
addChild(_consoleTextField);
_consoleTextField.visible = showConsole;
};
this.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
}
public function handleRemovedFromStage(event:Event):void{
if (GlobalData.DEBUG_USE_INTERNAL_CONSOLE){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, keyUp);
};
trace("DebugDisplay: Removed From Stage");
this.removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
}
public function handleEnterFrame(event:Event):void{
var _offsetx:int;
var _offsety:int;
var _sizex:int;
var _sizey:int;
var _moy:int;
var k:int;
var _time:int = getTimer();
var _elapsed:int = (_time - _lastTime);
_lastTime = _time;
_fps = Math.round((1000 / _elapsed));
_avgFPS = ((_avgFPS)<1) ? _fps : ((_avgFPS * 0.96) + (_fps * 0.04));
if ((((_minFPS > _fps)) || ((_minFPStime < _time)))){
_minFPS = _fps;
_minFPStime = (_time + 2000);
};
if (GlobalData.DEBUG_MODE){
_deltaTimeArray.push(_elapsed);
if (_deltaTimeArray.length > 250){
_deltaTimeArray.shift();
};
_offsetx = 80;
_offsety = 550;
_sizex = 710;
_sizey = 40;
_moy = 0;
k = ((_max - _min) * 0.1);
_min = (_min + k);
_max = (_max - k);
for each (k in _deltaTimeArray) {
if (k < _min){
_min = k;
};
if (k > _max){
_max = k;
};
_moy = (_moy + k);
};
_moy = (_moy / _deltaTimeArray.length);
if (_max != _min){
this.graphics.clear();
this.graphics.lineStyle(2, 0xFF00, 1);
this.graphics.moveTo(_offsetx, (_offsety + (((_moy - _min) / (_max - _min)) * _sizey)));
this.graphics.lineTo((_offsetx + _sizex), (_offsety + (((_moy - _min) / (_max - _min)) * _sizey)));
this.graphics.endFill();
this.graphics.lineStyle(2, 0xFF0000, 1);
this.graphics.moveTo(_offsetx, _offsety);
k = 0;
while (k < _deltaTimeArray.length) {
this.graphics.lineTo((_offsetx + ((Number(k) / _deltaTimeArray.length) * _sizex)), (_offsety + (((_deltaTimeArray[k] - _min) / (_max - _min)) * _sizey)));
k++;
};
this.graphics.endFill();
};
};
var totalMem:uint = System.totalMemory;
maxTotalMemory = ((totalMem)>maxTotalMemory) ? totalMem : maxTotalMemory;
dynamicStr = ((((("FPS " + Math.round(_avgFPS)) + " [") + _fps) + "] ") + _minFPS);
_dynamicTextField.text = dynamicStr;
}
private static function strReplace(str:String, pattern:String, repl:String):String{
var result:String;
var iterator:String;
if (str.indexOf(pattern) >= 0){
result = null;
for each (iterator in str.split(pattern)) {
if (result){
result = (result + (repl + iterator));
} else {
result = iterator;
};
};
return (result);
};
return (str);
}
public static function _trace(str:String, fontType:int=0):void{
var iterator:String;
var lines:Array;
if (GlobalData.DEBUG_USE_INTERNAL_CONSOLE){
iterator = "";
str = strReplace(str, "&", "&");
str = strReplace(str, "<", "<");
str = strReplace(str, ">", ">");
lines = str.split("\n");
for each (iterator in lines) {
switch (fontType){
case FONT_TYPE_NORMAL:
instance._consoleStringArray.push(iterator);
break;
case FONT_TYPE_WARNING:
instance._consoleStringArray.push((("<font color=\"#eeff00\">" + iterator) + "</font>"));
break;
case FONT_TYPE_ERROR:
instance._consoleStringArray.push((("<font color=\"#ff3333\">" + iterator) + "</font>"));
break;
};
};
while (instance._consoleStringArray.length > CONSOLE_LINES) {
instance._consoleStringArray.shift();
};
instance._consoleString = "";
for each (iterator in instance._consoleStringArray) {
instance._consoleString = (instance._consoleString + (iterator + "\n"));
};
if (((instance._consoleTextField) && (showConsole))){
instance._consoleTextField.text = instance._consoleString;
};
if (instance._consoleTextField){
instance._consoleTextField.htmlText = instance._consoleString;
};
};
trace(str);
}
public static function getDisplayTree(obj:DisplayObjectContainer):String{
var s:String;
displayTreeStr = "";
if (obj != null){
displayTreeChildList = new Array();
staticPopulateStageChildrenTreeRec(" ", obj);
displayTreeChildList.reverse();
for each (s in displayTreeChildList) {
displayTreeStr = (displayTreeStr + ("\n" + s));
};
};
return (displayTreeStr);
}
private static function staticPopulateStageChildrenTreeRec(deepLevel:String, obj:DisplayObjectContainer):void{
var i:uint;
var str:String = deepLevel;
if (obj == null){
str = (str + "null");
} else {
str = (str + (((getQualifiedClassName(obj) + "[") + obj.numChildren) + "]"));
if ((obj is MovieClip)){
str = (str + ((" (" + (obj as MovieClip).totalFrames) + " frames)"));
};
i = 0;
while (i < obj.numChildren) {
staticPopulateStageChildrenTreeRec((deepLevel + "-"), (obj.getChildAt(i) as DisplayObjectContainer));
i++;
};
};
displayTreeChildList.push(str);
}
public static function populateStageChildrenTree(_stage:DisplayObjectContainer):void{
var lastStr:String;
var lastStrCount:uint;
var s:String;
childrenTreeStr = "";
if (_stage != null){
childList = new Array();
populateStageChildrenTreeRec("", _stage);
childList.reverse();
lastStr = "";
lastStrCount = 0;
for each (s in childList) {
if (s == lastStr){
lastStrCount++;
} else {
if (lastStrCount > 1){
childrenTreeStr = (childrenTreeStr + ((" x [" + lastStrCount) + "]"));
};
childrenTreeStr = (childrenTreeStr + ("\n" + s));
lastStr = s;
lastStrCount = 1;
};
};
};
}
private static function keyDown(event:KeyboardEvent):void{
if (event.keyCode == CONSOLE_TRIGGER_KEY){
if (!keyIsDown){
showConsole = !(showConsole);
instance._consoleTextField.visible = showConsole;
};
keyIsDown = true;
};
}
private static function keyUp(event:KeyboardEvent):void{
if (event.keyCode == CONSOLE_TRIGGER_KEY){
keyIsDown = false;
};
}
private static function populateStageChildrenTreeRec(deepLevel:String, obj:DisplayObjectContainer):void{
var i:uint;
var str:String = deepLevel;
if (obj == null){
str = (str + "null");
} else {
str = (str + (((getQualifiedClassName(obj) + "[") + obj.numChildren) + "]"));
i = 0;
while (i < obj.numChildren) {
populateStageChildrenTreeRec((deepLevel + "-"), (obj.getChildAt(i) as DisplayObjectContainer));
i++;
};
};
childList.push(str);
}
public static function forceShowConsole():void{
if (GlobalData.DEBUG_USE_INTERNAL_CONSOLE){
showConsole = true;
instance._consoleTextField.visible = showConsole;
};
}
public static function getChildrenCountRecursive(paramObj:DisplayObject):uint{
var obj:DisplayObjectContainer;
var k:int;
var i:uint;
if ((paramObj is DisplayObjectContainer)){
obj = (paramObj as DisplayObjectContainer);
k = 0;
while (k < obj.numChildren) {
i = (i + getChildrenCountRecursive(obj.getChildAt(k)));
k++;
};
};
return ((i + 1));
}
}
}//package debug
Section 19
//DebugFileWriter (debug.DebugFileWriter)
package debug {
public final class DebugFileWriter {
private var saveFunction:Function;
private var loadFunction:Function;
private static var _instance:DebugFileWriter = new DebugFileWriter(PrivateClass);
;
public function DebugFileWriter(c:Class){
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
private function instanceConstructor():void{
}
public function setFunctions(s:Function, l:Function):void{
saveFunction = s;
loadFunction = l;
}
public static function SaveFile(path:String, data:String):void{
if (_instance.saveFunction != null){
_instance.saveFunction(path, data);
};
}
public static function getInstance():DebugFileWriter{
return (_instance);
}
public static function LoadFile(path:String, callbackFunction:Function):void{
if (_instance.loadFunction != null){
_instance.loadFunction(path, callbackFunction);
};
}
}
}//package debug
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 20
//GameTimer (global.GameTimer)
package global {
import flash.utils.*;
public final class GameTimer {
private var timerType:int;// = 0
private static const TIMER_TYPE_COUNT:int = 1;
public static const PAUSE_2:int = 2;
public static const PAUSE_1:int = 1;
public static const TIMER_ABSOLUTE:int = 0;
public static const UNPAUSE:int = 0;
private static var deltaArray:Array = [0, 0, 0];
private static var currentPauseLevel:int = 0;
private static var timerArray:Array = [0, 0, 0];
private static var previousTime:int = 0;
public static var timeScaleFactor:Number = 1;
public function GameTimer(type:int=0){
super();
timerType = type;
}
public static function getDeltaTimeByType(type:int):Number{
return (deltaArray[type]);
}
public static function getTime():Number{
return (timerArray[0]);
}
public static function reset():void{
var currentTime:int = getTimer();
previousTime = currentTime;
var i:int;
while (i < TIMER_TYPE_COUNT) {
timerArray[i] = 0;
deltaArray[i] = 0;
i++;
};
}
public static function UpdateTimers():void{
var currentTime:int = getTimer();
var deltaTime:Number = (Number((currentTime - previousTime)) / 1000);
deltaTime = Math.min(0.1, deltaTime);
deltaTime = (deltaTime * timeScaleFactor);
var i:int;
while (i < TIMER_TYPE_COUNT) {
if (i <= currentPauseLevel){
timerArray[i] = (timerArray[i] + deltaTime);
deltaArray[i] = deltaTime;
} else {
deltaArray[i] = 0;
};
i++;
};
previousTime = currentTime;
}
public static function SetPauseLevel(level:int):void{
currentPauseLevel = level;
}
public static function getTimerByType(type:int):Number{
return (timerArray[type]);
}
public static function getDeltaTime():Number{
return (deltaArray[0]);
}
public static function setPause(pause:Boolean):void{
timeScaleFactor = (pause) ? 0 : 1;
}
public static function isPaused():Boolean{
return ((timeScaleFactor == 0));
}
}
}//package global
Section 21
//GlobalData (global.GlobalData)
package global {
import flash.filters.*;
public class GlobalData {
public static const CHEAT_LAUCH_BOSS_FIGHT_4:String = "bf4";
public static const DEBUG_DISABLE_COMMUNITY:Boolean = false;
public static const missionAvailability:Array = [AVAILABILITY_BUY, AVAILABILITY_BUY, AVAILABILITY_BUY, AVAILABILITY_BUY];
public static const GO_TYPE_OBJECT:uint = (1 << 10);
public static const PARAM_PLATFORMER_ID:String = "levelID";
public static const SLOPE_ANGLE_DEGREE:Number = ((Math.atan((1 / 2)) * 180) / Math.PI);
public static const CODE_PLATFORMER_BACK:String = "backToMainMenu";
public static const CUSTOM_LEVEL:String = "custom_level";
public static const MODE_TRY:String = "try";
public static const DEBUG_USE_INTERNAL_CONSOLE:Boolean = false;
public static const GO_TYPE_DANGER_AREA:uint = (1 << 8);
public static const navMeshThresholdX:Number = 16;
public static const navMeshThresholdY:Number = 32;
public static const PARAM_TRUE:String = "true";
public static const CODE_PLATFORMER_FAILURE:String = "failure";
public static const DEBUG_USE_EXTERNAL_CONSOLE:Boolean = false;
public static const OBJECTIVE_COLLECT_CARDS:String = "cards";
public static const MISSION_04_INDEX:int = 3;
public static const AVATAR_TY:String = "ty";
public static const GO_TYPE_AVATAR:uint = (1 << 0);
public static const DEBUG_MODE:Boolean = false;
public static const DEFAULT_USERNAME:String = "12345";
public static const GO_TYPE_COLLECTABLE_MASK:uint = 30;
public static const GO_TYPE_ALL_MASK:uint = 0xFFFF;
public static const GO_TYPE_COLLECTABLE_SPECIAL_CARD:uint = (1 << 3);
public static const CHEAT_NO_CLIP_MODE:String = "noClip";
public static const TILE_SIZE:int = 32;
public static const AVAILABILITY_NOT_AVAILABLE:int = 0;
public static const BLOCK_NAME:String = "block_";
public static const PARAM_PLATFORMER_EXTRA_DAMAGE:String = "extraDamage";
public static const windowHeight:Number = 480;
public static const CHEAT_TOGGLE_SOUND:String = "noSound";
public static const GO_TYPE_BOSS:uint = (1 << 6);
public static const CHEAT_END_LEVEL:String = "TheEnd";
public static const applicationWidth:Number = 640;
public static const PARAM_PLATFORMER_MODE:String = "mode";
public static const GO_TYPE_COLLECTABLE_CARD:uint = 12;
public static const AVATAR_ABBY:String = "abby";
public static const GO_TYPE_COLLECTABLE_POWERUP:uint = (1 << 1);
public static const MISSION_01_INDEX:int = 0;
public static const OBJECTIVE_GLUE_ENEMIES:String = "enemies";
public static const DEBUG_TEST_TEXT_FIELD_SIZE:Boolean = false;
public static const PARAM_PLATFORMER_TIME:String = "time";
public static const MODE_PLATFORMER:String = "modePlatformer";
public static const CHEAT_UNLOCK_MISSIONS:String = "unlockMissions";
public static const AVAILABILITY_BUY:int = 2;
public static const applicationFrameRate:Number = 240;
public static const CHEAT_LOCALIZATION_TEST_ACCENTS:String = "accents";
public static const OBJECTIVE_GO_TO_END:String = "none";
public static const GO_TYPE_TRAP:uint = (1 << 7);
public static const OBJECTIVE_COLLECT_HINTS:String = "hints";
public static const MODE_LEVEL_CHALLENGE:String = "modeChallenge";
public static const applicationHeight:Number = 480;
public static const GO_TYPE_TRIGGER:uint = (1 << 9);
public static const PARAM_PLATFORMER_RESULT_CODE:String = "result";
public static const gameName:String = "BubbleElephant";
public static const CODE_PLATFORMER_SUCCESS:String = "success";
public static const MODE_LEVEL_TEST:String = "modeLevelTest";
public static const MISSION_02_INDEX:int = 1;
public static const PARAM_FALSE:String = "false";
public static const MISSION_01:String = "mission_01";
public static const MISSION_02:String = "mission_02";
public static const MISSION_03:String = "mission_03";
public static const MISSION_04:String = "mission_04";
public static const OBJECTIVE_GLUE_ENEMIES_AND_COLLECT_CARDS:String = "enemiesAndCards";
public static const MODE_BOSS_FIGHT:String = "modeBossFight";
public static const windowWidth:Number = 640;
public static const PARAM_PLATFORMER_AVATAR:String = "avatar";
public static const AVATAR_UNDEFINED:String = "undefined";
public static const CHEAT_INVULNERABILITY:String = "idkfa";
public static const GO_TYPE_UNDEFINED:uint = 0xFF00;
public static const GO_TYPE_COLLECTABLE_HINT:uint = (1 << 4);
public static const OBJECTIVE_DEFEAT_BOSS:String = "defeatBoss";
public static const CHEAT_UNLOCK_ALL_CARDS:String = "unlockCards";
public static const USE_CHEATS:Boolean = false;
public static const GO_TYPE_ENEMY:uint = 96;
public static const PARAM_MISSION_ID:String = "mission_id";
public static const GO_TYPE_THREAT_MASK:uint = 480;
public static const MISSION_03_INDEX:int = 2;
public static const CHEAT_LAUCH_BOSS_FIGHT_1:String = "bf1";
public static const CHEAT_LAUCH_BOSS_FIGHT_2:String = "bf2";
public static const CHEAT_LAUCH_BOSS_FIGHT_3:String = "bf3";
public static const DEFAULT_PASSWORD:String = "678910";
public static const AVAILABILITY_NOT_BUY:int = 1;
private static var _instance:GlobalData = new GlobalData(PrivateClass);
;
public static var ITEMSELECTORRADIUS:Number = 0;
public static var firstLoginStep:int = 4;
public static var MOUSELISTENER:Boolean = false;
public static var enableSound:Boolean = false;
public static var currentFrame:uint = 0;
public static var missionFlowCardArray:Array = [true, true, true, true];
public static var USE_EXTERNAL_CONSOLE:Boolean;
public static var password:String;
public static var BUILD_VERSION:String = "";
public static var username:String;
public static var currentMission:int = 1;
public function GlobalData(c:Class){
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
private function instanceConstructor():void{
}
public static function getInstance():GlobalData{
return (_instance);
}
public static function get missionPrefix():String{
return ((("mission0" + currentMission) + "/"));
}
public static function formatNumber(value:Number, len:int=2):String{
var s:String = String(Math.floor(value));
while (s.length < len) {
s = ("0" + s);
};
return (s);
}
public static function getTimeStamp():String{
var d:Date = new Date();
return ((((((formatNumber((d.getFullYear() % 100)) + formatNumber((d.getMonth() + 1))) + formatNumber(d.getDate())) + formatNumber(d.getHours())) + formatNumber(d.getMinutes())) + formatNumber(d.getSeconds())));
}
public static function getMissionCount():int{
return (missionAvailability.length());
}
public static function getMissionAvailabilityBool():Array{
var iterator:int;
var a:Array = new Array();
for each (iterator in missionAvailability) {
a.push((iterator == AVAILABILITY_BUY));
};
return (a);
}
public static function CRASH():void{
(null as Object).constructor();
}
public static function getBuildName():String{
return (BUILD_VERSION);
}
public static function getCardId(mission:int, quiz:Boolean, card:int):int{
return (((mission + (quiz) ? 4 : 0) + (8 * card)));
}
private static function linearinterp(a:Number, b:Number, u:Number):Number{
return ((((1 - u) * a) + (u * b)));
}
public static function getGhostFilters():Array{
var j:int;
var matrix:Array = new Array();
matrix = matrix.concat([0.299, 0.587, 0.114, 0, 0]);
matrix = matrix.concat([0.299, 0.587, 0.114, 0, 0]);
matrix = matrix.concat([0.299, 0.587, 0.114, 0, 0]);
matrix = matrix.concat([0, 0, 0, 0.3, 0]);
var i:int;
while (i < 3) {
j = 0;
while (j < 3) {
matrix[(i + (j * 5))] = (matrix[(i + (j * 5))] * 0.5);
j++;
};
i++;
};
var filter1:ColorMatrixFilter = new ColorMatrixFilter(matrix);
var filter2:GlowFilter = new GlowFilter(0xFFFFFF, 0.8, 12, 12);
return ([filter1, filter2]);
}
}
}//package global
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 22
//LoadingScreen (managers.modules.LoadingScreen)
package managers.modules {
import flash.display.*;
import flash.utils.*;
public class LoadingScreen extends Sprite {
private var timeStart:int;
public function LoadingScreen(){
super();
}
public function loadingProgress(isDone:Boolean, progress:Number):void{
}
public function destroy():void{
trace("Loading time: ", (getTimer() - timeStart), "ms");
}
public function create():void{
timeStart = getTimer();
}
public function isReadyToStart():Boolean{
return (true);
}
}
}//package managers.modules
Section 23
//Module (managers.modules.Module)
package managers.modules {
import flash.display.*;
public class Module extends Sprite {
protected var _paramList:ParameterList;
protected var _resultParamList:ParameterList;
public function Module(){
super();
}
final public function setParamList(list:ParameterList):void{
_paramList = list;
}
public function uninitialize():Boolean{
return (true);
}
final public function setResultParam(list:ParameterList):void{
_resultParamList = list;
}
public function initialize():Boolean{
return (true);
}
public function execute():void{
}
public function render():void{
}
public function destroy():void{
}
final protected function invalidate():void{
if (stage){
stage.invalidate();
};
}
public function create():void{
}
}
}//package managers.modules
Section 24
//ModuleDefinition (managers.modules.ModuleDefinition)
package managers.modules {
public final class ModuleDefinition {
public var visible:Boolean;// = true
public var resourcePackageList:Array;
public var defaultParamList:ParameterList;
public var name:String;// = "name"
public var url:String;// = "url"
public function ModuleDefinition(){
resourcePackageList = new Array();
defaultParamList = new ParameterList();
super();
}
}
}//package managers.modules
Section 25
//ModuleLoader (managers.modules.ModuleLoader)
package managers.modules {
import flash.events.*;
import debug.*;
import flash.display.*;
import flash.system.*;
import flash.net.*;
public final class ModuleLoader {
public var loaded:Boolean;// = false
public var bytesTotal:Number;// = 0
private var _module:Module;// = null
private var _paramList:ParameterList;// = null
public var bytesLoaded:Number;// = 0
private var _loader:Loader;// = null
private var _url:String;// = ""
public function ModuleLoader(){
super();
loaded = false;
}
public function loadEmbeddedModuleCallback(moduleMC:Object, paramList:ParameterList):void{
_module = (moduleMC as Module);
_module.setParamList(paramList);
loaded = true;
}
private function handleModuleLoadComplete(event:Event):void{
_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, handleModuleLoadProgress);
_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, handleModuleLoadComplete);
_loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, handleModuleLoadError);
_module = (_loader.content as Module);
_module.setParamList(_paramList);
bytesLoaded = _loader.contentLoaderInfo.bytesLoaded;
bytesTotal = _loader.contentLoaderInfo.bytesTotal;
loaded = true;
}
public function unloadModule():void{
_module = null;
loaded = false;
System.gc();
}
private function handleModuleLoadProgress(event:ProgressEvent):void{
bytesLoaded = event.bytesLoaded;
bytesTotal = event.bytesTotal;
}
public function get module():Module{
return (_module);
}
public function loadModule(url:String, paramList:ParameterList):void{
Debug.trace(("Loading Module at url = " + url));
_module = null;
loaded = false;
_paramList = paramList;
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleModuleLoadProgress, false, 0, true);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleModuleLoadComplete, false, 0, true);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleModuleLoadError, false, 0, true);
_loader.load(new URLRequest(url));
}
private function handleModuleLoadError(event:IOErrorEvent):void{
Debug.error("[ModuleManager] ERROR: Could not load module!", event.text);
_module = null;
loaded = true;
}
}
}//package managers.modules
Section 26
//ModuleManager (managers.modules.ModuleManager)
package managers.modules {
import flash.events.*;
import debug.*;
import managers.ui.*;
import flash.display.*;
import global.*;
import utils.*;
import managers.resources.*;
import flash.system.*;
import flash.net.*;
public final class ModuleManager extends Sprite {
private var _moduleLayer:Sprite;
private var _loadingScreenLayer:Sprite;
private var _requestPush:Boolean;
private var _currentModuleInitialized:Boolean;
private var _resultParam:ParameterList;
private var _currentModule:Module;
private var btnMessageOk:ButtonCallback;
private var _loadingScreen:LoadingScreen;
private var _moduleStack:Array;
private var _embeddedResourceList:IEmbeddedData;
private var _showErrorMessage:Boolean;
public var testLayer:Sprite;
private var _requestPop:Boolean;
private var _messageLayer:Sprite;
private var _embeddedModuleList:IEmbeddedData;
private var _moduleDefinitionList:StringHashtable;
public static const MESSAGE_ERROR_W_BTN:int = 3;
public static const MESSAGE_INFO:int = 0;
public static const MESSAGE_FATAL_ERROR:int = 4;
public static const MESSAGE_WARNING_W_BTN:int = 2;
public static const MESSAGE_INFO_W_BTN:int = 1;
private static var _instance:ModuleManager = new ModuleManager(PrivateClass);
;
public function ModuleManager(c:Class){
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
private function hangGame():void{
stage.removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
stage.removeEventListener(Event.RENDER, handleRender);
}
private function handleMasterLoadComplete(event:Event):void{
var masterXML:XML;
var resListFilename:String;
var event = event;
masterXML = new XML(event.target.data);
resListFilename = String(masterXML.@resList);
ResourceManager.getInstance().loadMaster(resListFilename, (_embeddedResourceList) ? _embeddedResourceList.getDataList() : null);
_embeddedResourceList = null;
compileMaster(masterXML);
//unresolved jump
var _slot1 = e;
Debug.error("[ModuleManager] ERROR: Could not parse Master XML", _slot1.message);
showMessage("ERROR: Could not parse Master XML", MESSAGE_FATAL_ERROR);
}
public function updateFocus():void{
if (((!(_loadingScreen)) && (_currentModule))){
stage.focus = _currentModule;
};
}
public function getCurrentModule():Module{
return (_currentModule);
}
public function popModule(resultParam:ParameterList=null):void{
_resultParam = resultParam;
_requestPop = true;
}
private function instanceConstructor():void{
_requestPop = false;
_resultParam = null;
_moduleDefinitionList = new StringHashtable();
_moduleStack = new Array();
_moduleLayer = new Sprite();
_loadingScreenLayer = new Sprite();
_messageLayer = new Sprite();
testLayer = new Sprite();
this.addChild(_moduleLayer);
this.addChild(_loadingScreenLayer);
this.addChild(_messageLayer);
this.addChild(testLayer);
_currentModuleInitialized = false;
_showErrorMessage = false;
}
public function pushModule(id:String, loadingScreen:LoadingScreen=null, paramList:ParameterList=null, packageList:Array=null):void{
var i:String;
var iterator:String;
_requestPush = true;
Debug.trace("PUSH MODULE", _currentModule);
if (_loadingScreen){
Debug.warning("[ModuleManager] ERROR: cannot load 2 modules at the same time");
return;
};
if (!isLoadingFinished()){
Debug.warning("[ModuleManager] ERROR: cannot push Module while loading ResourceManager");
return;
};
if (_currentModule){
_moduleLayer.removeChild(_currentModule);
_currentModule = null;
};
var def:ModuleDefinition = (_moduleDefinitionList.getElement(id) as ModuleDefinition);
var resourcePackageList:Array = new Array();
for each (i in def.resourcePackageList) {
resourcePackageList.push(i);
};
if (packageList){
for each (i in packageList) {
if (resourcePackageList.indexOf(i) < 0){
resourcePackageList.push(i);
};
};
};
_loadingScreen = (loadingScreen) ? loadingScreen : new LoadingScreen();
_loadingScreenLayer.addChild(_loadingScreen);
_loadingScreen.create();
_loadingScreen.loadingProgress(false, 0);
var moduleParamList:ParameterList = def.defaultParamList.clone();
if (paramList){
moduleParamList.mergeWith(paramList);
};
Debug.trace("PARAMS:", moduleParamList.toString());
ResourceManager.getInstance().loadPackages(resourcePackageList);
var module:ModuleLoader = new ModuleLoader();
_moduleStack.unshift(module);
var useEmbeddedModule:Boolean;
var moduleId:String = id;
if (_embeddedModuleList){
for each (iterator in _embeddedModuleList.getDataList().keys()) {
if (id.indexOf(iterator) >= 0){
moduleId = iterator;
useEmbeddedModule = true;
break;
};
};
};
if (useEmbeddedModule){
this.stage.addChild(new EmbeddedMovieClipConversionTool((new ((_embeddedModuleList.getDataList().getElement(moduleId) as Class)) as MovieClip), module.loadEmbeddedModuleCallback, moduleParamList));
} else {
module.loadModule(def.url, moduleParamList);
};
}
public function handleEnterFrame(event:Event):void{
var loader:ModuleLoader;
var isDone:Boolean;
var progress:ProgressInfo;
var event = event;
if (!_showErrorMessage){
GlobalData.currentFrame++;
if (_loadingScreen){
stage.focus = _loadingScreen;
loader = (_moduleStack[0] as ModuleLoader);
isDone = ResourceManager.getInstance().isLoadingFinished();
progress = ResourceManager.getInstance().getProgess();
progress.bytesLoaded = (progress.bytesLoaded + loader.bytesLoaded);
progress.bytesTotal = (progress.bytesTotal + loader.bytesTotal);
_loadingScreen.loadingProgress(isDone, (progress.bytesTotal) ? Number((progress.bytesLoaded / progress.bytesTotal)) : 0);
if (((((loader.loaded) && (isDone))) && (_loadingScreen.isReadyToStart()))){
_loadingScreen.destroy();
_loadingScreenLayer.removeChild(_loadingScreen);
_loadingScreen = null;
_currentModule = loader.module;
_moduleLayer.addChild(_currentModule);
_currentModule.create();
//unresolved jump
var _slot1 = error;
Debug.error("ERROR Module.create()", _slot1.message, "\n", _slot1.getStackTrace());
showMessage("ERROR Module.create", MESSAGE_FATAL_ERROR);
_currentModuleInitialized = false;
stage.focus = _currentModule;
System.gc();
//unresolved jump
var _slot1 = error;
trace("ModuleManager - GC Error", _slot1);
};
} else {
if (_currentModule){
if (_requestPop){
if (_currentModule.uninitialize()){
_currentModuleInitialized = false;
_requestPop = false;
internalPopModule();
};
} else {
if (_currentModuleInitialized){
_currentModule.execute();
} else {
_currentModuleInitialized = _currentModule.initialize();
//unresolved jump
var _slot1 = error;
Debug.error("ERROR Module.initialize()", _slot1.message, "\n", _slot1.getStackTrace());
showMessage("ERROR Module.initialize", MESSAGE_FATAL_ERROR);
if (_currentModuleInitialized){
InputManager.getInstance().reset();
};
};
};
};
};
};
}
public function isLoadingFinished():Boolean{
return (ResourceManager.getInstance().isMasterLoaded());
}
public function showMessage(str:String, messageType:int):void{
var titleString:String;
var useButton:Boolean;
var str = str;
var messageType = messageType;
while (_messageLayer.numChildren > 0) {
_messageLayer.removeChildAt(0);
};
_messageLayer.graphics.clear();
_messageLayer.graphics.beginFill(0, 0.85);
_messageLayer.graphics.drawRect(0, 0, GlobalData.applicationWidth, GlobalData.applicationHeight);
switch (messageType){
case MESSAGE_INFO:
titleString = "INFORMATION";
useButton = false;
_showErrorMessage = false;
break;
case MESSAGE_INFO_W_BTN:
titleString = "INFORMATION";
useButton = true;
_showErrorMessage = true;
break;
case MESSAGE_WARNING_W_BTN:
titleString = "WARNING";
useButton = true;
_showErrorMessage = true;
break;
case MESSAGE_ERROR_W_BTN:
titleString = "ERROR";
useButton = true;
_showErrorMessage = true;
break;
case MESSAGE_FATAL_ERROR:
default:
titleString = "FATAL ERROR";
useButton = false;
_showErrorMessage = true;
hangGame();
break;
};
var mc:MovieClip = (ResourceManager.getInstance().getResource("popup") as MovieClip);
if (mc){
if (!useButton){
mc.hintBox.hintButtonText.visible = false;
} else {
mc.hintBox.hintButtonText.visible = true;
btnMessageOk = new ButtonCallback(mc.hintBox.hintButtonText, function ():void{
btnMessageOk = null;
hideMessage();
});
mc.hintBox.hintButtonText.text = "Ok";
};
mc.hintBox.hintTitle.text = titleString;
mc.hintBox.hintText.text = str;
_messageLayer.addChild(mc);
};
}
public function getModuleCount():int{
return (_moduleDefinitionList.size());
}
public function handleNetworkError(code:int):Boolean{
var str = (("Network Error Code[" + code) + "]");
showMessage(str, MESSAGE_FATAL_ERROR);
return (true);
}
public function pushModuleIndex(index:int, loadingScreen:LoadingScreen=null):void{
pushModule((_moduleDefinitionList.keys()[index] as String), loadingScreen, null);
}
public function getModuleDefinitionAtIndex(index:int):ModuleDefinition{
return ((_moduleDefinitionList.getElement((_moduleDefinitionList.keys()[index] as String)) as ModuleDefinition));
}
public function handleRender(event:Event):void{
if (((((!(_loadingScreen)) && (_currentModule))) && (_currentModuleInitialized))){
_currentModule.render();
};
}
private function internalPopModule():void{
var moduleLoader:ModuleLoader;
Debug.trace("POP MODULE", _currentModule);
if (_moduleStack.length > 0){
moduleLoader = (_moduleStack.shift() as ModuleLoader);
moduleLoader.module.destroy();
//unresolved jump
var _slot1 = error;
Debug.error("ERROR Module.destroy()", _slot1.message, "\n", _slot1.getStackTrace());
showMessage("ERROR Module.destroy", MESSAGE_FATAL_ERROR);
_moduleLayer.removeChild(moduleLoader.module);
moduleLoader.unloadModule();
_currentModule = null;
};
InputManager.getInstance().reset();
if (_moduleStack.length > 0){
moduleLoader = (_moduleStack[0] as ModuleLoader);
_currentModule = moduleLoader.module;
_moduleLayer.addChild(_currentModule);
if (_resultParam){
_currentModule.setResultParam(_resultParam);
_resultParam = null;
};
};
}
public function setMaster(masterList:XML, resourceList:XML, embeddedModuleList:IEmbeddedData, embeddedResourceList:IEmbeddedData):void{
_embeddedModuleList = embeddedModuleList;
ResourceManager.getInstance().setMaster(resourceList, (embeddedResourceList) ? embeddedResourceList.getDataList() : null);
compileMaster(masterList);
}
public function hideMessage():void{
_messageLayer.graphics.clear();
while (_messageLayer.numChildren > 0) {
_messageLayer.removeChildAt(0);
};
_showErrorMessage = false;
}
public function loadMaster(url:String, embeddedModuleList:IEmbeddedData, embeddedResourceList:IEmbeddedData):void{
_embeddedModuleList = embeddedModuleList;
_embeddedResourceList = embeddedResourceList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
xmlLoader.addEventListener(Event.COMPLETE, handleMasterLoadComplete, false, 0, true);
xmlLoader.load(new URLRequest(url));
}
public function getModuleCountVisible():int{
var def:ModuleDefinition;
var count:int;
for each (def in _moduleDefinitionList.elements()) {
if (def.visible){
count++;
};
};
return (count);
}
private function compileMaster(masterXML:XML):void{
var def:ModuleDefinition;
var x:XML;
var i:int;
while (i < masterXML.module.length()) {
def = new ModuleDefinition();
def.name = String(masterXML.module[i].@name);
def.url = String(masterXML.module[i].@url);
def.visible = ((String(masterXML.module[i].@visible).toLowerCase())=="true") ? true : false;
for each (x in masterXML..module[i].resourcePackage) {
def.resourcePackageList.push(String(x.@name));
};
for each (x in masterXML..module[i].param) {
def.defaultParamList.set(String(x.@name), String(x.@value));
};
_moduleDefinitionList.put(def.name, def);
i++;
};
stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
stage.addEventListener(Event.RENDER, handleRender);
}
public static function getInstance():ModuleManager{
return (_instance);
}
}
}//package managers.modules
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 27
//ParameterList (managers.modules.ParameterList)
package managers.modules {
import utils.*;
public final class ParameterList {
private var _paramList:StringHashtable;
public function ParameterList(obj:Object=null){
super();
_paramList = new StringHashtable(obj);
}
public function size():int{
return (_paramList.size());
}
public function getNames():Array{
return (_paramList.keys());
}
public function remove(name:String):void{
_paramList.remove(name);
}
public function get(name:String):String{
if (_paramList.containsKey(name)){
return ((_paramList.getElement(name) as String));
};
return ("");
}
public function set(name:String, value:String):void{
if (_paramList.containsKey(name)){
_paramList.remove(name);
};
_paramList.put(name, value);
}
public function toString():String{
var s:String;
var key:String;
var list:Array = _paramList.keys();
s = (("PARAM LIST [" + list.length) + "]\n");
for each (key in list) {
s = (s + (((((" KEY='" + key) + "'") + " VALUE='") + (_paramList.getElement(key) as String)) + "'\n"));
};
return (s);
}
public function clone():ParameterList{
var key:String;
var cloneObj:ParameterList = new ParameterList();
for each (key in _paramList.keys()) {
cloneObj._paramList.put(key, _paramList.getElement(key));
};
return (cloneObj);
}
public function mergeWith(list:ParameterList, overwrite:Boolean=true):void{
var key:String;
for each (key in list._paramList.keys()) {
_paramList.put(key, list._paramList.getElement(key));
};
}
}
}//package managers.modules
Section 28
//AnchorData (managers.objects.AnchorData)
package managers.objects {
public final class AnchorData {
private var _id:int;
private var _anchor:String;
public function AnchorData(id:int, anchor:String){
super();
_id = id;
_anchor = anchor;
}
public function get anchorId():String{
return (_anchor);
}
public function get objectId():int{
return (_id);
}
}
}//package managers.objects
Section 29
//FXObject (managers.objects.FXObject)
package managers.objects {
import animation.*;
public final class FXObject {
public var animatedObject:AnimatedObject;// = null
public var attachToObject:AnchorData;// = null
public var inUse:Boolean;// = false
public var startTime:Number;
public var timeToLive:Number;
public var timerType:int;
public function FXObject(){
super();
}
}
}//package managers.objects
Section 30
//FXObjectDefinition (managers.objects.FXObjectDefinition)
package managers.objects {
public class FXObjectDefinition {
public var visualDataAnim:String;
public var visualDataType:String;
public var type:String;
public var timerType:int;
public function FXObjectDefinition(){
super();
}
}
}//package managers.objects
Section 31
//FXObjectManager (managers.objects.FXObjectManager)
package managers.objects {
import debug.*;
import flash.display.*;
import physic.*;
import global.*;
import utils.*;
import animation.*;
public final class FXObjectManager {
private const MAX_FXOBJECT_INSTANCE_COUNT:int = 32;
private var _fxObjectList:Array;
private var _fxObjectDefinitions:StringHashtable;
private var _layer:Sprite;
public function FXObjectManager(layer:Sprite){
super();
_layer = layer;
_fxObjectDefinitions = new StringHashtable();
_fxObjectList = new Array(MAX_FXOBJECT_INSTANCE_COUNT);
var i:int;
while (i < _fxObjectList.length) {
_fxObjectList[i] = new FXObject();
i++;
};
}
public function update():void{
var currentTime:Number;
var deltaTime:Number;
var iterator:FXObject;
var v:Vec2;
for each (iterator in _fxObjectList) {
if (iterator.inUse){
currentTime = GameTimer.getTimerByType(iterator.timerType);
deltaTime = GameTimer.getDeltaTimeByType(iterator.timerType);
if (((!(iterator.animatedObject.isPlaying())) || (((iterator.startTime + iterator.timeToLive) < currentTime)))){
destroyFXObject(iterator);
} else {
iterator.animatedObject.update(deltaTime);
if (iterator.attachToObject){
v = GameObjectManager.getInstance().getAnchorPosition(iterator.attachToObject);
if (v){
iterator.animatedObject.x = v.x;
iterator.animatedObject.y = v.y;
};
};
};
};
};
}
private function destroyFXObject(obj:FXObject):void{
if (this._layer.contains(obj.animatedObject)){
this._layer.removeChild(obj.animatedObject);
};
obj.animatedObject.destroy();
obj.animatedObject = null;
obj.inUse = false;
}
public function CreateFXObject(type:String, position:Object, mirror:Boolean=false):Boolean{
var iterator:FXObject;
var v:Vec2;
var def:FXObjectDefinition = (_fxObjectDefinitions.getElement(type) as FXObjectDefinition);
if (!def){
Debug.trace(("ERROR: FXObject definition not found for type " + type));
return (false);
};
for each (iterator in _fxObjectList) {
if (!iterator.inUse){
iterator.animatedObject = new AnimatedObject();
this._layer.addChild(iterator.animatedObject);
iterator.animatedObject.setData(def.visualDataType);
iterator.animatedObject.playAnim(def.visualDataAnim, false);
iterator.animatedObject.setMirror(mirror);
if ((position is Vec2)){
iterator.attachToObject = null;
iterator.animatedObject.x = position.x;
iterator.animatedObject.y = position.y;
} else {
if ((position is AnchorData)){
iterator.attachToObject = (position as AnchorData);
v = GameObjectManager.getInstance().getAnchorPosition(iterator.attachToObject);
if (v){
iterator.animatedObject.x = v.x;
iterator.animatedObject.y = v.y;
};
};
};
iterator.startTime = GameTimer.getTimerByType(GameTimer.TIMER_ABSOLUTE);
iterator.timeToLive = 2;
iterator.inUse = true;
return (true);
};
};
return (false);
}
public function InjectFXObjectDefinition(def:FXObjectDefinition):void{
_fxObjectDefinitions.put(def.type, def);
}
public function destroy():void{
_fxObjectDefinitions = null;
_fxObjectList = null;
}
}
}//package managers.objects
Section 32
//GameLayerManager (managers.objects.GameLayerManager)
package managers.objects {
import debug.*;
import flash.display.*;
import physic.*;
import global.*;
import utils.*;
import managers.modules.*;
public final class GameLayerManager {
private const _cameraFlashDuration:Number = 1;
private var _cameraFlashTime:Number;// = 0
private var _layerParallaxSpeed:Array;
public var CameraPosition:Vec2;
private var _cameraShakeTime:Number;// = 0
private var _overlay:Sprite;
private var _cameraShakeVec:Vec2;
public var _freeCameraMode:Boolean;
private var _initialized:Boolean;
private var _cameraFlashMode:Boolean;// = false
public var CameraBottomBound:Vec2;
private var _layers:Array;
private var _debugLayer:Sprite;
private var _cameraShakeMode:Boolean;// = false
private var _hudLayer:Sprite;
public static const LAYER_BACKGOUND_1:int = 6;
public static const LAYER_BACKGOUND_2:int = 8;
public static const LAYER_FOREGROUND_1:int = 2;
public static const LAYER_BACKGOUND_3:int = 9;
public static const LAYER_BACKGOUND_4:int = 10;
private static const LAYER_COUNT:int = 12;
public static const LAYER_BACKGOUND_TEST:int = 7;
public static const LAYER_FARTHEST:int = 11;
public static const LAYER_CLOSEST:int = 0;
public static const LAYER_GAME_1:int = 1;
public static const LAYER_GAME_2:int = 3;
public static const LAYER_GAME_3:int = 4;
public static const LAYER_GAME_4:int = 5;
private static var _instance:GameLayerManager = new GameLayerManager(PrivateClass);
;
public function GameLayerManager(c:Class){
_cameraShakeVec = new Vec2();
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
public function destroy():void{
var layerSprite:Sprite;
var i:int;
while (i < LAYER_COUNT) {
layerSprite = (_layers[i] as Sprite);
removeChildrenRecursive(layerSprite);
if (layerSprite.parent){
layerSprite.parent.removeChild(layerSprite);
};
if (layerSprite){
while (layerSprite.numChildren > 0) {
layerSprite.removeChildAt(0);
};
};
i++;
};
if (_overlay.parent){
_overlay.parent.removeChild(_overlay);
};
_overlay = null;
if (_hudLayer.parent){
_hudLayer.parent.removeChild(_hudLayer);
};
_hudLayer = null;
if (_debugLayer.parent){
_debugLayer.parent.removeChild(_debugLayer);
};
_debugLayer = null;
_layers = null;
_layerParallaxSpeed = null;
CameraBottomBound = null;
CameraPosition = null;
_initialized = false;
}
public function create(parentDisplayObject:DisplayObjectContainer):void{
_layers = new Array(LAYER_COUNT);
_layerParallaxSpeed = new Array(LAYER_COUNT);
CameraBottomBound = new Vec2(0, 0);
CameraPosition = new Vec2(0, 0);
_freeCameraMode = false;
setParentDisplayObject(parentDisplayObject);
_initialized = true;
if (!_overlay){
_overlay = new Sprite();
};
if (!_hudLayer){
_hudLayer = new Sprite();
};
if (!_debugLayer){
_debugLayer = new Sprite();
};
}
public function isInitialized():Boolean{
return (_initialized);
}
public function cameraFlash():void{
_cameraFlashMode = true;
_cameraFlashTime = GameTimer.getTimerByType(GameTimer.TIMER_ABSOLUTE);
}
public function getHudLayer():Sprite{
return (_hudLayer);
}
public function set CameraInFreeMode(free:Boolean):void{
_freeCameraMode = free;
}
public function getLayer(index:int):Sprite{
return ((_layers[index] as Sprite));
}
private function instanceConstructor():void{
_initialized = false;
_cameraShakeMode = false;
}
public function setLayerParallaxSpeed(index:int, speed:Number):void{
_layerParallaxSpeed[index] = speed;
}
public function Update(deltaTime:Number):void{
var ratio:Number;
var layerSprite:Sprite;
var layerSpeed:Number;
if (_cameraShakeMode){
_cameraShakeVec.x = ((Math.random() * 4) - 2);
_cameraShakeVec.y = ((Math.random() * 4) - 2);
if (_cameraShakeTime < GameTimer.getTimerByType(GameTimer.TIMER_ABSOLUTE)){
_cameraShakeMode = false;
_cameraShakeVec.x = 0;
_cameraShakeVec.y = 0;
};
};
if (_cameraFlashMode){
_overlay.graphics.clear();
ratio = ((GameTimer.getTimerByType(GameTimer.TIMER_ABSOLUTE) - _cameraFlashTime) / _cameraFlashDuration);
ratio = (1 - Math.max(0, Math.min(1, ratio)));
if (ratio <= 0){
_cameraFlashMode = false;
} else {
_overlay.graphics.beginFill(0xFFFFFF, (ratio * ratio));
_overlay.graphics.drawRect(0, 0, GlobalData.applicationWidth, GlobalData.applicationHeight);
};
};
var i:int = LAYER_CLOSEST;
while (i < LAYER_COUNT) {
layerSprite = (_layers[i] as Sprite);
layerSpeed = (_layerParallaxSpeed[i] as Number);
if (layerSprite != null){
layerSprite.x = ((CameraPosition.x + _cameraShakeVec.x) * layerSpeed);
layerSprite.y = ((CameraPosition.y + _cameraShakeVec.y) * layerSpeed);
};
i++;
};
}
private function setParentDisplayObject(s:DisplayObjectContainer):void{
var i:int;
var sp:Sprite;
var baseSpeed:Number;
if (s != null){
i = 0;
while (i < LAYER_COUNT) {
sp = new Sprite();
s.addChildAt(sp, 0);
_layers[i] = sp;
baseSpeed = 1;
setLayerParallaxSpeed(i, 1);
i++;
};
if (!_overlay){
_overlay = new Sprite();
};
s.addChild(_overlay);
if (!_hudLayer){
_hudLayer = new Sprite();
};
s.addChild(_hudLayer);
if (!_debugLayer){
_debugLayer = new Sprite();
};
s.addChild(_debugLayer);
setLayerParallaxSpeed(LAYER_BACKGOUND_TEST, 0);
setLayerParallaxSpeed(LAYER_BACKGOUND_2, 0.8);
setLayerParallaxSpeed(LAYER_BACKGOUND_3, 0.6);
setLayerParallaxSpeed(LAYER_BACKGOUND_4, 0.4);
} else {
Debug.trace("stage passed to GameLayerManager::setStage is null");
};
}
public function cameraShake():void{
_cameraShakeMode = true;
_cameraShakeTime = (GameTimer.getTimerByType(GameTimer.TIMER_ABSOLUTE) + 1.5);
}
public function cameraReset():void{
_cameraFlashMode = false;
_cameraFlashTime = 0;
_cameraShakeMode = false;
_cameraShakeTime = 0;
}
public function getDebugLayer():Sprite{
return (_debugLayer);
}
public function getLayerParallaxSpeed(index:int):Number{
return ((_layerParallaxSpeed[index] as Number));
}
public function get isFreeCameraMode():Boolean{
return (_freeCameraMode);
}
public static function getInstance():GameLayerManager{
return (_instance);
}
public static function removeChildrenRecursive(paramObj:DisplayObject):void{
var obj:DisplayObjectContainer;
var child:DisplayObject;
if ((paramObj is DisplayObjectContainer)){
obj = (paramObj as DisplayObjectContainer);
while (obj.numChildren > 0) {
child = obj.getChildAt(0);
removeChildrenRecursive(child);
obj.removeChild(child);
};
};
}
}
}//package managers.objects
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 33
//GameObject (managers.objects.GameObject)
package managers.objects {
import flash.display.*;
import physic.*;
import global.*;
import animation.*;
import managers.sounds.*;
public class GameObject implements IGameObject {
public var active:Boolean;// = true
public var velocity:Vec2;
public var timerType:int;
private var _displayObject:IDisplayableObject;
public var position:Vec2;
public var relativeBoundingBox:Rect;
public var onScreen:Boolean;
private var _id:uint;// = 0
public function GameObject(){
super();
}
public function get type():uint{
return (GlobalData.GO_TYPE_UNDEFINED);
}
final public function set displayObject(obj:IDisplayableObject):void{
_displayObject = obj;
}
final public function get boundingBox():Rect{
return (new Rect((relativeBoundingBox.x + position.x), (relativeBoundingBox.y + position.y), relativeBoundingBox.width, relativeBoundingBox.height));
}
final public function get id():uint{
return (_id);
}
final public function selfDestruction():void{
GameObjectManager.getInstance().destroyGameObject(_id);
}
final public function debugDisplayObject(debugGraphics:Graphics):void{
if (Physic.SHOW_DEBUG_STUFF){
debugGraphics.beginFill((active) ? 0xFF0000 : 0xFF, 0.2);
debugGraphics.drawRect(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height);
debugGraphics.endFill();
};
}
public function update(currentTime:Number, deltaTime:Number):void{
}
protected function internalDestroy():void{
}
protected function internalCreate():void{
}
final public function destroy():void{
internalDestroy();
if (((_displayObject) && ((_displayObject is IDisplayableObject)))){
(_displayObject as IDisplayableObject).destroy();
};
_displayObject = null;
velocity = null;
position = null;
relativeBoundingBox = null;
}
public function get layer():int{
return (GameLayerManager.LAYER_CLOSEST);
}
final public function get displayObject():IDisplayableObject{
return (_displayObject);
}
final public function playProximitySound(id:String):void{
var pan:Number = ((-(GameLayerManager.getInstance().CameraPosition.x) + (GlobalData.applicationWidth / 2)) - position.x);
pan = (pan / -(GlobalData.applicationWidth));
SoundManager.getInstance().playProximitySound(id, pan);
}
final public function set id(objId:uint):void{
_id = objId;
}
final public function create():void{
_displayObject = null;
velocity = new Vec2();
position = new Vec2();
relativeBoundingBox = new Rect();
internalCreate();
}
}
}//package managers.objects
Section 34
//GameObjectManager (managers.objects.GameObjectManager)
package managers.objects {
import debug.*;
import flash.display.*;
import physic.*;
import global.*;
import animation.*;
public class GameObjectManager {
private var _gameObjects:Array;// = null
private var _projectileManager:ProjectileManager;// = null
private var _destroyRequestList:Array;// = null
private var _fxObjectManager:FXObjectManager;// = null
public static const onScreenBoxBorder:Number = 50;
public static const onScreenBox:Rect = new Rect();
private static const DEBUG_MODE:Boolean = true;
private static var UID_PROVIDER:uint = 1;
private static var _instance:GameObjectManager = new GameObjectManager(PrivateClass);
;
public function GameObjectManager(c:Class){
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
public function destroy():void{
while (_gameObjects.length > 0) {
(_gameObjects.pop() as IGameObject).destroy();
};
_gameObjects = null;
_destroyRequestList = null;
_fxObjectManager.destroy();
_projectileManager.destroy();
}
public function get projectileManager():ProjectileManager{
return (_projectileManager);
}
public function getGameObject(id:uint):GameObject{
var iterator:GameObject;
for each (iterator in _gameObjects) {
if (id == iterator.id){
return (iterator);
};
};
return (null);
}
public function update():void{
var obj:GameObject;
fxObjectManager.update();
projectileManager.update();
var debugGraphics:Graphics;
if (DEBUG_MODE){
if (GameLayerManager.getInstance().isInitialized()){
debugGraphics = GameLayerManager.getInstance().getLayer(GameLayerManager.LAYER_FOREGROUND_1).graphics;
debugGraphics.clear();
};
};
for each (obj in _gameObjects) {
obj.onScreen = Physic.isRectIntersectRect(onScreenBox, obj.boundingBox);
obj.update(GameTimer.getTimerByType(obj.timerType), GameTimer.getDeltaTimeByType(obj.timerType));
if (obj.displayObject){
if (obj.onScreen){
if ((obj.displayObject is IAnimatedObject)){
obj.displayObject.visible = true;
(obj.displayObject as IAnimatedObject).update(GameTimer.getDeltaTimeByType(obj.timerType));
};
if (((DEBUG_MODE) && (debugGraphics))){
obj.debugDisplayObject(debugGraphics);
};
} else {
obj.displayObject.visible = false;
};
};
};
while (_destroyRequestList.length > 0) {
internalDestroyGameObject(_destroyRequestList.pop());
};
}
private function instanceConstructor():void{
}
public function createGameObject(gameObjectClass:Class, ... _args):uint{
var it:Object;
var s:Sprite;
var id:int = UID_PROVIDER++;
var newObj:GameObject = new (gameObjectClass);
var layerIndex:int = newObj.layer;
newObj.id = id;
newObj.create();
for each (it in _args) {
if ((it is Vec2)){
newObj.position.x = (it as Vec2).x;
newObj.position.y = (it as Vec2).y;
};
};
s = GameLayerManager.getInstance().getLayer(layerIndex);
if (s){
if (newObj.displayObject){
s.addChild((newObj.displayObject as DisplayObject));
} else {
Debug.trace((("New object of type " + gameObjectClass) + " has no graphics !"));
};
} else {
Debug.trace(("Cannot find layer=" + layerIndex));
};
_gameObjects.push(newObj);
return (id);
}
private function internalDestroyGameObject(id:uint):void{
var obj:GameObject = getGameObject(id);
if (obj){
obj.destroy();
_gameObjects.splice(_gameObjects.indexOf(obj), 1);
};
}
public function getAvatar():GameObject{
var list:Array = getGameObjectsByType(GlobalData.GO_TYPE_AVATAR);
if (list.length > 0){
return (list[0]);
};
return (new GameObject());
}
public function create():void{
_gameObjects = new Array();
_destroyRequestList = new Array();
_projectileManager = new ProjectileManager(GameLayerManager.getInstance().getLayer(GameLayerManager.LAYER_GAME_2));
_fxObjectManager = new FXObjectManager(GameLayerManager.getInstance().getLayer(GameLayerManager.LAYER_GAME_2));
}
public function getGameObjectsByType(type:uint):Array{
var iterator:GameObject;
var objectList:Array = new Array();
for each (iterator in _gameObjects) {
if ((iterator.type & type) != 0){
objectList.push(iterator);
};
};
return (objectList);
}
public function destroyGameObject(id:uint):void{
_destroyRequestList.push(id);
}
public function getAnchorPosition(anchorData:AnchorData):Vec2{
var ao:IAnimatedObject;
var go:IGameObject = getGameObject(anchorData.objectId);
if (go){
ao = (go.displayObject as IAnimatedObject);
if (ao){
return (ao.getAnchor(anchorData.anchorId));
};
};
return (null);
}
public function get fxObjectManager():FXObjectManager{
return (_fxObjectManager);
}
public static function objectIs(obj:GameObject, type:uint):Boolean{
return (!(((obj.type & type) == 0)));
}
public static function getInstance():GameObjectManager{
return (_instance);
}
public static function setNewLayer(newObj:GameObject, lay:uint):void{
var layerIndex:int;
var s:Sprite;
if (((newObj.layer) && (newObj.displayObject))){
layerIndex = newObj.layer;
s = GameLayerManager.getInstance().getLayer(layerIndex);
(newObj.displayObject as DisplayObject).parent.removeChild((newObj.displayObject as DisplayObject));
s = GameLayerManager.getInstance().getLayer(lay);
s.addChild((newObj.displayObject as DisplayObject));
};
}
}
}//package managers.objects
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 35
//IGameObject (managers.objects.IGameObject)
package managers.objects {
import flash.display.*;
import animation.*;
public interface IGameObject {
function get displayObject():IDisplayableObject;
function set displayObject(Z:\Shared;managers\objects;IGameObject.as:IDisplayableObject):void;
function set id(Z:\Shared;managers\objects;IGameObject.as:uint):void;
function get type():uint;
function update(_arg1:Number, _arg2:Number):void;
function destroy():void;
function get id():uint;
function create():void;
function debugDisplayObject(Z:\Shared;managers\objects;IGameObject.as:Graphics):void;
}
}//package managers.objects
Section 36
//Projectile (managers.objects.Projectile)
package managers.objects {
import flash.display.*;
import physic.*;
import animation.*;
public final class Projectile {
public var type:int;
public var boundingBox:Rect;
public var firingObjectId:uint;
public var startTime:Number;
public var offset:Vec2;
public var hitPoints:Number;// = 1
public var velocity:Vec2;
public var timerType:int;
public var displayObject:DisplayObject;// = null
public var inUse:Boolean;// = false
public var position:Vec2;
public var toBeCleared:Boolean;// = false
public var oldPosition:Vec2;
public var velocityMultiplier:Number;
public function Projectile(){
super();
}
public function LoadFromDefinition(def:ProjectileDefinition, mirror:Boolean):void{
type = def.type;
timerType = def.timerType;
velocityMultiplier = def.velocityMultiplier;
boundingBox = def.boundingBox;
offset = def.offset;
displayObject = new Image();
(displayObject as Image).setData(def.templateVisualData, offset);
(displayObject as Image).setMirror(mirror);
}
}
}//package managers.objects
Section 37
//ProjectileDefinition (managers.objects.ProjectileDefinition)
package managers.objects {
import physic.*;
public class ProjectileDefinition {
public var stopFX:String;// = ""
public var templateVisualData:String;
public var boundingBox:Rect;
public var maximumOnScreen:int;
public var collisionFX:String;// = ""
public var offset:Vec2;
public var type:int;
public var startFX:String;// = ""
public var velocityMultiplier:Number;
public var timerType:int;
public function ProjectileDefinition(){
offset = Vec2.ZERO;
super();
}
}
}//package managers.objects
Section 38
//ProjectileManager (managers.objects.ProjectileManager)
package managers.objects {
import debug.*;
import flash.display.*;
import physic.*;
import global.*;
import utils.*;
import animation.*;
public final class ProjectileManager {
private const MAX_PROJECTILE_INSTANCE_COUNT:int = 64;
private const MAX_PROJECTILE_DEFINITION:int = 16;
private var _projectiles:Hashtable;
private var _layer:Sprite;
private var _projectileDefinitions:Hashtable;
private var debugGraphics:Graphics;// = null
public static const maximumScreenProjectiles:int = 10;
private static const DEBUG_MODE:Boolean = true;
public function ProjectileManager(layer:Sprite){
super();
_layer = layer;
_projectileDefinitions = new Hashtable();
_projectiles = new Hashtable();
}
public function checkForNearCollision(pos:Vec2, dist:Number):Boolean{
var currentTime:Number;
var deltaTime:Number;
var prjTypeId:int;
var projectileTypeArray:Array;
var iterator:Projectile;
dist = (dist * dist);
var projectileIdList:Array = _projectiles.keys();
for each (prjTypeId in projectileIdList) {
projectileTypeArray = (_projectiles.getElement(prjTypeId) as Array);
for each (iterator in projectileTypeArray) {
if (iterator.inUse){
if (dist > Vec2.distanceSquared(iterator.position, pos)){
return (true);
};
};
};
};
return (false);
}
public function CreateProjectile(objectId:uint, type:int, position:Object, velocity:Vec2, hitPoints:Number, mirror:Boolean=false):Boolean{
var iterator:Projectile;
var v:Vec2;
var prjDef:ProjectileDefinition = (_projectileDefinitions.getElement(type) as ProjectileDefinition);
if (!prjDef){
Debug.trace(("ERROR: projectile definition not found for type " + type));
return (false);
};
var pArray:Array = (_projectiles.getElement(type) as Array);
for each (iterator in pArray) {
if (!iterator.inUse){
iterator.LoadFromDefinition(prjDef, mirror);
if ((position is Vec2)){
iterator.position = position.clone();
} else {
if ((position is AnchorData)){
v = GameObjectManager.getInstance().getAnchorPosition((position as AnchorData));
if (v){
iterator.position = v.clone();
};
};
};
iterator.hitPoints = hitPoints;
iterator.oldPosition = iterator.position.clone();
iterator.firingObjectId = objectId;
iterator.velocity = velocity;
_layer.addChild(iterator.displayObject);
iterator.inUse = true;
launchFXObject(prjDef.startFX, position, mirror);
return (true);
};
};
Debug.trace(("WARNING: not enough projectile in pool for type " + type));
return (false);
}
private function launchFXObject(type:String, position:Object, mirror:Boolean=false):void{
if (((type) && (!((type == ""))))){
GameObjectManager.getInstance().fxObjectManager.CreateFXObject(type, position, mirror);
};
}
public function update():void{
var currentTime:Number;
var deltaTime:Number;
var prjTypeId:int;
var prjDef:ProjectileDefinition;
var projectileTypeArray:Array;
var iterator:Projectile;
var velocity:Vec2;
if (((DEBUG_MODE) && (Physic.SHOW_DEBUG_STUFF))){
if (GameLayerManager.getInstance().isInitialized()){
debugGraphics = GameLayerManager.getInstance().getLayer(GameLayerManager.LAYER_FOREGROUND_1).graphics;
};
};
var projectileIdList:Array = _projectiles.keys();
var typeCount:int = _projectiles.size();
for each (prjTypeId in projectileIdList) {
prjDef = (_projectileDefinitions.getElement(prjTypeId) as ProjectileDefinition);
projectileTypeArray = (_projectiles.getElement(prjTypeId) as Array);
for each (iterator in projectileTypeArray) {
if (iterator.inUse){
currentTime = GameTimer.getTimerByType(iterator.timerType);
deltaTime = GameTimer.getDeltaTimeByType(iterator.timerType);
if (iterator.toBeCleared){
_layer.removeChild(iterator.displayObject);
if ((iterator.displayObject is AnimatedObject)){
(iterator.displayObject as AnimatedObject).destroy();
};
iterator.inUse = false;
iterator.toBeCleared = false;
} else {
velocity = iterator.velocity.getMultiplyBy((iterator.velocityMultiplier * deltaTime));
iterator.oldPosition.x = iterator.position.x;
iterator.oldPosition.y = iterator.position.y;
if (!Physic.isVecIntersectRect(iterator.position, GameObjectManager.onScreenBox)){
iterator.toBeCleared = true;
} else {
if ((((((((iterator.position.x < 0)) || ((iterator.position.x > 10000)))) || ((iterator.position.y < 0)))) || ((iterator.position.y > 10000)))){
iterator.toBeCleared = true;
} else {
if (Physic.updateProjectilePosition(iterator.oldPosition, iterator.position, velocity)){
iterator.toBeCleared = true;
launchFXObject(prjDef.stopFX, iterator.position);
};
};
};
if ((iterator.displayObject is AnimatedObject)){
(iterator.displayObject as AnimatedObject).update(deltaTime);
};
iterator.displayObject.x = iterator.position.x;
iterator.displayObject.y = iterator.position.y;
};
if (((((DEBUG_MODE) && (Physic.SHOW_DEBUG_STUFF))) && (debugGraphics))){
debugGraphics.beginFill(0xFFFF, 0.2);
debugGraphics.drawCircle(iterator.position.x, iterator.position.y, 5);
debugGraphics.endFill();
};
};
};
};
}
public function InjectProjectileDefinition(def:ProjectileDefinition):void{
_projectileDefinitions.put(def.type, def);
var newArray:Array = new Array(def.maximumOnScreen);
var i:int;
while (i < def.maximumOnScreen) {
newArray[i] = new Projectile();
i++;
};
_projectiles.put(def.type, newArray);
}
public function checkForCollision(objectId:uint, boundingBox:Rect, callback:Function):void{
var currentTime:Number;
var deltaTime:Number;
var prjTypeId:int;
var prjDef:ProjectileDefinition;
var projectileTypeArray:Array;
var iterator:Projectile;
var projectileIdList:Array = _projectiles.keys();
var displacement:Line = new Line();
var dispBBox:Rect = new Rect();
for each (prjTypeId in projectileIdList) {
prjDef = (_projectileDefinitions.getElement(prjTypeId) as ProjectileDefinition);
projectileTypeArray = (_projectiles.getElement(prjTypeId) as Array);
for each (iterator in projectileTypeArray) {
if (((iterator.inUse) && (!((iterator.firingObjectId == objectId))))){
displacement.pt1 = iterator.oldPosition;
displacement.pt2 = iterator.position;
dispBBox.x = Math.min(displacement.pt1.x, displacement.pt2.x);
dispBBox.y = Math.min(displacement.pt1.y, displacement.pt2.y);
dispBBox.width = Math.abs((displacement.pt1.x - displacement.pt2.x));
dispBBox.height = Math.abs((displacement.pt1.y - displacement.pt2.y));
if (Physic.isRectIntersectRect(boundingBox, dispBBox)){
callback(prjTypeId, iterator.velocity, iterator.hitPoints);
iterator.toBeCleared = true;
launchFXObject(prjDef.stopFX, iterator.position);
};
};
};
};
}
public function destroy():void{
_layer = null;
_projectiles.clear();
_projectileDefinitions.clear();
}
}
}//package managers.objects
Section 39
//EmbeddedMovieClipConversionTool (managers.resources.EmbeddedMovieClipConversionTool)
package managers.resources {
import flash.events.*;
import flash.display.*;
public final class EmbeddedMovieClipConversionTool extends Sprite {
private var _loader:Loader;
private var _callback:Function;
private var _param:Object;
public function EmbeddedMovieClipConversionTool(mc:MovieClip, fct:Function, param:Object){
super();
_param = param;
_loader = (mc.getChildAt(0) as Loader);
_callback = fct;
this.addEventListener(Event.ADDED_TO_STAGE, addedToStage);
this.visible = false;
}
private function enterFrame(event:Event):void{
if (_loader.content){
_callback(_loader.content, _param);
_param = null;
_callback = null;
_loader = null;
this.stage.removeEventListener(Event.ENTER_FRAME, enterFrame);
this.parent.removeChild(this);
};
}
private function addedToStage(event:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
this.stage.addEventListener(Event.ENTER_FRAME, enterFrame);
}
}
}//package managers.resources
Section 40
//ICompiledResource (managers.resources.ICompiledResource)
package managers.resources {
public interface ICompiledResource {
}
}//package managers.resources
Section 41
//IEmbeddedData (managers.resources.IEmbeddedData)
package managers.resources {
import utils.*;
public interface IEmbeddedData {
function getDataList():StringHashtable;
}
}//package managers.resources
Section 42
//ProgressInfo (managers.resources.ProgressInfo)
package managers.resources {
public class ProgressInfo {
public var bytesLoaded:Number;// = 0
public var bytesTotal:Number;// = 0
public function ProgressInfo(){
super();
}
}
}//package managers.resources
Section 43
//Resource (managers.resources.Resource)
package managers.resources {
import flash.events.*;
import debug.*;
import flash.display.*;
import managers.modules.*;
import flash.media.*;
import flash.net.*;
public class Resource {
public var _package:String;// = ""
public var _data:Object;// = null
public var embedded:Boolean;
public var bytesLoaded:uint;// = 0
public var bytesTotal:uint;// = 0
public var _loader:Object;// = null
public var _type:String;// = ""
public var _isLoaded:Boolean;// = false
public var _size:uint;// = 0
public var _url:String;// = ""
public var _id:String;// = ""
public static const RES_XML_DATA:String = "xml_data";
public static const RES_SWF_NORMAL:String = "swf";
public static const RES_PURE_SWF_NEEDCOMPILATION:String = "pure_swf_needcompilation";
public static const RES_SOUND:String = "sound";
public static const RES_SWF_NEEDCOMPILATION:String = "swf_needcompilation";
public static const RES_UNDEFINED:String = "undefined";
public static const RES_SWF_SINGLEFRAME:String = "swf_singleframe";
public static const RES_IMG_NEEDCOMPILATION:String = "img_needcompilation";
public function Resource(){
super();
}
public function handleLoadError(event:IOErrorEvent):void{
Debug.warning("\n#######################################################");
Debug.warning("ERROR: [Resource] Load Error :", _id, event.text);
Debug.warning("#######################################################\n");
bytesLoaded = (bytesTotal = 0);
_loader = null;
_isLoaded = true;
_data = null;
}
public function handleLoadComplete(event:Event):void{
if ((event.target is Sound)){
_data = (event.target as Sound);
};
if ((event.target is URLLoader)){
_data = (event.target as URLLoader).data;
} else {
if ((event.target is LoaderInfo)){
_data = (event.target as LoaderInfo).loader.content;
};
};
ResourceManager.getInstance().compileResource(this);
bytesLoaded = bytesTotal;
}
public function handleLoadProgress(event:ProgressEvent):void{
bytesLoaded = event.bytesLoaded;
bytesTotal = event.bytesTotal;
ModuleManager.getInstance().handleEnterFrame(null);
}
}
}//package managers.resources
Section 44
//ResourceManager (managers.resources.ResourceManager)
package managers.resources {
import flash.events.*;
import debug.*;
import managers.ui.*;
import flash.display.*;
import utils.*;
import managers.modules.*;
import animation.*;
import flash.media.*;
import flash.system.*;
import flash.net.*;
public final class ResourceManager extends Sprite {
private var _loadingPendingResourceList:Array;
private var _loadedResourceList:Array;
private var embeddedDataList:StringHashtable;
private var totalDownloadedBytes:Number;
private var _masterLoaded:Boolean;
private var _dictionary:StringHashtable;
private static var _instance:ResourceManager = new ResourceManager(PrivateClass);
;
public static var GAMEASSET_PATH:String = "";
public function ResourceManager(c:Class){
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
public function loadPackages(packageList:Array):void{
var pack:String;
var res:String;
var resource:Resource;
var list:Array = new Array();
for each (pack in packageList) {
Debug.trace((("[ResourceManager] Load package '" + pack) + "'"));
for each (resource in _dictionary.elements()) {
if (resource._package == pack){
if (list.indexOf(resource._id) < 0){
list.push(resource._id);
};
};
};
};
for each (res in list) {
if (!internalIsResourceLoaded(res)){
internalLoadResource(res);
};
};
}
public function isLoadingFinished():Boolean{
var id:String;
var resource:Resource;
if (_loadingPendingResourceList.length > 0){
for each (id in _loadingPendingResourceList) {
resource = (_dictionary.getElement(id) as Resource);
if (!resource._isLoaded){
return (false);
};
};
while (_loadingPendingResourceList.length > 0) {
_loadedResourceList.push(_loadingPendingResourceList.pop());
};
};
return (true);
}
public function loadPackage(packId:String):void{
var resource:Resource;
Debug.trace((("[ResourceManager] Load package '" + packId) + "'"));
for each (resource in _dictionary.elements()) {
if (resource._package == packId){
internalLoadResource(resource._id);
};
};
}
private function handleMasterLoadComplete(event:Event):void{
var event = event;
compileResourceList(new XML(event.target.data));
Debug.trace("[ResourceManager] Loading of Resource Master List Completed");
//unresolved jump
var _slot1 = e;
Debug.error("[ResourceManager] ERROR: Could not parse Resource Master List", _slot1.message);
}
public function loadAllResources():void{
var res:String;
Debug.trace("[Resource Manager] Load All Resources");
for each (res in _dictionary.keys()) {
if (!internalIsResourceLoaded(res)){
internalLoadResource(res);
};
};
}
private function compileEmbeddedResource(mc:Object, resource:Object):void{
(resource as Resource)._data = mc;
compileResource((resource as Resource));
}
private function getPackageList():Array{
var resource:Resource;
var list:Array = new Array();
for each (resource in _dictionary.elements()) {
if (list.indexOf(resource._package) < 0){
list.push(resource._package);
};
};
return (list);
}
public function isMasterLoaded():Boolean{
return (_masterLoaded);
}
public function loadResource(id:String):void{
internalLoadResource(id);
}
public function unloadPackage(packId:String):void{
var resource:Resource;
var resArray:Array = _dictionary.elements();
for each (resource in resArray) {
if (resource._package == packId){
unloadResource(resource._id);
};
};
}
public function setResource(id:String, obj:Object, type:String="undefined"):void{
var resource:Resource = (_dictionary.getElement(id) as Resource);
if (!resource){
Debug.warning("\n*******************************************************");
Debug.warning((("WARNING: [ResourceManager] Resource id '" + id) + "' not found!"));
Debug.warning("*******************************************************\n");
resource = new Resource();
resource._data = obj;
resource._id = id;
resource._type = type;
resource._isLoaded = true;
_dictionary.put(resource._id, resource);
Debug.trace((("[ResourceManager] Resource added to dictionary '" + resource._id) + "'"));
return;
};
resource._data = obj;
}
private function internalIsResourceLoaded(id:String):Boolean{
var resource:Resource = (_dictionary.getElement(id) as Resource);
if (resource){
return (resource._isLoaded);
};
return (false);
}
public function getResource(id:String):Object{
var resource:Resource = (_dictionary.getElement(id) as Resource);
if (!resource){
Debug.warning("\n*******************************************************");
Debug.warning((("WARNING: [ResourceManager] Resource id '" + id) + "' not found!"));
Debug.warning("*******************************************************\n");
return (null);
};
return (resource._data);
}
private function compileResourceList(resourceListXml:XML):void{
var item:XML;
var resource:Resource;
GAMEASSET_PATH = resourceListXml.@resPath;
var resourceList:XMLList = resourceListXml.children();
var i:int;
while (i < resourceList.length()) {
item = resourceList[i];
resource = new Resource();
resource._id = item.@id;
resource._url = item.@url;
resource._package = item.@packageId;
resource._type = item.@type;
resource._size = item.@size;
if (resource._size){
resource.bytesTotal = resource._size;
};
resource._isLoaded = false;
if (((!((resource._url == ""))) && (!((resource._id == ""))))){
_dictionary.put(resource._id, resource);
};
i++;
};
_masterLoaded = true;
}
public function compileResource(resource:Resource):void{
if (resource._loader){
removeListenersFromResource((resource._loader as IEventDispatcher), resource);
};
switch (resource._type){
case Resource.RES_SWF_NORMAL:
InputManager.getInstance().registerExternalEventDispatcher((resource._data as MovieClip));
case Resource.RES_XML_DATA:
resource._isLoaded = true;
break;
case Resource.RES_PURE_SWF_NEEDCOMPILATION:
this.stage.addChild(new SwfAnimationConversionTool((resource._data as MovieClip), resource));
break;
case Resource.RES_SWF_NEEDCOMPILATION:
this.stage.addChild(new AnimationConversionTool((resource._data as MovieClip), resource));
break;
case Resource.RES_IMG_NEEDCOMPILATION:
this.stage.addChild(new ImageConversionTool((resource._data as Bitmap), resource));
break;
case Resource.RES_SOUND:
resource._isLoaded = true;
break;
case Resource.RES_UNDEFINED:
resource._isLoaded = true;
Debug.warning(((("[Resource Manager] UNDEFINED RESOURCE : " + resource._package) + "/") + resource._id));
break;
default:
Debug.error(((("[Resource Manager] UNDEFINED RESOURCE : " + resource._package) + "/") + resource._id));
break;
};
}
private function removeListenersFromResource(obj:IEventDispatcher, res:Resource):void{
obj.removeEventListener(Event.COMPLETE, res.handleLoadComplete);
obj.removeEventListener(ProgressEvent.PROGRESS, res.handleLoadProgress);
obj.removeEventListener(IOErrorEvent.IO_ERROR, res.handleLoadError);
}
public function unloadAllResources():void{
var resId:String;
var resIdArray:Array = _dictionary.keys();
for each (resId in resIdArray) {
unloadResource(resId);
};
}
private function instanceConstructor():void{
totalDownloadedBytes = 0;
_masterLoaded = false;
this.visible = false;
this.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
_dictionary = new StringHashtable();
_loadedResourceList = new Array();
_loadingPendingResourceList = new Array();
}
public function loadMaster(url:String, data:StringHashtable):void{
embeddedDataList = data;
Debug.trace("[ResourceManager] Loading Resource Master List");
_masterLoaded = false;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
xmlLoader.addEventListener(Event.COMPLETE, handleMasterLoadComplete);
xmlLoader.load(new URLRequest(url));
}
public function displaySizeOfResources():void{
var resource:Resource;
for each (resource in _dictionary.elements()) {
trace((((((((((("<resource id=\"" + resource._id) + "\" packageId=\"") + resource._package) + "\" url=\"") + resource._url) + "\" type=\"") + resource._type) + "\" size=\"") + resource.bytesTotal) + "\" />"));
};
}
public function unloadResource(id:String):void{
var resource:Resource;
var index:int = _loadedResourceList.indexOf(id);
if (index >= 0){
Debug.trace((("Unload resource '" + id) + "'"));
resource = (_dictionary.getElement(id) as Resource);
_loadedResourceList.splice(index, 1);
resource._isLoaded = false;
resource._data = null;
resource.bytesLoaded = 0;
resource.bytesTotal = 0;
resource._loader = null;
};
}
public function displaySizeOfPackages():void{
var pack:String;
var size:Number;
var resource:Resource;
for each (pack in getPackageList()) {
size = 0;
for each (resource in _dictionary.elements()) {
if (resource._package == pack){
size = (size + resource.bytesTotal);
};
};
trace((((("<package id=\"" + pack) + "\" size=\"") + size) + "\" />"));
};
}
private function internalLoadResource(id:String):void{
var id = id;
var resource:Resource = (_dictionary.getElement(id) as Resource);
if (!resource){
return;
};
if (((resource._isLoaded) || ((_loadingPendingResourceList.indexOf(id) >= 0)))){
return;
};
_loadingPendingResourceList.push(id);
if (((embeddedDataList) && (embeddedDataList.containsKey(id)))){
resource.embedded = true;
resource._data = new ((embeddedDataList.getElement(id) as Class));
if ((resource._data is MovieClip)){
this.stage.addChild(new EmbeddedMovieClipConversionTool((resource._data as MovieClip), compileEmbeddedResource, resource));
} else {
compileResource(resource);
};
} else {
resource.embedded = false;
resource._isLoaded = false;
switch (resource._type){
case Resource.RES_SOUND:
resource._loader = new Sound();
addListenersToResource((resource._loader as Sound), resource);
(resource._loader as Sound).load(new URLRequest((GAMEASSET_PATH + resource._url)), new SoundLoaderContext(0, false));
case Resource.RES_XML_DATA:
resource._loader = new URLLoader();
addListenersToResource((resource._loader as URLLoader), resource);
(resource._loader as URLLoader).load(new URLRequest((GAMEASSET_PATH + resource._url)));
break;
default:
resource._loader = new Loader();
addListenersToResource((resource._loader as Loader).contentLoaderInfo, resource);
(resource._loader as Loader).load(new URLRequest((GAMEASSET_PATH + resource._url)), new LoaderContext(false, ApplicationDomain.currentDomain));
break;
};
//unresolved jump
var _slot1 = error;
Debug.error("\n#######################################################");
Debug.error("ERROR: [ResourceManager]", _slot1.name, _slot1.errorID, _slot1.message);
Debug.error("#######################################################\n");
};
}
private function handleAddedToStage(event:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
}
public function setMaster(resourceList:XML, data:StringHashtable):void{
embeddedDataList = data;
Debug.trace("[ResourceManager] Setting Resource Master List");
compileResourceList(resourceList);
}
private function addListenersToResource(obj:IEventDispatcher, res:Resource):void{
obj.addEventListener(Event.COMPLETE, res.handleLoadComplete, false, 0, true);
obj.addEventListener(ProgressEvent.PROGRESS, res.handleLoadProgress, false, 0, true);
obj.addEventListener(IOErrorEvent.IO_ERROR, res.handleLoadError, false, 0, true);
}
public function getProgess():ProgressInfo{
var id:String;
var resource:Resource;
var progress:ProgressInfo = new ProgressInfo();
for each (id in _loadingPendingResourceList) {
resource = (_dictionary.getElement(id) as Resource);
progress.bytesLoaded = (progress.bytesLoaded + resource.bytesLoaded);
progress.bytesTotal = (progress.bytesTotal + resource.bytesTotal);
};
return (progress);
}
public function isResourceLoaded(id:String):Boolean{
var resource:Resource = (_dictionary.getElement(id) as Resource);
if (resource){
return (resource._isLoaded);
};
return (false);
}
public function setResourceURL(id:String, url:String):void{
var resource:Resource = (_dictionary.getElement(id) as Resource);
if (!resource){
Debug.warning("\n*******************************************************");
Debug.warning((("WARNING: [ResourceManager] Resource id '" + id) + "' not found!"));
Debug.warning("*******************************************************\n");
return;
};
resource._isLoaded = false;
resource._url = url;
}
public static function getInstance():ResourceManager{
return (_instance);
}
}
}//package managers.resources
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 45
//SoundManager (managers.sounds.SoundManager)
package managers.sounds {
import managers.resources.*;
import flash.media.*;
public final class SoundManager {
private var _ambianceMusic:String;// = null
private var loopSoundList:Array;
private var _currentMusic:String;// = null
private var _enableSound:Boolean;
private static var _instance:SoundManager = new SoundManager(PrivateClass);
;
public function SoundManager(c:Class){
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
public function stopAllSounds():void{
SoundMixer.stopAll();
}
private function instanceConstructor():void{
SoundMixer.stopAll();
}
public function isMusicEnabled():Boolean{
return (!((_currentMusic == null)));
}
public function stopMusic():void{
_currentMusic = null;
_ambianceMusic = null;
SoundMixer.stopAll();
}
public function enableSound(b:Boolean):void{
_enableSound = b;
if (_enableSound){
internalPlayMusic(_currentMusic, _ambianceMusic);
} else {
stopAllSounds();
};
}
public function playMusic(id:String, ambiance:String=null):void{
if (_currentMusic != id){
_currentMusic = id;
_ambianceMusic = ambiance;
if (_enableSound){
SoundMixer.stopAll();
internalPlayMusic(_currentMusic, _ambianceMusic);
};
};
}
private function internalPlayMusic(id:String, ambiance:String):void{
var _sound:Sound;
var st:SoundTransform = new SoundTransform(1);
_sound = (ResourceManager.getInstance().getResource(id) as Sound);
if (_sound){
_sound.play(0, int.MAX_VALUE, st);
};
_sound = (ResourceManager.getInstance().getResource(ambiance) as Sound);
if (_sound){
_sound.play(0, int.MAX_VALUE, st);
};
}
public function playSound(id:String, loop:Boolean=false):void{
var _sound:Sound;
if (_enableSound){
_sound = (ResourceManager.getInstance().getResource(id) as Sound);
if (_sound){
trace("sound", _enableSound);
_sound.play(0, (loop) ? 9999 : 0);
};
};
}
public function playProximitySound(id:String, pan:Number=0):void{
var _sound:Sound;
var channel:SoundChannel;
if (_enableSound){
_sound = (ResourceManager.getInstance().getResource(id) as Sound);
if (_sound){
pan = Math.max(-1, Math.min(1, pan));
channel = _sound.play(0, 0, new SoundTransform(1, pan));
};
};
}
public static function getInstance():SoundManager{
return (_instance);
}
}
}//package managers.sounds
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 46
//ButtonCallback (managers.ui.ButtonCallback)
package managers.ui {
import flash.events.*;
public class ButtonCallback {
private var _obj:EventDispatcher;// = null
private var _fct:Function;// = null
public function ButtonCallback(obj:EventDispatcher, fct:Function){
super();
_obj = obj;
if (_obj){
_obj.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_fct = fct;
};
}
private function onClick(event:MouseEvent):void{
if (_fct != null){
_fct();
};
}
}
}//package managers.ui
Section 47
//IMouseListener (managers.ui.IMouseListener)
package managers.ui {
import physic.*;
public interface IMouseListener {
function handleMouseUp(_arg1:Vec2, _arg2:Object):void;
function handleMouseLeave(_arg1:Vec2, _arg2:Object):void;
function handleMouseMove(_arg1:Vec2, _arg2:Boolean, _arg3:Object):void;
function handleMouseDown(_arg1:Vec2, _arg2:Object):void;
}
}//package managers.ui
Section 48
//InputManager (managers.ui.InputManager)
package managers.ui {
import flash.events.*;
import debug.*;
import flash.display.*;
import physic.*;
import flash.geom.*;
import global.*;
import flash.utils.*;
import flash.ui.*;
public final class InputManager extends Sprite {
private var _mouseCursor:DisplayObject;
private var _locked:Boolean;// = false
private var keyTable:Array;
private var _showMouse:Boolean;
public var previousMouseTargetObject:DisplayObject;// = null
private var _mouseListenerList:Array;
private var _mouseCursorOffset:Vec2;
private var mouseDown:Boolean;// = false
private var _lockObject:Object;// = null
public var mousePosition:Vec2;
private var keyTablePressed:Array;
public var currentMouseTargetObject:DisplayObject;// = null
public static const KEY_LEFT:uint = 0;
public static const KEY_NUMPAD_ADD:uint = 21;
public static const KEY_UP:uint = 2;
public static const KEY_NUMPAD_MULTIPLY:uint = 24;
public static const KEY_DOWN:uint = 3;
public static const KEY_F1:uint = 11;
public static const KEY_F4:uint = 12;
public static const KEY_F5:uint = 13;
public static const KEY_0:uint = 25;
public static const KEY_F7:uint = 15;
public static const KEY_F8:uint = 16;
public static const KEY_F9:uint = 17;
public static const KEY_4:uint = 7;
public static const KEY_5:uint = 10;
public static const KEY_F6:uint = 14;
public static const KEY_8:uint = 9;
public static const KEY_2:uint = 6;
public static const KEY_3:uint = 22;
private static const KEY_UNDEF:uint = 25;
public static const KEY_6:uint = 8;
public static const KEY_7:uint = 23;
public static const KEY_ENTER:uint = 4;
public static const KEY_1:uint = 21;
public static const KEY_A:uint = 65;
public static const KEY_NUMPAD_DIVIDE:uint = 23;
public static const KEY_9:uint = 24;
public static const KEY_D:uint = 68;
public static const KEY_NUMPAD_ENTER:uint = 20;
public static const KEY_S:uint = 83;
public static const KEY_NUMPAD_SUBTRACT:uint = 22;
public static const KEY_W:uint = 87;
public static const KEY_F10:uint = 18;
public static const KEY_SPACE:uint = 5;
private static const KEY_COUNT:uint = 26;
public static const KEY_DEL:uint = 19;
public static const KEY_RIGHT:uint = 1;
private static var _instance:InputManager = new InputManager(PrivateClass);
;
public function InputManager(c:Class){
mousePosition = new Vec2();
super();
if (_instance){
throw (new Error("Invalid Singleton access."));
};
instanceConstructor();
}
private function removeKeyboardListenersFromDispatcher(obj:IEventDispatcher):void{
obj.removeEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
obj.removeEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
}
private function handleExternalMouseLeave(event:Event):void{
var obj:IMouseListener;
if (_mouseCursor){
(_mouseCursor.visible = false);
};
for each (var _local5 in _mouseListenerList) {
obj = _local5;
_local5;
obj.handleMouseLeave(mousePosition, event.target);
};
stage.invalidate();
}
private function GetObjectUnderPoint(point:Point):DisplayObject{
var obj:DisplayObject;
var array:Array = stage.getObjectsUnderPoint(point);
while (array.length > 0) {
obj = array.pop();
if (obj == this){
obj = array.pop();
return (obj);
};
};
return (null);
}
private function handleKeyUp(event:KeyboardEvent):void{
var code:uint = getKeyCode(event.keyCode);
if (keyTable[code]){
keyTablePressed[code] = false;
keyTable[code] = false;
};
}
public function isKeyPressed(key:uint):Boolean{
return ((_locked) ? false : keyTable[key]);
}
public function resetMouse():void{
currentMouseTargetObject = null;
previousMouseTargetObject = null;
}
public function setMouseCursor(cursor:DisplayObject, offset:Vec2=null):void{
if (((_mouseCursor) && (this.contains(_mouseCursor)))){
this.removeChild(_mouseCursor);
};
_mouseCursorOffset = offset;
_mouseCursor = cursor;
this.addChild(_mouseCursor);
updateMouse();
}
public function getInputTable():String{
var str = (("\n\n" + keyTable.length) + "\n");
var i:uint;
while (i < keyTable.length) {
str = (str + ((("\nkey[" + i) + "] = ") + keyTable[i]));
i++;
};
return (str);
}
public function isKeyPressedOnceLockedMode(obj:Object, key:uint):Boolean{
if ((((_lockObject == obj)) && (keyTablePressed[key]))){
keyTablePressed[key] = false;
return (true);
};
return (false);
}
private function handleExternalMouseDoubleClick(event:MouseEvent):void{
}
private function handleMouseDown(event:MouseEvent):void{
var obj:IMouseListener;
for each (obj in _mouseListenerList) {
obj.handleMouseDown(new Vec2(event.stageX, event.stageY), event.target);
};
}
private function addKeyboardListenersToDispatcher(obj:IEventDispatcher):void{
obj.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
obj.addEventListener(KeyboardEvent.KEY_UP, handleKeyUp, false, 0, true);
}
private function handleMouseDoubleClick(event:MouseEvent):void{
}
private function traceObjectUnderPoint(point:Point):void{
var obj:Object;
var array:Array = stage.getObjectsUnderPoint(point);
for each (obj in array) {
};
}
private function instanceConstructor():void{
var i:uint;
this.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
keyTable = new Array();
keyTablePressed = new Array();
while (i < KEY_COUNT) {
keyTable.push(new Boolean());
keyTablePressed.push(new Boolean());
i++;
};
_mouseListenerList = new Array();
_mouseCursor = null;
showMouse(true);
this.mouseChildren = false;
this.mouseEnabled = false;
this.visible = true;
Mouse.hide();
}
public function showMouse(show:Boolean):void{
_showMouse = show;
updateMouse();
}
private function handleMouseClick(event:MouseEvent):void{
this.stage.invalidate();
}
private function handleExternalMouseDown(event:MouseEvent):void{
var obj:IMouseListener;
(mousePosition.x = event.stageX);
(mousePosition.y = event.stageY);
for each (var _local5 in _mouseListenerList) {
obj = _local5;
_local5;
obj.handleMouseDown(mousePosition, event.target);
};
}
public function isKeyPressedOnce(key:uint):Boolean{
if (((!(_locked)) && (keyTablePressed[key]))){
keyTablePressed[key] = false;
return (true);
};
return (false);
}
private function handleExternalMouseOut(event:MouseEvent):void{
}
private function getKeyCode(key:uint):uint{
switch (key){
case Keyboard.NUMPAD_5:
return (KEY_5);
case Keyboard.NUMPAD_4:
return (KEY_4);
case Keyboard.LEFT:
return (KEY_LEFT);
case Keyboard.NUMPAD_6:
return (KEY_6);
case Keyboard.RIGHT:
return (KEY_RIGHT);
case Keyboard.NUMPAD_8:
return (KEY_8);
case Keyboard.UP:
return (KEY_UP);
case Keyboard.NUMPAD_2:
return (KEY_2);
case Keyboard.DOWN:
return (KEY_DOWN);
case Keyboard.NUMPAD_0:
return (KEY_0);
case Keyboard.NUMPAD_1:
return (KEY_1);
case Keyboard.NUMPAD_3:
return (KEY_3);
case Keyboard.NUMPAD_7:
return (KEY_7);
case Keyboard.NUMPAD_9:
return (KEY_9);
case Keyboard.NUMPAD_ENTER:
return (KEY_NUMPAD_ENTER);
case Keyboard.NUMPAD_ADD:
return (KEY_NUMPAD_ADD);
case Keyboard.NUMPAD_SUBTRACT:
return (KEY_NUMPAD_SUBTRACT);
case Keyboard.NUMPAD_DIVIDE:
return (KEY_NUMPAD_DIVIDE);
case Keyboard.NUMPAD_MULTIPLY:
return (KEY_NUMPAD_MULTIPLY);
case Keyboard.ENTER:
return (KEY_ENTER);
case Keyboard.SPACE:
return (KEY_SPACE);
case Keyboard.F1:
return (KEY_F1);
case Keyboard.F4:
return (KEY_F4);
case Keyboard.F5:
return (KEY_F5);
case Keyboard.F6:
return (KEY_F6);
case Keyboard.F7:
return (KEY_F7);
case Keyboard.F8:
return (KEY_F8);
case Keyboard.F9:
return (KEY_F9);
case Keyboard.F10:
return (KEY_F10);
case Keyboard.DELETE:
return (KEY_DEL);
case 68:
return (KEY_D);
case 65:
return (KEY_A);
case 87:
return (KEY_W);
case 83:
return (KEY_S);
};
return (KEY_UNDEF);
}
public function unregisterExternalEventDispatcher(obj:IEventDispatcher):void{
Debug.trace((("[InputManager] Unregister EventDispatcher '" + getQualifiedClassName(obj)) + "' (EXTERNAL)"));
removeMouseListenersFromDispatcher(obj);
}
private function addMouseListenersToDispatcher(obj:IEventDispatcher):void{
obj.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown, false, 0, true);
obj.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove, false, 0, true);
obj.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp, false, 0, true);
obj.addEventListener(MouseEvent.CLICK, handleMouseClick, false, 0, true);
obj.addEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDoubleClick, false, 0, true);
obj.addEventListener(Event.MOUSE_LEAVE, handleMouseLeave, false, 0, true);
}
public function isKeyPressedLockedMode(obj:Object, key:uint):Boolean{
return (((_lockObject)==obj) ? keyTable[key] : false);
}
private function handleExternalMouseMove(event:MouseEvent):void{
var obj:IMouseListener;
stage.invalidate();
if (_mouseCursor){
if (!_mouseCursor.visible){
(_mouseCursor.visible = true);
};
(_mouseCursor.x = (event.stageX + (_mouseCursorOffset) ? _mouseCursorOffset.x : 0));
(_mouseCursor.y = (event.stageY + (_mouseCursorOffset) ? _mouseCursorOffset.y : 0));
event.updateAfterEvent();
};
(mousePosition.x = event.stageX);
(mousePosition.y = event.stageY);
for each (var _local5 in _mouseListenerList) {
obj = _local5;
_local5;
obj.handleMouseMove(mousePosition, event.buttonDown, event.target);
};
}
private function handleExternalMouseUp(event:MouseEvent):void{
var obj:IMouseListener;
(mousePosition.x = event.stageX);
(mousePosition.y = event.stageY);
for each (var _local5 in _mouseListenerList) {
obj = _local5;
_local5;
obj.handleMouseUp(mousePosition, event.target);
};
}
private function handleExternalMouseOver(event:MouseEvent):void{
}
private function specialDispatch(point:Point, event:MouseEvent):void{
var obj:DisplayObject;
var e:*;
var array:Array = stage.getObjectsUnderPoint(point);
do {
obj = array.pop();
} while (((obj) && (!((obj == currentMouseTargetObject)))));
if (obj){
do {
obj = array.pop();
if ((((obj is InteractiveObject)) && ((event.currentTarget == event.target)))){
e = new MouseEvent(MouseEvent.MOUSE_MOVE, true, false, point.x, point.y, (obj as InteractiveObject), event.ctrlKey, event.altKey, event.shiftKey, event.buttonDown, event.delta);
obj.dispatchEvent(e);
};
} while (obj);
};
}
public function isLocked():Boolean{
return (_locked);
}
public function removeMouseListener(obj:IMouseListener):void{
Debug.trace((("[InputManager] Remove Mouse Listener '" + getQualifiedClassName(obj)) + "'"));
if (_mouseListenerList.indexOf(obj) >= 0){
_mouseListenerList.splice(_mouseListenerList.indexOf(obj), 1);
};
}
public function reset():void{
var i:uint;
while (i < KEY_COUNT) {
keyTable[i] = false;
keyTablePressed[i] = false;
i++;
};
}
public function addMouseListener(obj:IMouseListener):void{
Debug.trace((("[InputManager] Add Mouse Listener '" + getQualifiedClassName(obj)) + "'"));
if (_mouseListenerList.indexOf(obj) < 0){
_mouseListenerList.push(obj);
};
}
private function handleKeyDown(event:KeyboardEvent):void{
var code:uint = getKeyCode(event.keyCode);
if (!keyTable[code]){
keyTablePressed[code] = true;
keyTable[code] = true;
};
}
private function handleMouseLeave(event:Event):void{
var obj:IMouseListener;
if (_mouseCursor){
_mouseCursor.visible = false;
};
for each (obj in _mouseListenerList) {
obj.handleMouseLeave(mousePosition, event.target);
};
stage.invalidate();
}
private function updateMouse():void{
if (_mouseCursor){
Mouse.hide();
if (_showMouse){
_mouseCursor.x = (mousePosition.x + (_mouseCursorOffset) ? _mouseCursorOffset.x : 0);
_mouseCursor.y = (mousePosition.y + (_mouseCursorOffset) ? _mouseCursorOffset.y : 0);
this.visible = true;
} else {
this.visible = false;
};
} else {
this.visible = false;
if (_showMouse){
Mouse.show();
} else {
Mouse.hide();
};
};
}
public function lockInputManager(obj:Object, lock:Boolean):void{
if (lock){
_lockObject = obj;
_locked = true;
} else {
if (obj == _lockObject){
_lockObject = null;
_locked = false;
};
};
}
private function handleMouseUp(event:MouseEvent):void{
var obj:IMouseListener;
for each (obj in _mouseListenerList) {
obj.handleMouseUp(new Vec2(event.stageX, event.stageY), event.target);
};
}
private function handleExternalMouseClick(event:MouseEvent):void{
stage.invalidate();
}
private function addMouseListenersToExternalDispatcher(obj:EventDispatcher):void{
obj.addEventListener(MouseEvent.MOUSE_DOWN, handleExternalMouseDown, false, 0, true);
obj.addEventListener(MouseEvent.MOUSE_MOVE, handleExternalMouseMove, false, 0, true);
obj.addEventListener(MouseEvent.MOUSE_UP, handleExternalMouseUp, false, 0, true);
obj.addEventListener(MouseEvent.MOUSE_OVER, handleExternalMouseOver, false, 0, true);
obj.addEventListener(MouseEvent.MOUSE_OUT, handleExternalMouseOut, false, 0, true);
obj.addEventListener(MouseEvent.ROLL_OVER, handleExternalMouseRollOver, false, 0, true);
obj.addEventListener(MouseEvent.ROLL_OUT, handleExternalMouseRollOut, false, 0, true);
obj.addEventListener(MouseEvent.CLICK, handleExternalMouseClick, false, 0, true);
obj.addEventListener(MouseEvent.DOUBLE_CLICK, handleExternalMouseDoubleClick, false, 0, true);
obj.addEventListener(Event.MOUSE_LEAVE, handleExternalMouseLeave, false, 0, true);
}
private function handleAddedToStage(event:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
addKeyboardListenersToDispatcher(stage);
addMouseListenersToDispatcher(stage);
stage.mouseChildren = true;
}
private function removeMouseListenersFromDispatcher(obj:IEventDispatcher):void{
if (obj.hasEventListener(MouseEvent.MOUSE_DOWN)){
obj.removeEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);
};
if (obj.hasEventListener(MouseEvent.MOUSE_MOVE)){
obj.removeEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
};
if (obj.hasEventListener(MouseEvent.MOUSE_UP)){
obj.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
};
if (obj.hasEventListener(Event.MOUSE_LEAVE)){
obj.removeEventListener(Event.MOUSE_LEAVE, handleMouseLeave);
};
}
private function handleExternalMouseRollOver(event:MouseEvent):void{
}
public function registerExternalEventDispatcher(obj:EventDispatcher):void{
Debug.trace((("[InputManager] Register EventDispatcher '" + getQualifiedClassName(obj)) + "' (EXTERNAL)"));
addMouseListenersToExternalDispatcher(obj);
}
private function handleExternalMouseRollOut(event:MouseEvent):void{
}
private function handleMouseMove(event:MouseEvent):void{
handleExternalMouseMove(event);
if (_mouseCursor){
if (!_mouseCursor.visible){
(_mouseCursor.visible = true);
};
(_mouseCursor.x = (event.stageX + (_mouseCursorOffset) ? _mouseCursorOffset.x : 0));
(_mouseCursor.y = (event.stageY + (_mouseCursorOffset) ? _mouseCursorOffset.y : 0));
event.updateAfterEvent();
};
}
public static function getInstance():InputManager{
return (_instance);
}
}
}//package managers.ui
class PrivateClass {
private function PrivateClass(){
super();
}
}
Section 49
//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);
};
var sendHostProgress:Boolean;
mc.regContLC = function (lc_name:String):void{
mc._containerLCName = lc_name;
};
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 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;
var mc:MovieClip = 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();
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);
};
mc.regContLC = function (lc_name:String):void{
mc._containerLCName = lc_name;
};
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 50
//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 51
//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 52
//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 53
//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 addEventListener(eventType:String, delegate:Function):void{
_dispatcher.addEventListener(eventType, delegate);
}
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 endGame():void{
var delta:Number = (new Date().time - gameStart);
trigger("end_game", {time:delta});
}
public static function startGame():void{
gameStart = new Date().time;
trigger("start_game");
}
public static function trigger(kind:String, obj:Object=null):void{
if (obj == null){
obj = {};
} else {
if (obj["kind"] != undefined){
trace("WARNING: optional arguments package contains key 'id', it will be overwritten");
obj["kind"] = kind;
};
};
MochiServices.send("events_triggerEvent", {eventObject:obj}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startLevel():void{
levelStart = new Date().time;
trigger("start_level");
}
public static function endLevel():void{
var delta:Number = (new Date().time - levelStart);
trigger("end_level", {time:delta});
}
}
}//package mochi.as3
Section 54
//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 55
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
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 _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 _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 = _clip._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 _clip._callbacks[cb];
}
public static function get childClip():Object{
return (_clip);
}
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:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + methodName));
handleError(args, callbackObject, callbackMethod);
flush(true);
return;
};
_clip._queue.push({methodName:methodName, args:args, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:callbackObject, callbackMethod:callbackMethod};
_clip._nextcallbackID++;
};
};
}
private static function init(id:String, clip:Object):void{
_id = id;
if (clip != null){
_container = clip;
loadCommunicator(id, _container);
};
}
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 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++;
};
}
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.7 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
private static function flush(error:Boolean):void{
var request:Object;
var callback:Object;
if (((_clip) && (_clip._queue))){
while (_clip._queue.length > 0) {
request = _clip._queue.shift();
callback = null;
if (request != null){
if (request.callbackID != null){
callback = _clip._callbacks[request.callbackID];
};
delete _clip._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 (container != null){
if ((container is Sprite)){
_container = container;
};
};
if (doAdd){
if ((_container is Sprite)){
Sprite(_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 (_clip._queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _clip._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{
var clipname:String = ("_mochiservices_com_" + id);
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 = createEmptyMovieClip(clip, clipname, 10336, false);
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);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._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 createEmptyMovieClip(parent:Object, name:String, depth:Number, doAdd:Boolean=true):MovieClip{
var parent = parent;
var name = name;
var depth = depth;
var doAdd = doAdd;
var mc:MovieClip = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
parent[name] = mc;
//unresolved jump
var _slot1 = e;
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
mc["_name"] = name;
return (mc);
}
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 56
//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 57
//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 58
//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 59
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
public function ByteArrayAsset(){
super();
}
}
}//package mx.core
Section 60
//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.2.0.3958";
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 61
//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.2.0.3958";
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 62
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 63
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 64
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
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 65
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(C:\autobuild\3.2.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get isDocument():Boolean;
function set repeaters(C:\autobuild\3.2.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function initializeRepeaterArrays(C:\autobuild\3.2.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(C:\autobuild\3.2.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 66
//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.2.0.3958";
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 67
//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.2.0.3958";
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 68
//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 69
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
public function SoundAsset(){
super();
}
}
}//package mx.core
Section 70
//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.2.0.3958";
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 71
//Circle (physic.Circle)
package physic {
public final class Circle {
public var radius:Number;
public var x:Number;
public var y:Number;
public function Circle(x:Number=0, y:Number=0, r:Number=1){
super();
this.x = x;
this.y = y;
this.radius = r;
}
public function clone(v:Circle):Circle{
return (new Circle(x, y, radius));
}
}
}//package physic
Section 72
//Line (physic.Line)
package physic {
public final class Line {
public var pt1:Vec2;
public var pt2:Vec2;
public function Line(u:Vec2=null, v:Vec2=null){
pt1 = new Vec2();
pt2 = new Vec2();
super();
if (((u) && (v))){
pt1.x = u.x;
pt1.y = u.y;
pt2.x = v.x;
pt2.y = v.y;
};
}
public function clone(v:Line):Line{
return (new Line(pt1, pt2));
}
}
}//package physic
Section 73
//NavMesh (physic.NavMesh)
package physic {
public final class NavMesh {
public static const tileSize:Number = 32;
private static var intersection:Vec2 = new Vec2();
public static var segmentList:Array = new Array();
public function NavMesh(){
super();
}
private static function MergeNavSegments(lineA:NavSegment, lineB:NavSegment):void{
var denom:Number = (((lineB.ptB.y - lineB.ptA.y) * (lineA.ptB.x - lineA.ptA.x)) - ((lineB.ptB.x - lineB.ptA.x) * (lineA.ptB.y - lineA.ptA.y)));
var nume_a:Number = (((lineB.ptB.x - lineB.ptA.x) * (lineA.ptA.y - lineB.ptA.y)) - ((lineB.ptB.y - lineB.ptA.y) * (lineA.ptA.x - lineB.ptA.x)));
var nume_b:Number = (((lineA.ptB.x - lineA.ptA.x) * (lineA.ptA.y - lineB.ptA.y)) - ((lineA.ptB.y - lineA.ptA.y) * (lineA.ptA.x - lineB.ptA.x)));
if (denom == 0){
return;
};
var ua:Number = (nume_a / denom);
var ub:Number = (nume_b / denom);
if ((((((((ua >= 0)) && ((ua <= 1)))) && ((ub >= 0)))) && ((ub <= 1)))){
intersection.x = (lineA.ptA.x + (ua * (lineA.ptB.x - lineA.ptA.x)));
intersection.y = (lineA.ptA.y + (ua * (lineA.ptB.y - lineA.ptA.y)));
if (ua < 0.5){
lineA.ptA.x = (lineB.ptB.x = intersection.x);
lineA.ptA.y = (lineB.ptB.y = intersection.y);
} else {
lineA.ptB.x = (lineB.ptA.x = intersection.x);
lineA.ptB.y = (lineB.ptA.y = intersection.y);
};
};
}
public static function optimize():void{
var j:int;
var len:int = segmentList.length;
var i:int;
while (i < len) {
j = (i + 1);
while (j < len) {
MergeNavSegments((segmentList[i] as NavSegment), (segmentList[j] as NavSegment));
j++;
};
i++;
};
}
}
}//package physic
Section 74
//NavSegment (physic.NavSegment)
package physic {
import global.*;
public final class NavSegment {
public var _ptA:Vec2;
public var floorCollision:Boolean;// = false
public var boundingBox:Rect;
public var offset:Vec2;
public var stopped:Boolean;
public var skip:Boolean;
public var _visualPtA:Vec2;
public var _visualPtB:Vec2;
public var normal:Vec2;
public var visualBoundingBox:Rect;
public var isDynamic:Boolean;// = false
public var currentVelocity:Vec2;
public var debugCollision:int;// = 0
public var _ptB:Vec2;
public function NavSegment(){
_ptA = new Vec2(0, 0);
_ptB = new Vec2(0, 0);
_visualPtA = new Vec2(0, 0);
_visualPtB = new Vec2(0, 0);
normal = new Vec2(0, 1);
offset = new Vec2(0, 0);
currentVelocity = new Vec2();
boundingBox = new Rect();
visualBoundingBox = new Rect();
super();
}
public function get visualPtA():Vec2{
if (isDynamic){
return (new Vec2((_visualPtA.x + offset.x), (_visualPtA.y + offset.y)));
};
return (_visualPtA);
}
public function get visualPtB():Vec2{
if (isDynamic){
return (new Vec2((_visualPtB.x + offset.x), (_visualPtB.y + offset.y)));
};
return (_visualPtB);
}
public function get ptB():Vec2{
if (isDynamic){
return (new Vec2((_ptB.x + offset.x), (_ptB.y + offset.y)));
};
return (_ptB);
}
public function NavSegmentCtor(x1:Number, y1:Number, x2:Number, y2:Number):void{
var distX:Number;
var distY:Number;
stopped = false;
_visualPtA.x = (x1 * NavMesh.tileSize);
_visualPtA.y = (y1 * NavMesh.tileSize);
_visualPtB.x = (x2 * NavMesh.tileSize);
_visualPtB.y = (y2 * NavMesh.tileSize);
normal.x = (_visualPtB.y - _visualPtA.y);
normal.y = (_visualPtA.x - _visualPtB.x);
normal.normalize();
_ptA.x = _visualPtA.x;
_ptA.y = _visualPtA.y;
_ptB.x = _visualPtB.x;
_ptB.y = _visualPtB.y;
var vecAB:Vec2 = new Vec2((_ptB.x - _ptA.x), (_ptB.y - _ptA.y));
vecAB.normalize();
distX = GlobalData.navMeshThresholdX;
distY = GlobalData.navMeshThresholdY;
_ptA.x = (_ptA.x + ((normal.x * distX) - (vecAB.x * distX)));
_ptA.y = (_ptA.y + ((normal.y * distY) - (vecAB.y * distY)));
_ptB.x = (_ptB.x + ((normal.x * distX) + (vecAB.x * distX)));
_ptB.y = (_ptB.y + ((normal.y * distY) + (vecAB.y * distY)));
boundingBox.x = Math.min(_ptA.x, _ptB.x);
boundingBox.y = Math.min(_ptA.y, _ptB.y);
boundingBox.width = Math.abs((_ptA.x - _ptB.x));
boundingBox.height = Math.abs((_ptA.y - _ptB.y));
visualBoundingBox.x = Math.min(_visualPtA.x, _visualPtB.x);
visualBoundingBox.y = Math.min(_visualPtA.y, _visualPtB.y);
visualBoundingBox.width = Math.abs((_visualPtA.x - _visualPtB.x));
visualBoundingBox.height = Math.abs((_visualPtA.y - _visualPtB.y));
}
public function get ptA():Vec2{
if (isDynamic){
return (new Vec2((_ptA.x + offset.x), (_ptA.y + offset.y)));
};
return (_ptA);
}
}
}//package physic
Section 75
//Physic (physic.Physic)
package physic {
import debug.*;
import flash.display.*;
import managers.objects.*;
public final class Physic {
public static const SHOW_DEBUG_STUFF:Boolean = true;
private static const movingBox:Rect = new Rect();
public static const Epsilon5:Number = 1E-5;
private static const modeTest:Boolean = true;
private static const VEC_UNIT_Y_NEG:Vec2 = new Vec2(0, -1);
public static const Epsilon10:Number = 1E-10;
public static var bFloorCollision:Boolean = false;
private static var intersection:Vec2 = new Vec2();
public static var currentFloor:NavSegment = null;
private static var len:Number;
private static var displacement:Line = new Line();
private static var currentDynFloor:NavSegment = null;
public static var lineList:Array = new Array();
private static var relativeVelocity:Vec2 = new Vec2();
private static var penetration:Vec2 = new Vec2();
public static var vec2List:Array = new Array();
private static var navMeshSegment:Line = new Line();
public static var prevDynFloor:NavSegment = null;
private static var newPosition:Vec2 = new Vec2();
public static var debugSprite:Sprite = new Sprite();
private static var previousVelocity:Vec2 = new Vec2();
public static var bRoofCollision:Boolean = false;
public function Physic(){
super();
}
public static function updateAvatar(obj:GameObject, deltaTime:Number):Boolean{
var it:NavSegment;
var lastCollision:NavSegment;
var preventInfiniteLoop:int;
var epsVel:Vec2;
var iterator:NavSegment;
var pt:Vec2;
var lineIterator:Line;
var vec2Iterator:Vec2;
if (deltaTime == 0){
return (false);
};
if (SHOW_DEBUG_STUFF){
while (vec2List.length > 0) {
vec2List.pop();
};
while (lineList.length > 0) {
lineList.pop();
};
};
bFloorCollision = false;
bRoofCollision = false;
currentFloor = null;
if (obj.velocity.lengthSquared() >= Epsilon5){
epsVel = obj.velocity.clone();
epsVel.normalize(-(Epsilon10));
obj.position.x = (obj.position.x + epsVel.x);
obj.position.y = (obj.position.y + epsVel.y);
};
prevDynFloor = currentDynFloor;
if (currentDynFloor){
obj.velocity.x = (obj.velocity.x + currentDynFloor.currentVelocity.x);
obj.velocity.y = (obj.velocity.y + currentDynFloor.currentVelocity.y);
currentDynFloor = null;
};
newPosition.x = (obj.position.x + obj.velocity.x);
newPosition.y = (obj.position.y + obj.velocity.y);
len = obj.velocity.length();
movingBox.x = (obj.position.x - len);
movingBox.y = (obj.position.y - len);
movingBox.width = (len * 2);
movingBox.height = (len * 2);
for each (it in NavMesh.segmentList) {
it.floorCollision = false;
it.skip = !(Physic.isRectIntersectRect(movingBox, it.boundingBox));
};
lastCollision = null;
preventInfiniteLoop = 3;
while (true) {
--preventInfiniteLoop;
if (preventInfiniteLoop < 0){
Debug.warning("[Physic] Something went wrong!!!");
if (prevDynFloor){
prevDynFloor.currentVelocity.x = 0;
prevDynFloor.currentVelocity.y = 0;
prevDynFloor.stopped = true;
};
iterator.currentVelocity.x = 0;
iterator.currentVelocity.y = 0;
iterator.stopped = true;
return (true);
};
for each (iterator in NavMesh.segmentList) {
if (iterator.skip){
} else {
if (lastCollision == iterator){
//unresolved jump
};
relativeVelocity.x = (obj.velocity.x - iterator.currentVelocity.x);
relativeVelocity.y = (obj.velocity.y - iterator.currentVelocity.y);
if (Vec2.dotProduct(relativeVelocity, iterator.normal) >= 0){
} else {
displacement.pt1 = obj.position;
displacement.pt2.x = (obj.position.x + relativeVelocity.x);
displacement.pt2.y = (obj.position.y + relativeVelocity.y);
navMeshSegment.pt1 = iterator.ptA;
navMeshSegment.pt2 = iterator.ptB;
if (Physic.LineLineIntersection(displacement, navMeshSegment, intersection)){
iterator.floorCollision = true;
if (Vec2.dotProduct(VEC_UNIT_Y_NEG, iterator.normal) > 0){
if (iterator.isDynamic){
currentDynFloor = iterator;
};
currentFloor = iterator;
bFloorCollision = true;
} else {
if (iterator.normal.y == 1){
bRoofCollision = true;
};
};
intersection.x = (intersection.x + iterator.currentVelocity.x);
intersection.y = (intersection.y + iterator.currentVelocity.y);
penetration.x = (obj.velocity.x - (intersection.x - obj.position.x));
penetration.y = (obj.velocity.y - (intersection.y - obj.position.y));
if (penetration.lengthSquared() < Epsilon5){
obj.velocity.x = (intersection.x - obj.position.x);
obj.velocity.y = (intersection.y - obj.position.y);
} else {
lastCollision = iterator;
pt = projectionVecSurVec2(penetration, new Vec2((iterator.ptB.x - iterator.ptA.x), (iterator.ptB.y - iterator.ptA.y)));
newPosition.x = (pt.x + intersection.x);
newPosition.y = (pt.y + intersection.y);
obj.velocity.x = (newPosition.x - obj.position.x);
obj.velocity.y = (newPosition.y - obj.position.y);
};
if (Math.abs(obj.velocity.x) < Epsilon5){
obj.velocity.x = 0;
};
if (Math.abs(obj.velocity.y) < Epsilon5){
obj.velocity.y = 0;
};
if (SHOW_DEBUG_STUFF){
lineList.push(new Line(new Vec2((intersection.x + penetration.x), (intersection.y + penetration.y)), intersection));
vec2List.push(new Vec2(intersection.x, intersection.y));
vec2List.push(new Vec2(newPosition.x, newPosition.y));
};
};
};
};
};
if (lastCollision == null){
break;
};
};
obj.position.x = (obj.position.x + obj.velocity.x);
obj.position.y = (obj.position.y + obj.velocity.y);
if (currentDynFloor){
obj.position.x = (obj.position.x + (currentDynFloor.normal.x * Epsilon5));
obj.position.y = (obj.position.y + (currentDynFloor.normal.y * Epsilon5));
};
if (SHOW_DEBUG_STUFF){
debugDisplayNavMesh();
for each (lineIterator in lineList) {
debugDrawLine(lineIterator.pt1, lineIterator.pt2, 0x999999);
};
for each (vec2Iterator in vec2List) {
debugDrawSphere(vec2Iterator, 5, 0x9999);
};
};
return (false);
}
public static function checkRectCollision(pt:Vec2, rectX:int, rectY:int, rectW:int, rectH:int):Boolean{
pt.y = (pt.y - rectY);
if ((((pt.y < 0)) || ((pt.y > rectH)))){
return (false);
};
pt.x = (pt.x - rectX);
if ((((pt.x < 0)) || ((pt.x > rectW)))){
return (false);
};
return (true);
}
public static function projectionVecSurVec2(u:Vec2, v:Vec2):Vec2{
var u_v:Vec2 = new Vec2();
var dot:Number = Vec2.dotProduct(u, v);
var norm:Number = Math.sqrt(((v.x * v.x) + (v.y * v.y)));
var vNormalized:Vec2 = new Vec2(v.x, v.y);
vNormalized.normalize();
u_v.x = ((dot / norm) * vNormalized.x);
u_v.y = ((dot / norm) * vNormalized.y);
return (u_v);
}
public static function is2SegmentIntersect(a1:Number, b1:Number, a2:Number, b2:Number):Boolean{
var min1:Number = Math.min(a1, b1);
var max1:Number = Math.max(a1, b1);
var min2:Number = Math.min(a2, b2);
var max2:Number = Math.max(a2, b2);
return ((((min1 < max2)) && ((min2 < max1))));
}
public static function isRectIntersectRect(rect1:Rect, rect2:Rect):Boolean{
return ((((((((rect1.x < (rect2.x + rect2.width))) && ((rect2.x < (rect1.x + rect1.width))))) && ((rect1.y < (rect2.y + rect2.height))))) && ((rect2.y < (rect1.y + rect1.height)))));
}
public static function LineCircleIntersection(line:Line, circle:Circle, mu:Vec2):Boolean{
var a:Number;
var b:Number;
var c:Number;
var bb4ac:Number;
var dp:Vec2 = new Vec2();
dp.x = (line.pt2.x - line.pt1.x);
dp.y = (line.pt2.y - line.pt1.y);
a = ((dp.x * dp.x) + (dp.y * dp.y));
b = (2 * ((dp.x * (line.pt1.x - circle.x)) + (dp.y * (line.pt1.y - circle.y))));
c = ((circle.x * circle.x) + (circle.y * circle.y));
c = (c + ((line.pt1.x * line.pt1.x) + (line.pt1.y * line.pt1.y)));
c = (c - (2 * ((circle.x * line.pt1.x) + (circle.y * line.pt1.y))));
c = (c - (circle.radius * circle.radius));
bb4ac = ((b * b) - ((4 * a) * c));
if (bb4ac < 0){
mu.x = 0;
mu.y = 0;
return (false);
};
var sqrt:Number = Math.sqrt(bb4ac);
var mult:Number = (-1 / (2 * a));
mu.x = ((b - sqrt) * mult);
mu.y = ((b + sqrt) * mult);
if ((((((mu.x < 0)) && ((mu.y < 0)))) || ((((mu.x > 1)) && ((mu.y > 1)))))){
return (false);
};
return (true);
}
public static function projectionVecSurVecSpecial(a:Vec2, b:Vec2):Vec2{
var cosTheta:Number;
var lenA:Number = Math.sqrt(Vec2.dotProduct(a, a));
if ((((lenA == 0)) || ((Vec2.dotProduct(a, b) == 0)))){
return (Vec2.ZERO);
};
cosTheta = (Vec2.dotProduct(a, b) / (lenA * Math.sqrt(Vec2.dotProduct(b, b))));
var hyp:Number = (a.length() / cosTheta);
var u_v:Vec2 = b.clone();
u_v.normalize();
u_v.x = (u_v.x * hyp);
u_v.y = (u_v.y * hyp);
return (u_v);
}
public static function SuperLineLineIntersection(lineA:Line, lineB:Line, intersection:Vec2):Boolean{
var denom:Number = (((lineB.pt2.y - lineB.pt1.y) * (lineA.pt2.x - lineA.pt1.x)) - ((lineB.pt2.x - lineB.pt1.x) * (lineA.pt2.y - lineA.pt1.y)));
var nume_a:Number = (((lineB.pt2.x - lineB.pt1.x) * (lineA.pt1.y - lineB.pt1.y)) - ((lineB.pt2.y - lineB.pt1.y) * (lineA.pt1.x - lineB.pt1.x)));
var nume_b:Number = (((lineA.pt2.x - lineA.pt1.x) * (lineA.pt1.y - lineB.pt1.y)) - ((lineA.pt2.y - lineA.pt1.y) * (lineA.pt1.x - lineB.pt1.x)));
if (denom == 0){
return (false);
};
var ua:Number = (nume_a / denom);
var ub:Number = (nume_b / denom);
intersection.x = (lineA.pt1.x + (ua * (lineA.pt2.x - lineA.pt1.x)));
intersection.y = (lineA.pt1.y + (ua * (lineA.pt2.y - lineA.pt1.y)));
return (true);
}
public static function isVecIntersectRect(vec:Vec2, rect:Rect):Boolean{
return ((((((((vec.x < (rect.x + rect.width))) && ((rect.x < vec.x)))) && ((vec.y < (rect.y + rect.height))))) && ((rect.y < vec.y))));
}
public static function debugDrawRect(rect:Rect, color:uint):void{
if (SHOW_DEBUG_STUFF){
debugDrawLine(new Vec2(rect.x, rect.y), new Vec2(rect.x, (rect.y + rect.height)), color);
debugDrawLine(new Vec2(rect.x, rect.y), new Vec2((rect.x + rect.width), rect.y), color);
debugDrawLine(new Vec2(rect.x, (rect.y + rect.height)), new Vec2((rect.x + rect.width), (rect.y + rect.height)), color);
debugDrawLine(new Vec2((rect.x + rect.width), rect.y), new Vec2((rect.x + rect.width), (rect.y + rect.height)), color);
};
}
private static function debugDisplayNavMesh():void{
var iterator:NavSegment;
var color:uint;
var ptA:Vec2;
var ptB:Vec2;
var na:Vec2;
var nb:Vec2;
for each (iterator in NavMesh.segmentList) {
color = ((iterator.isDynamic) ? 0xFF : 170 << 16);
ptA = iterator.ptA.clone();
ptB = iterator.ptB.clone();
if (iterator.floorCollision){
debugDrawLine(ptA, ptB, 0xFFFF00);
} else {
debugDrawLine(ptA, ptB, (((iterator.debugCollision)>0) ? 0x7777 : 0 + color));
};
na = Vec2.interpolate(ptA, ptB, 0.5);
nb = new Vec2((na.x + (iterator.normal.x * 10)), (na.y + (iterator.normal.y * 10)));
debugDrawLine(na, nb, (((iterator.debugCollision)>0) ? 43639 : 0xFF00 + color));
};
}
public static function castRayNavMesh(position:Vec2, maxDistance:Number=0):Boolean{
var tmpDist:Number;
var lineA1x:Number;
var lineA1y:Number;
var lineA2x:Number;
var lineA2y:Number;
var lineB1x:Number;
var lineB1y:Number;
var lineB2x:Number;
var lineB2y:Number;
var iterator:NavSegment;
var denom:Number;
var nume_a:Number;
var nume_b:Number;
var ub:Number;
var ua:Number;
var dist:Number = (maxDistance * maxDistance);
var tmpResult:Vec2 = new Vec2();
var resultSegment:Boolean;
movingBox.x = position.x;
movingBox.width = 0;
movingBox.y = position.y;
movingBox.height = maxDistance;
Physic.debugDrawLine(position, new Vec2(position.x, (position.y + maxDistance)), 0xFFFFFF);
for each (iterator in NavMesh.segmentList) {
if ((((((Vec2.dotProduct(Vec2.DOWN, iterator.normal) < 0)) || (iterator.isDynamic))) || (!(Physic.isRectIntersectRect(movingBox, iterator.boundingBox))))){
} else {
lineA1x = iterator.ptA.x;
lineA1y = iterator.ptA.y;
lineA2x = (iterator.ptB.x - lineA1x);
lineA2y = (iterator.ptB.y - lineA1y);
lineB1x = position.x;
lineB1y = position.y;
lineB2x = (position.x - lineB1x);
lineB2y = ((position.y + 1) - lineB1y);
denom = ((lineB2y * lineA2x) - (lineB2x * lineA2y));
nume_a = ((lineB2x * (lineA1y - lineB1y)) - (lineB2y * (lineA1x - lineB1x)));
nume_b = ((lineA2x * (lineA1y - lineB1y)) - (lineA2y * (lineA1x - lineB1x)));
if (denom == 0){
} else {
ub = (nume_b / denom);
if (ub >= 0){
ua = (nume_a / denom);
if ((((ua >= 0)) && ((ua <= 1)))){
tmpResult.x = (lineA1x + (ua * lineA2x));
tmpResult.y = (lineA1y + (ua * lineA2y));
tmpDist = Vec2.distanceSquared(tmpResult, position);
if (dist > tmpDist){
dist = tmpDist;
resultSegment = true;
};
};
};
};
};
};
return (resultSegment);
}
public static function projectionVecSurVec(a:Vec2, b:Vec2):Vec2{
var u_v:Vec2 = new Vec2();
var dp:Number = ((a.x * b.x) + (a.y * b.y));
u_v.x = ((dp / ((b.x * b.x) + (b.y * b.y))) * b.x);
u_v.y = ((dp / ((b.x * b.x) + (b.y * b.y))) * b.y);
return (u_v);
}
public static function debugDrawLine(u:Vec2, v:Vec2, color:uint):void{
var u = u;
var v = v;
var color = color;
if (SHOW_DEBUG_STUFF){
var _local5 = debugSprite.graphics;
with (_local5) {
lineStyle(3, color, 1);
moveTo(u.x, u.y);
lineTo(v.x, v.y);
};
};
}
public static function BenchmarkShapeCollision():void{
var u:Vec2;
var v:Vec2;
var k:int;
while (k < 3) {
switch (k){
case 0:
u = new Vec2(3, 2);
v = new Vec2(2, 0);
break;
case 1:
u = new Vec2(-4, 8);
v = new Vec2(3, -7);
break;
case 2:
u = new Vec2(1, 0);
v = new Vec2(0, 1);
break;
};
debugTraceVec2(u, "u");
debugTraceVec2(v, "v");
debugTraceVec2(projectionVecSurVec2(u, v), "projectionVecSurVec2");
debugTraceVec2(projectionVecSurVecSpecial(u, v), "projectionVecSurVecSpecial");
k++;
};
}
public static function LineLineIntersection(lineA:Line, lineB:Line, intersection:Vec2, forceIntersection:Boolean=false):Boolean{
var denom:Number = (((lineB.pt2.y - lineB.pt1.y) * (lineA.pt2.x - lineA.pt1.x)) - ((lineB.pt2.x - lineB.pt1.x) * (lineA.pt2.y - lineA.pt1.y)));
var nume_a:Number = (((lineB.pt2.x - lineB.pt1.x) * (lineA.pt1.y - lineB.pt1.y)) - ((lineB.pt2.y - lineB.pt1.y) * (lineA.pt1.x - lineB.pt1.x)));
var nume_b:Number = (((lineA.pt2.x - lineA.pt1.x) * (lineA.pt1.y - lineB.pt1.y)) - ((lineA.pt2.y - lineA.pt1.y) * (lineA.pt1.x - lineB.pt1.x)));
if (denom == 0){
return (false);
};
var ua:Number = (nume_a / denom);
var ub:Number = (nume_b / denom);
if ((((((((ua >= 0)) && ((ua <= 1)))) && ((ub >= 0)))) && ((ub <= 1)))){
intersection.x = (lineA.pt1.x + (ua * (lineA.pt2.x - lineA.pt1.x)));
intersection.y = (lineA.pt1.y + (ua * (lineA.pt2.y - lineA.pt1.y)));
return (true);
};
if (forceIntersection){
if ((((ua >= 0)) && ((ua <= 1)))){
intersection.x = (lineA.pt1.x + (ua * (lineA.pt2.x - lineA.pt1.x)));
intersection.y = (lineA.pt1.y + (ua * (lineA.pt2.y - lineA.pt1.y)));
return (true);
};
};
return (false);
}
private static function validateVec2(v:Vec2):void{
if (((isNaN(v.x)) || (isNaN(v.y)))){
trace("shit!");
};
}
public static function updateProjectilePosition(oldPos:Vec2, pos:Vec2, vel:Vec2):Boolean{
var iterator:NavSegment;
var dist:Number;
var intersection:Vec2 = new Vec2();
var currentDistanceSquared:Number = Number.POSITIVE_INFINITY;
var displacement:Line = new Line(oldPos, new Vec2((oldPos.x + vel.x), (oldPos.y + vel.y)));
for each (iterator in NavMesh.segmentList) {
if (Vec2.dotProduct(vel, iterator.normal) >= 0){
} else {
if (LineLineIntersection(new Line(iterator.visualPtA, iterator.visualPtB), displacement, intersection, false)){
dist = Vec2.distanceSquared(intersection, oldPos);
if (dist < currentDistanceSquared){
currentDistanceSquared = dist;
pos.x = intersection.x;
pos.y = intersection.y;
};
};
};
};
if (currentDistanceSquared != Number.POSITIVE_INFINITY){
return (true);
};
pos.x = (oldPos.x + vel.x);
pos.y = (oldPos.y + vel.y);
return (false);
}
public static function isValBetweenInterval(v:Number, a:Number, b:Number):Boolean{
var min:Number = Math.min(a, b);
var max:Number = Math.max(a, b);
return ((((v > a)) && ((v < b))));
}
public static function debugDrawSphere(pt:Vec2, r:Number, color:uint):void{
var pt = pt;
var r = r;
var color = color;
if (SHOW_DEBUG_STUFF){
var _local5 = debugSprite.graphics;
with (_local5) {
lineStyle(3, color, 1);
drawCircle(pt.x, pt.y, r);
};
};
}
public static function isCircleIntersectCircle(circle1:Circle, circle2:Circle):Boolean{
var rad:Number = (circle1.radius + circle2.radius);
var dx:Number = (circle1.x - circle2.y);
var dy:Number = (circle1.x - circle2.y);
return (((rad * rad) >= ((dx * dx) + (dy * dy))));
}
public static function castRay(position:Vec2, direction:Vec2, result:Vec2, staticOnly:Boolean=false, maxDistance:Number=-1):NavSegment{
var tmpDist:Number;
var lineA1x:Number;
var lineA1y:Number;
var lineA2x:Number;
var lineA2y:Number;
var lineB1x:Number;
var lineB1y:Number;
var lineB2x:Number;
var lineB2y:Number;
var iterator:NavSegment;
var denom:Number;
var nume_a:Number;
var nume_b:Number;
var ub:Number;
var ua:Number;
var dist:Number = Number.POSITIVE_INFINITY;
var tmpResult:Vec2 = new Vec2();
var resultSegment:NavSegment;
if (maxDistance < 0){
maxDistance = 1000;
} else {
dist = (maxDistance * maxDistance);
};
if (direction.x != 0){
movingBox.x = (position.x + ((direction.x)<0) ? (maxDistance * direction.x) : 0);
movingBox.width = (maxDistance * Math.abs(direction.x));
} else {
movingBox.x = position.x;
movingBox.width = 0;
};
if (direction.y != 0){
movingBox.y = (position.y + ((direction.y)<0) ? (maxDistance * direction.y) : 0);
movingBox.height = (maxDistance * Math.abs(direction.y));
} else {
movingBox.y = position.y;
movingBox.height = 0;
};
for each (iterator in NavMesh.segmentList) {
if ((((((Vec2.dotProduct(direction, iterator.normal) >= 0)) || (((staticOnly) && (iterator.isDynamic))))) || (!(Physic.isRectIntersectRect(movingBox, iterator.visualBoundingBox))))){
} else {
lineA1x = iterator.visualPtA.x;
lineA1y = iterator.visualPtA.y;
lineA2x = (iterator.visualPtB.x - lineA1x);
lineA2y = (iterator.visualPtB.y - lineA1y);
lineB1x = position.x;
lineB1y = position.y;
lineB2x = ((position.x + direction.x) - lineB1x);
lineB2y = ((position.y + direction.y) - lineB1y);
denom = ((lineB2y * lineA2x) - (lineB2x * lineA2y));
nume_a = ((lineB2x * (lineA1y - lineB1y)) - (lineB2y * (lineA1x - lineB1x)));
nume_b = ((lineA2x * (lineA1y - lineB1y)) - (lineA2y * (lineA1x - lineB1x)));
if (denom == 0){
} else {
ub = (nume_b / denom);
if (ub >= 0){
ua = (nume_a / denom);
if ((((ua >= 0)) && ((ua <= 1)))){
tmpResult.x = (lineA1x + (ua * lineA2x));
tmpResult.y = (lineA1y + (ua * lineA2y));
tmpDist = Vec2.distanceSquared(tmpResult, position);
if (dist > tmpDist){
dist = tmpDist;
result.x = tmpResult.x;
result.y = tmpResult.y;
resultSegment = iterator;
};
};
};
};
};
};
return (resultSegment);
}
public static function isVecIntersectMovieClip(vec:Vec2, rect:MovieClip):Boolean{
return ((((((((vec.x < (rect.x + rect.width))) && ((rect.x < vec.x)))) && ((vec.y < (rect.y + rect.height))))) && ((rect.y < vec.y))));
}
private static function debugTraceVec2(v:Vec2, name:String=""):void{
trace(((((((" Vec2 '" + name) + "' = [") + v.x) + ", ") + v.y) + "]"));
if (((isNaN(v.x)) || (isNaN(v.y)))){
trace("shit!");
};
}
}
}//package physic
Section 76
//Rect (physic.Rect)
package physic {
public final class Rect {
public var width:Number;// = 0
public var height:Number;// = 0
public var x:Number;// = 0
public var y:Number;// = 0
public function Rect(x:Number=0, y:Number=0, width:Number=0, height:Number=0){
super();
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public function get right():Number{
return ((x + width));
}
public function get bottom():Number{
return ((y + height));
}
public function get top():Number{
return (y);
}
public function get left():Number{
return (x);
}
public function getTranslateRect(v:Vec2):Rect{
return (new Rect((x + v.x), (y + v.y), width, height));
}
public function clone():Rect{
return (new Rect(x, y, width, height));
}
}
}//package physic
Section 77
//Vec2 (physic.Vec2)
package physic {
import flash.geom.*;
public final class Vec2 {
public var x:Number;// = 0
public var y:Number;// = 0
public static const DOWN:Vec2 = new Vec2(0, 1);
;
public static const LEFT:Vec2 = new Vec2(-1, 0);
;
public static const UP:Vec2 = new Vec2(0, -1);
;
public static const RIGHT:Vec2 = new Vec2(1, 0);
;
public function Vec2(x:Number=0, y:Number=0){
super();
this.x = x;
this.y = y;
}
public function lengthSquared():Number{
return (((x * x) + (y * y)));
}
public function fromPoint(p:Point):void{
x = p.x;
y = p.y;
}
public function normalize(len:Number=1):void{
var invlen:Number = (len / Math.sqrt(((x * x) + (y * y))));
x = (x * invlen);
y = (y * invlen);
}
public function getMultiplyBy(value:Number):Vec2{
return (new Vec2((this.x * value), (this.y * value)));
}
public function toPoint():Point{
return (new Point(x, y));
}
public function multiplyBy(value:Number):void{
this.x = (this.x * value);
this.y = (this.y * value);
}
public function clone():Vec2{
return (new Vec2(x, y));
}
public function length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function copyFrom(p:Vec2):void{
x = p.x;
y = p.y;
}
public static function interpolate(pt1:Vec2, pt2:Vec2, f:Number):Vec2{
var invF:Number = (1 - f);
return (new Vec2(((invF * pt1.x) + (f * pt2.x)), ((invF * pt1.y) + (f * pt2.y))));
}
private static function Hermite01(s:Number):Number{
return (((((-2 * s) * s) * s) + ((3 * s) * s)));
}
public static function dotProduct(v1:Vec2, v2:Vec2):Number{
return (((v1.x * v2.x) + (v1.y * v2.y)));
}
public static function get ZERO():Vec2{
return (new Vec2(0, 0));
}
public static function normalVector(v:Vec2):Vec2{
return (new Vec2(v.y, -(v.x)));
}
private static function Hermite10(s:Number):Number{
return ((((((2 * s) * s) * s) - ((3 * s) * s)) + 1));
}
public static function distanceSquared(pt1:Vec2, pt2:Vec2):Number{
var deltaX:Number = (pt2.x - pt1.x);
var deltaY:Number = (pt2.y - pt1.y);
return (((deltaX * deltaX) + (deltaY * deltaY)));
}
public static function interpolateVec(out:Vec2, pt1:Vec2, pt2:Vec2, f:Number):void{
var invF:Number = (1 - f);
out.x = ((invF * pt1.x) + (f * pt2.x));
out.y = ((invF * pt1.y) + (f * pt2.y));
}
public static function distance(pt1:Vec2, pt2:Vec2):Number{
var deltaX:Number = (pt2.x - pt1.x);
var deltaY:Number = (pt2.y - pt1.y);
return (Math.sqrt(((deltaX * deltaX) + (deltaY * deltaY))));
}
public static function hermiteCubicSpline(pt1:Vec2, pt2:Vec2, s:Number):Vec2{
var vec:Vec2 = new (Vec2);
s = Hermite01(s);
vec.x = ((pt1.x * (1 - s)) + (pt2.x * s));
vec.y = ((pt1.y * (1 - s)) + (pt2.y * s));
return (vec);
}
public static function projLenAbs(v1:Vec2, v2:Vec2):Number{
var den:Number = dotProduct(v2, v2);
if (den == 0){
return (0);
};
return (Math.abs((dotProduct(v1, v2) / den)));
}
public static function proj(v1:Vec2, v2:Vec2):Vec2{
var den:Number = dotProduct(v2, v2);
if (den == 0){
return (Vec2.ZERO);
};
var v:Vec2 = v2.clone();
v.multiplyBy((dotProduct(v1, v2) / den));
return (v);
}
public static function projLen(v1:Vec2, v2:Vec2):Number{
var den:Number = dotProduct(v2, v2);
if (den == 0){
return (0);
};
return ((dotProduct(v1, v2) / den));
}
}
}//package physic
Section 78
//Hashtable (utils.Hashtable)
package utils {
public final class Hashtable {
private var table:Array;
public function Hashtable(obj:Object=null, initialCapacity:int=0){
var iterator:Element;
var x:Object;
super();
table = new Array();
if (obj){
if ((obj is StringHashtable)){
for each (iterator in (obj as Hashtable).table) {
table.push(iterator);
};
} else {
for (x in obj) {
table.push(new Element(int(x), obj[x]));
};
};
};
}
public function containsKey(key:int):Boolean{
var e:Element;
for each (e in table) {
if (e.key == key){
return (true);
};
};
return (false);
}
public function size():int{
return (table.length);
}
public function isEmpty():Boolean{
return ((table.length == 0));
}
public function remove(key:int):Object{
return ((table.splice(indexOf(key), 1)[0] as Element).element);
}
public function getElement(key:int):Object{
var e:Element;
for each (e in table) {
if (e.key == key){
return (e.element);
};
};
return (null);
}
private function indexOf(key:int):int{
var i:int;
while (i < table.length) {
if ((table[i] as Element).key == key){
return (i);
};
i++;
};
return (-1);
}
public function clear():void{
while (table.length > 0) {
table.pop();
};
}
public function put(key:int, value:Object):void{
table.push(new Element(key, value));
}
public function containsValue(value:Object):Boolean{
var e:Element;
for each (e in table) {
if (e.element == value){
return (true);
};
};
return (false);
}
public function keys():Array{
var e:Element;
var array:Array = new Array();
for each (e in table) {
array.push(e.key);
};
return (array);
}
public function elements():Array{
var e:Element;
var array:Array = new Array();
for each (e in table) {
array.push(e.element);
};
return (array);
}
public function clone():Hashtable{
var e:Element;
var cloneObj:Hashtable = new Hashtable();
for each (e in table) {
cloneObj.table.push(e);
};
return (cloneObj);
}
}
}//package utils
final class Element {
public var element:Object;
public var key:int;
private function Element(k:int, e:Object){
super();
key = k;
element = e;
}
}
Section 79
//StringHashtable (utils.StringHashtable)
package utils {
public final class StringHashtable {
private var table:Array;
public function StringHashtable(obj:Object=null){
var iterator:Element;
var x:Object;
super();
table = new Array();
if (obj){
if ((obj is StringHashtable)){
for each (iterator in (obj as StringHashtable).table) {
table.push(iterator);
};
} else {
for (x in obj) {
table.push(new Element((x as String), obj[x]));
};
};
};
}
public function containsKey(key:String):Boolean{
var e:Element;
for each (e in table) {
if (e.key == key){
return (true);
};
};
return (false);
}
public function size():int{
return (table.length);
}
public function isEmpty():Boolean{
return ((table.length == 0));
}
public function remove(key:String):Object{
return ((table.splice(indexOf(key), 1)[0] as Element).element);
}
public function getElement(key:String):Object{
var len:int = table.length;
var i:int;
while (i < len) {
if ((table[i] as Element).key == key){
return ((table[i] as Element).element);
};
i++;
};
return (null);
}
private function indexOfObject(value:Object):int{
var i:int;
while (i < table.length) {
if ((table[i] as Element).element == value){
return (i);
};
i++;
};
return (-1);
}
private function indexOf(key:String):int{
var i:int;
while (i < table.length) {
if ((table[i] as Element).key == key){
return (i);
};
i++;
};
return (-1);
}
public function removeObject(value:Object):Object{
return ((table.splice(indexOfObject(value), 1)[0] as Element).element);
}
public function toString():String{
var iterator:String;
var str:String = "";
for each (iterator in keys()) {
str = (str + (((("['" + iterator) + "', '") + getElement(iterator)) + "']\n"));
};
return (str);
}
public function clear():void{
while (table.length > 0) {
table.pop();
};
}
public function put(key:String, value:Object):void{
var index:int = indexOf(key);
if (index >= 0){
(table[index] as Element).element = value;
} else {
table.push(new Element(key, value));
};
}
public function containsValue(value:Object):Boolean{
var e:Element;
for each (e in table) {
if (e.element == value){
return (true);
};
};
return (false);
}
public function keys():Array{
var e:Element;
var array:Array = new Array();
for each (e in table) {
array.push(e.key);
};
return (array);
}
public function elements():Array{
var e:Element;
var array:Array = new Array();
for each (e in table) {
array.push(e.element);
};
return (array);
}
public function clone():StringHashtable{
var e:Element;
var cloneObj:StringHashtable = new StringHashtable();
for each (e in table) {
cloneObj.table.push(e);
};
return (cloneObj);
}
}
}//package utils
final class Element {
public var element:Object;
public var key:String;
private function Element(k:String, e:Object){
super();
key = k;
element = e;
}
}
Section 80
//EmbeddedModules (EmbeddedModules)
package {
import utils.*;
import managers.resources.*;
public class EmbeddedModules implements IEmbeddedData {
private static const ToughLoveClass:Class = EmbeddedModules_ToughLoveClass;
private static const objectDictionary:Object = {toughlove:ToughLoveClass};
public function EmbeddedModules(){
super();
}
public function getDataList():StringHashtable{
return (new StringHashtable(objectDictionary));
}
}
}//package
Section 81
//EmbeddedModules_ToughLoveClass (EmbeddedModules_ToughLoveClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedModules_ToughLoveClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedModules_ToughLoveClass(){
dataClass = EmbeddedModules_ToughLoveClass_dataClass;
super();
initialWidth = (10000 / 20);
initialHeight = (7500 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 82
//EmbeddedModules_ToughLoveClass_dataClass (EmbeddedModules_ToughLoveClass_dataClass)
package {
import mx.core.*;
public class EmbeddedModules_ToughLoveClass_dataClass extends ByteArrayAsset {
}
}//package
Section 83
//EmbeddedResources (EmbeddedResources)
package {
import utils.*;
import managers.resources.*;
public class EmbeddedResources implements IEmbeddedData {
private static const objectDictionary:Object = {herodown:herodownClass, heroup:heroupClass, herolarm:herolarmClass, herorarm:herorarmClass, wflame:wflameClass, snapout:snapoutClass, note:noteClass, tentacle:tentacleClass, cloud1:cloud1Class, cloud2:cloud2Class, cloud3:cloud3Class, cloud4:cloud4Class, cloud5:cloud5Class, sheep:sheepClass, bunny:bunnyClass, chick:chickClass, squid:squidClass, penguin:penguinClass, levelxml:levelxmlClass, monstersxml:monstersxmlClass, spawnxml:spawnxmlClass, level0:level0Class, level1:level1Class, level2:level2Class, level3:level3Class, level4:level4Class, level0_middle:level0_middleClass, level1_middle:level1_middleClass, level2_middle:level2_middleClass, level3_middle:level3_middleClass, level4_middle:level4_middleClass, level0_far:level0_farClass, level1_far:level1_farClass, level2_far:level2_farClass, level3_far:level3_farClass, level4_far:level4_farClass, level0_sky:level0_skyClass, level1_sky:level1_skyClass, level2_sky:level2_skyClass, level3_sky:level3_skyClass, level4_sky:level4_skyClass, hud:hudClass, mainmenu:mainmenuClass, gamedone:gamedoneClass, gameover:gameoverClass, transition:transitionClass, endstage:endstageClass, splashOdd1:splashOdd1Class, sun:sunClass, clouds:cloudsClass, healthpack:healthpackClass, gazpack:gazpackClass, nitropack:nitropackClass, Boutons:BoutonsClass, Torche:TorcheClass, DeathHero:DeathHeroClass, MoutonAtk:MoutonAtkClass, LapinAtk:LapinAtkClass, PoussinAtk:PoussinAtkClass, PinguinAtk:PinguinAtkClass, PieuvreAtk:PieuvreAtkClass, DeathEnn:DeathEnnClass, MainMusic:MainMusicClass, InGameMusic:InGameMusicClass, EndStage:EndStageClass, DeathMusic:DeathMusicClass};
private static var healthpackClass:Class = EmbeddedResources_healthpackClass;
private static var tentacleClass:Class = EmbeddedResources_tentacleClass;
private static var DeathEnnClass:Class = EmbeddedResources_DeathEnnClass;
private static var level4_skyClass:Class = EmbeddedResources_level4_skyClass;
private static var splashOdd1Class:Class = EmbeddedResources_splashOdd1Class;
private static var cloud4Class:Class = EmbeddedResources_cloud4Class;
private static var MainMusicClass:Class = EmbeddedResources_MainMusicClass;
private static var spawnxmlClass:Class = EmbeddedResources_spawnxmlClass;
private static var transitionClass:Class = EmbeddedResources_transitionClass;
private static var levelxmlClass:Class = EmbeddedResources_levelxmlClass;
private static var herolarmClass:Class = EmbeddedResources_herolarmClass;
private static var level4Class:Class = EmbeddedResources_level4Class;
private static var BoutonsClass:Class = EmbeddedResources_BoutonsClass;
private static var herorarmClass:Class = EmbeddedResources_herorarmClass;
private static var endstageClass:Class = EmbeddedResources_endstageClass;
private static var cloudsClass:Class = EmbeddedResources_cloudsClass;
private static var herodownClass:Class = EmbeddedResources_herodownClass;
private static var cloud1Class:Class = EmbeddedResources_cloud1Class;
private static var EndStageClass:Class = EmbeddedResources_EndStageClass;
private static var level1Class:Class = EmbeddedResources_level1Class;
private static var level2_middleClass:Class = EmbeddedResources_level2_middleClass;
private static var level4_middleClass:Class = EmbeddedResources_level4_middleClass;
private static var level0_middleClass:Class = EmbeddedResources_level0_middleClass;
private static var level0_farClass:Class = EmbeddedResources_level0_farClass;
private static var gameoverClass:Class = EmbeddedResources_gameoverClass;
private static var heroupClass:Class = EmbeddedResources_heroupClass;
private static var gamedoneClass:Class = EmbeddedResources_gamedoneClass;
private static var squidClass:Class = EmbeddedResources_squidClass;
private static var MoutonAtkClass:Class = EmbeddedResources_MoutonAtkClass;
private static var PinguinAtkClass:Class = EmbeddedResources_PinguinAtkClass;
private static var level1_farClass:Class = EmbeddedResources_level1_farClass;
private static var cloud3Class:Class = EmbeddedResources_cloud3Class;
private static var monstersxmlClass:Class = EmbeddedResources_monstersxmlClass;
private static var level3Class:Class = EmbeddedResources_level3Class;
private static var level0_skyClass:Class = EmbeddedResources_level0_skyClass;
private static var sunClass:Class = EmbeddedResources_sunClass;
private static var InGameMusicClass:Class = EmbeddedResources_InGameMusicClass;
private static var bunnyClass:Class = EmbeddedResources_bunnyClass;
private static var snapoutClass:Class = EmbeddedResources_snapoutClass;
private static var level2_farClass:Class = EmbeddedResources_level2_farClass;
private static var PoussinAtkClass:Class = EmbeddedResources_PoussinAtkClass;
private static var nitropackClass:Class = EmbeddedResources_nitropackClass;
private static var noteClass:Class = EmbeddedResources_noteClass;
private static var level1_skyClass:Class = EmbeddedResources_level1_skyClass;
private static var DeathHeroClass:Class = EmbeddedResources_DeathHeroClass;
private static var penguinClass:Class = EmbeddedResources_penguinClass;
private static var level3_farClass:Class = EmbeddedResources_level3_farClass;
private static var level0Class:Class = EmbeddedResources_level0Class;
private static var cloud5Class:Class = EmbeddedResources_cloud5Class;
private static var wflameClass:Class = EmbeddedResources_wflameClass;
private static var mainmenuClass:Class = EmbeddedResources_mainmenuClass;
private static var hudClass:Class = EmbeddedResources_hudClass;
private static var level2_skyClass:Class = EmbeddedResources_level2_skyClass;
private static var level4_farClass:Class = EmbeddedResources_level4_farClass;
private static var level1_middleClass:Class = EmbeddedResources_level1_middleClass;
private static var level3_middleClass:Class = EmbeddedResources_level3_middleClass;
private static var DeathMusicClass:Class = EmbeddedResources_DeathMusicClass;
private static var LapinAtkClass:Class = EmbeddedResources_LapinAtkClass;
private static var cloud2Class:Class = EmbeddedResources_cloud2Class;
private static var sheepClass:Class = EmbeddedResources_sheepClass;
private static var PieuvreAtkClass:Class = EmbeddedResources_PieuvreAtkClass;
private static var chickClass:Class = EmbeddedResources_chickClass;
private static var level3_skyClass:Class = EmbeddedResources_level3_skyClass;
private static var level2Class:Class = EmbeddedResources_level2Class;
private static var TorcheClass:Class = EmbeddedResources_TorcheClass;
private static var gazpackClass:Class = EmbeddedResources_gazpackClass;
public function EmbeddedResources(){
super();
}
public function getDataList():StringHashtable{
return (new StringHashtable(objectDictionary));
}
}
}//package
Section 84
//EmbeddedResources_BoutonsClass (EmbeddedResources_BoutonsClass)
package {
import mx.core.*;
public class EmbeddedResources_BoutonsClass extends SoundAsset {
}
}//package
Section 85
//EmbeddedResources_bunnyClass (EmbeddedResources_bunnyClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_bunnyClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_bunnyClass(){
dataClass = EmbeddedResources_bunnyClass_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 86
//EmbeddedResources_bunnyClass_dataClass (EmbeddedResources_bunnyClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_bunnyClass_dataClass extends ByteArrayAsset {
}
}//package
Section 87
//EmbeddedResources_chickClass (EmbeddedResources_chickClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_chickClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_chickClass(){
dataClass = EmbeddedResources_chickClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 88
//EmbeddedResources_chickClass_dataClass (EmbeddedResources_chickClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_chickClass_dataClass extends ByteArrayAsset {
}
}//package
Section 89
//EmbeddedResources_cloud1Class (EmbeddedResources_cloud1Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_cloud1Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_cloud1Class(){
dataClass = EmbeddedResources_cloud1Class_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 90
//EmbeddedResources_cloud1Class_dataClass (EmbeddedResources_cloud1Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_cloud1Class_dataClass extends ByteArrayAsset {
}
}//package
Section 91
//EmbeddedResources_cloud2Class (EmbeddedResources_cloud2Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_cloud2Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_cloud2Class(){
dataClass = EmbeddedResources_cloud2Class_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 92
//EmbeddedResources_cloud2Class_dataClass (EmbeddedResources_cloud2Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_cloud2Class_dataClass extends ByteArrayAsset {
}
}//package
Section 93
//EmbeddedResources_cloud3Class (EmbeddedResources_cloud3Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_cloud3Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_cloud3Class(){
dataClass = EmbeddedResources_cloud3Class_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 94
//EmbeddedResources_cloud3Class_dataClass (EmbeddedResources_cloud3Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_cloud3Class_dataClass extends ByteArrayAsset {
}
}//package
Section 95
//EmbeddedResources_cloud4Class (EmbeddedResources_cloud4Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_cloud4Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_cloud4Class(){
dataClass = EmbeddedResources_cloud4Class_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 96
//EmbeddedResources_cloud4Class_dataClass (EmbeddedResources_cloud4Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_cloud4Class_dataClass extends ByteArrayAsset {
}
}//package
Section 97
//EmbeddedResources_cloud5Class (EmbeddedResources_cloud5Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_cloud5Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_cloud5Class(){
dataClass = EmbeddedResources_cloud5Class_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 98
//EmbeddedResources_cloud5Class_dataClass (EmbeddedResources_cloud5Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_cloud5Class_dataClass extends ByteArrayAsset {
}
}//package
Section 99
//EmbeddedResources_cloudsClass (EmbeddedResources_cloudsClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_cloudsClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_cloudsClass(){
dataClass = EmbeddedResources_cloudsClass_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 100
//EmbeddedResources_cloudsClass_dataClass (EmbeddedResources_cloudsClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_cloudsClass_dataClass extends ByteArrayAsset {
}
}//package
Section 101
//EmbeddedResources_DeathEnnClass (EmbeddedResources_DeathEnnClass)
package {
import mx.core.*;
public class EmbeddedResources_DeathEnnClass extends SoundAsset {
}
}//package
Section 102
//EmbeddedResources_DeathHeroClass (EmbeddedResources_DeathHeroClass)
package {
import mx.core.*;
public class EmbeddedResources_DeathHeroClass extends SoundAsset {
}
}//package
Section 103
//EmbeddedResources_DeathMusicClass (EmbeddedResources_DeathMusicClass)
package {
import mx.core.*;
public class EmbeddedResources_DeathMusicClass extends SoundAsset {
}
}//package
Section 104
//EmbeddedResources_EndStageClass (EmbeddedResources_EndStageClass)
package {
import mx.core.*;
public class EmbeddedResources_EndStageClass extends SoundAsset {
}
}//package
Section 105
//EmbeddedResources_endstageClass (EmbeddedResources_endstageClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_endstageClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_endstageClass(){
dataClass = EmbeddedResources_endstageClass_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 106
//EmbeddedResources_endstageClass_dataClass (EmbeddedResources_endstageClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_endstageClass_dataClass extends ByteArrayAsset {
}
}//package
Section 107
//EmbeddedResources_gamedoneClass (EmbeddedResources_gamedoneClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_gamedoneClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_gamedoneClass(){
dataClass = EmbeddedResources_gamedoneClass_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 108
//EmbeddedResources_gamedoneClass_dataClass (EmbeddedResources_gamedoneClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_gamedoneClass_dataClass extends ByteArrayAsset {
}
}//package
Section 109
//EmbeddedResources_gameoverClass (EmbeddedResources_gameoverClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_gameoverClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_gameoverClass(){
dataClass = EmbeddedResources_gameoverClass_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 110
//EmbeddedResources_gameoverClass_dataClass (EmbeddedResources_gameoverClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_gameoverClass_dataClass extends ByteArrayAsset {
}
}//package
Section 111
//EmbeddedResources_gazpackClass (EmbeddedResources_gazpackClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_gazpackClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_gazpackClass(){
dataClass = EmbeddedResources_gazpackClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 112
//EmbeddedResources_gazpackClass_dataClass (EmbeddedResources_gazpackClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_gazpackClass_dataClass extends ByteArrayAsset {
}
}//package
Section 113
//EmbeddedResources_healthpackClass (EmbeddedResources_healthpackClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_healthpackClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_healthpackClass(){
dataClass = EmbeddedResources_healthpackClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 114
//EmbeddedResources_healthpackClass_dataClass (EmbeddedResources_healthpackClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_healthpackClass_dataClass extends ByteArrayAsset {
}
}//package
Section 115
//EmbeddedResources_herodownClass (EmbeddedResources_herodownClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_herodownClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_herodownClass(){
dataClass = EmbeddedResources_herodownClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 116
//EmbeddedResources_herodownClass_dataClass (EmbeddedResources_herodownClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_herodownClass_dataClass extends ByteArrayAsset {
}
}//package
Section 117
//EmbeddedResources_herolarmClass (EmbeddedResources_herolarmClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_herolarmClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_herolarmClass(){
dataClass = EmbeddedResources_herolarmClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 118
//EmbeddedResources_herolarmClass_dataClass (EmbeddedResources_herolarmClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_herolarmClass_dataClass extends ByteArrayAsset {
}
}//package
Section 119
//EmbeddedResources_herorarmClass (EmbeddedResources_herorarmClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_herorarmClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_herorarmClass(){
dataClass = EmbeddedResources_herorarmClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 120
//EmbeddedResources_herorarmClass_dataClass (EmbeddedResources_herorarmClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_herorarmClass_dataClass extends ByteArrayAsset {
}
}//package
Section 121
//EmbeddedResources_heroupClass (EmbeddedResources_heroupClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_heroupClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_heroupClass(){
dataClass = EmbeddedResources_heroupClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 122
//EmbeddedResources_heroupClass_dataClass (EmbeddedResources_heroupClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_heroupClass_dataClass extends ByteArrayAsset {
}
}//package
Section 123
//EmbeddedResources_hudClass (EmbeddedResources_hudClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_hudClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_hudClass(){
dataClass = EmbeddedResources_hudClass_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 124
//EmbeddedResources_hudClass_dataClass (EmbeddedResources_hudClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_hudClass_dataClass extends ByteArrayAsset {
}
}//package
Section 125
//EmbeddedResources_InGameMusicClass (EmbeddedResources_InGameMusicClass)
package {
import mx.core.*;
public class EmbeddedResources_InGameMusicClass extends SoundAsset {
}
}//package
Section 126
//EmbeddedResources_LapinAtkClass (EmbeddedResources_LapinAtkClass)
package {
import mx.core.*;
public class EmbeddedResources_LapinAtkClass extends SoundAsset {
}
}//package
Section 127
//EmbeddedResources_level0_farClass (EmbeddedResources_level0_farClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level0_farClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level0_farClass(){
dataClass = EmbeddedResources_level0_farClass_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 128
//EmbeddedResources_level0_farClass_dataClass (EmbeddedResources_level0_farClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level0_farClass_dataClass extends ByteArrayAsset {
}
}//package
Section 129
//EmbeddedResources_level0_middleClass (EmbeddedResources_level0_middleClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level0_middleClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level0_middleClass(){
dataClass = EmbeddedResources_level0_middleClass_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 130
//EmbeddedResources_level0_middleClass_dataClass (EmbeddedResources_level0_middleClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level0_middleClass_dataClass extends ByteArrayAsset {
}
}//package
Section 131
//EmbeddedResources_level0_skyClass (EmbeddedResources_level0_skyClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level0_skyClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level0_skyClass(){
dataClass = EmbeddedResources_level0_skyClass_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 132
//EmbeddedResources_level0_skyClass_dataClass (EmbeddedResources_level0_skyClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level0_skyClass_dataClass extends ByteArrayAsset {
}
}//package
Section 133
//EmbeddedResources_level0Class (EmbeddedResources_level0Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level0Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level0Class(){
dataClass = EmbeddedResources_level0Class_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 134
//EmbeddedResources_level0Class_dataClass (EmbeddedResources_level0Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level0Class_dataClass extends ByteArrayAsset {
}
}//package
Section 135
//EmbeddedResources_level1_farClass (EmbeddedResources_level1_farClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level1_farClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level1_farClass(){
dataClass = EmbeddedResources_level1_farClass_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 136
//EmbeddedResources_level1_farClass_dataClass (EmbeddedResources_level1_farClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level1_farClass_dataClass extends ByteArrayAsset {
}
}//package
Section 137
//EmbeddedResources_level1_middleClass (EmbeddedResources_level1_middleClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level1_middleClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level1_middleClass(){
dataClass = EmbeddedResources_level1_middleClass_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 138
//EmbeddedResources_level1_middleClass_dataClass (EmbeddedResources_level1_middleClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level1_middleClass_dataClass extends ByteArrayAsset {
}
}//package
Section 139
//EmbeddedResources_level1_skyClass (EmbeddedResources_level1_skyClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level1_skyClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level1_skyClass(){
dataClass = EmbeddedResources_level1_skyClass_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 140
//EmbeddedResources_level1_skyClass_dataClass (EmbeddedResources_level1_skyClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level1_skyClass_dataClass extends ByteArrayAsset {
}
}//package
Section 141
//EmbeddedResources_level1Class (EmbeddedResources_level1Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level1Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level1Class(){
dataClass = EmbeddedResources_level1Class_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 142
//EmbeddedResources_level1Class_dataClass (EmbeddedResources_level1Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level1Class_dataClass extends ByteArrayAsset {
}
}//package
Section 143
//EmbeddedResources_level2_farClass (EmbeddedResources_level2_farClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level2_farClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level2_farClass(){
dataClass = EmbeddedResources_level2_farClass_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 144
//EmbeddedResources_level2_farClass_dataClass (EmbeddedResources_level2_farClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level2_farClass_dataClass extends ByteArrayAsset {
}
}//package
Section 145
//EmbeddedResources_level2_middleClass (EmbeddedResources_level2_middleClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level2_middleClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level2_middleClass(){
dataClass = EmbeddedResources_level2_middleClass_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 146
//EmbeddedResources_level2_middleClass_dataClass (EmbeddedResources_level2_middleClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level2_middleClass_dataClass extends ByteArrayAsset {
}
}//package
Section 147
//EmbeddedResources_level2_skyClass (EmbeddedResources_level2_skyClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level2_skyClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level2_skyClass(){
dataClass = EmbeddedResources_level2_skyClass_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 148
//EmbeddedResources_level2_skyClass_dataClass (EmbeddedResources_level2_skyClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level2_skyClass_dataClass extends ByteArrayAsset {
}
}//package
Section 149
//EmbeddedResources_level2Class (EmbeddedResources_level2Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level2Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level2Class(){
dataClass = EmbeddedResources_level2Class_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 150
//EmbeddedResources_level2Class_dataClass (EmbeddedResources_level2Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level2Class_dataClass extends ByteArrayAsset {
}
}//package
Section 151
//EmbeddedResources_level3_farClass (EmbeddedResources_level3_farClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level3_farClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level3_farClass(){
dataClass = EmbeddedResources_level3_farClass_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 152
//EmbeddedResources_level3_farClass_dataClass (EmbeddedResources_level3_farClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level3_farClass_dataClass extends ByteArrayAsset {
}
}//package
Section 153
//EmbeddedResources_level3_middleClass (EmbeddedResources_level3_middleClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level3_middleClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level3_middleClass(){
dataClass = EmbeddedResources_level3_middleClass_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 154
//EmbeddedResources_level3_middleClass_dataClass (EmbeddedResources_level3_middleClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level3_middleClass_dataClass extends ByteArrayAsset {
}
}//package
Section 155
//EmbeddedResources_level3_skyClass (EmbeddedResources_level3_skyClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level3_skyClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level3_skyClass(){
dataClass = EmbeddedResources_level3_skyClass_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 156
//EmbeddedResources_level3_skyClass_dataClass (EmbeddedResources_level3_skyClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level3_skyClass_dataClass extends ByteArrayAsset {
}
}//package
Section 157
//EmbeddedResources_level3Class (EmbeddedResources_level3Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level3Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level3Class(){
dataClass = EmbeddedResources_level3Class_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 158
//EmbeddedResources_level3Class_dataClass (EmbeddedResources_level3Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level3Class_dataClass extends ByteArrayAsset {
}
}//package
Section 159
//EmbeddedResources_level4_farClass (EmbeddedResources_level4_farClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level4_farClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level4_farClass(){
dataClass = EmbeddedResources_level4_farClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 160
//EmbeddedResources_level4_farClass_dataClass (EmbeddedResources_level4_farClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level4_farClass_dataClass extends ByteArrayAsset {
}
}//package
Section 161
//EmbeddedResources_level4_middleClass (EmbeddedResources_level4_middleClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level4_middleClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level4_middleClass(){
dataClass = EmbeddedResources_level4_middleClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 162
//EmbeddedResources_level4_middleClass_dataClass (EmbeddedResources_level4_middleClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level4_middleClass_dataClass extends ByteArrayAsset {
}
}//package
Section 163
//EmbeddedResources_level4_skyClass (EmbeddedResources_level4_skyClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level4_skyClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level4_skyClass(){
dataClass = EmbeddedResources_level4_skyClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 164
//EmbeddedResources_level4_skyClass_dataClass (EmbeddedResources_level4_skyClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level4_skyClass_dataClass extends ByteArrayAsset {
}
}//package
Section 165
//EmbeddedResources_level4Class (EmbeddedResources_level4Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_level4Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_level4Class(){
dataClass = EmbeddedResources_level4Class_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 166
//EmbeddedResources_level4Class_dataClass (EmbeddedResources_level4Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_level4Class_dataClass extends ByteArrayAsset {
}
}//package
Section 167
//EmbeddedResources_levelxmlClass (EmbeddedResources_levelxmlClass)
package {
import mx.core.*;
public class EmbeddedResources_levelxmlClass extends ByteArrayAsset {
}
}//package
Section 168
//EmbeddedResources_mainmenuClass (EmbeddedResources_mainmenuClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_mainmenuClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_mainmenuClass(){
dataClass = EmbeddedResources_mainmenuClass_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 169
//EmbeddedResources_mainmenuClass_dataClass (EmbeddedResources_mainmenuClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_mainmenuClass_dataClass extends ByteArrayAsset {
}
}//package
Section 170
//EmbeddedResources_MainMusicClass (EmbeddedResources_MainMusicClass)
package {
import mx.core.*;
public class EmbeddedResources_MainMusicClass extends SoundAsset {
}
}//package
Section 171
//EmbeddedResources_monstersxmlClass (EmbeddedResources_monstersxmlClass)
package {
import mx.core.*;
public class EmbeddedResources_monstersxmlClass extends ByteArrayAsset {
}
}//package
Section 172
//EmbeddedResources_MoutonAtkClass (EmbeddedResources_MoutonAtkClass)
package {
import mx.core.*;
public class EmbeddedResources_MoutonAtkClass extends SoundAsset {
}
}//package
Section 173
//EmbeddedResources_nitropackClass (EmbeddedResources_nitropackClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_nitropackClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_nitropackClass(){
dataClass = EmbeddedResources_nitropackClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 174
//EmbeddedResources_nitropackClass_dataClass (EmbeddedResources_nitropackClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_nitropackClass_dataClass extends ByteArrayAsset {
}
}//package
Section 175
//EmbeddedResources_noteClass (EmbeddedResources_noteClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_noteClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_noteClass(){
dataClass = EmbeddedResources_noteClass_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 176
//EmbeddedResources_noteClass_dataClass (EmbeddedResources_noteClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_noteClass_dataClass extends ByteArrayAsset {
}
}//package
Section 177
//EmbeddedResources_penguinClass (EmbeddedResources_penguinClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_penguinClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_penguinClass(){
dataClass = EmbeddedResources_penguinClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 178
//EmbeddedResources_penguinClass_dataClass (EmbeddedResources_penguinClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_penguinClass_dataClass extends ByteArrayAsset {
}
}//package
Section 179
//EmbeddedResources_PieuvreAtkClass (EmbeddedResources_PieuvreAtkClass)
package {
import mx.core.*;
public class EmbeddedResources_PieuvreAtkClass extends SoundAsset {
}
}//package
Section 180
//EmbeddedResources_PinguinAtkClass (EmbeddedResources_PinguinAtkClass)
package {
import mx.core.*;
public class EmbeddedResources_PinguinAtkClass extends SoundAsset {
}
}//package
Section 181
//EmbeddedResources_PoussinAtkClass (EmbeddedResources_PoussinAtkClass)
package {
import mx.core.*;
public class EmbeddedResources_PoussinAtkClass extends SoundAsset {
}
}//package
Section 182
//EmbeddedResources_sheepClass (EmbeddedResources_sheepClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_sheepClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_sheepClass(){
dataClass = EmbeddedResources_sheepClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 183
//EmbeddedResources_sheepClass_dataClass (EmbeddedResources_sheepClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_sheepClass_dataClass extends ByteArrayAsset {
}
}//package
Section 184
//EmbeddedResources_snapoutClass (EmbeddedResources_snapoutClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_snapoutClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_snapoutClass(){
dataClass = EmbeddedResources_snapoutClass_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 185
//EmbeddedResources_snapoutClass_dataClass (EmbeddedResources_snapoutClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_snapoutClass_dataClass extends ByteArrayAsset {
}
}//package
Section 186
//EmbeddedResources_spawnxmlClass (EmbeddedResources_spawnxmlClass)
package {
import mx.core.*;
public class EmbeddedResources_spawnxmlClass extends ByteArrayAsset {
}
}//package
Section 187
//EmbeddedResources_splashOdd1Class (EmbeddedResources_splashOdd1Class)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_splashOdd1Class extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_splashOdd1Class(){
dataClass = EmbeddedResources_splashOdd1Class_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 188
//EmbeddedResources_splashOdd1Class_dataClass (EmbeddedResources_splashOdd1Class_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_splashOdd1Class_dataClass extends ByteArrayAsset {
}
}//package
Section 189
//EmbeddedResources_squidClass (EmbeddedResources_squidClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_squidClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_squidClass(){
dataClass = EmbeddedResources_squidClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 190
//EmbeddedResources_squidClass_dataClass (EmbeddedResources_squidClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_squidClass_dataClass extends ByteArrayAsset {
}
}//package
Section 191
//EmbeddedResources_sunClass (EmbeddedResources_sunClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_sunClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_sunClass(){
dataClass = EmbeddedResources_sunClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 192
//EmbeddedResources_sunClass_dataClass (EmbeddedResources_sunClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_sunClass_dataClass extends ByteArrayAsset {
}
}//package
Section 193
//EmbeddedResources_tentacleClass (EmbeddedResources_tentacleClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_tentacleClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_tentacleClass(){
dataClass = EmbeddedResources_tentacleClass_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 194
//EmbeddedResources_tentacleClass_dataClass (EmbeddedResources_tentacleClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_tentacleClass_dataClass extends ByteArrayAsset {
}
}//package
Section 195
//EmbeddedResources_TorcheClass (EmbeddedResources_TorcheClass)
package {
import mx.core.*;
public class EmbeddedResources_TorcheClass extends SoundAsset {
}
}//package
Section 196
//EmbeddedResources_transitionClass (EmbeddedResources_transitionClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_transitionClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_transitionClass(){
dataClass = EmbeddedResources_transitionClass_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 197
//EmbeddedResources_transitionClass_dataClass (EmbeddedResources_transitionClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_transitionClass_dataClass extends ByteArrayAsset {
}
}//package
Section 198
//EmbeddedResources_wflameClass (EmbeddedResources_wflameClass)
package {
import mx.core.*;
import flash.utils.*;
public class EmbeddedResources_wflameClass extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function EmbeddedResources_wflameClass(){
dataClass = EmbeddedResources_wflameClass_dataClass;
super();
initialWidth = (11000 / 20);
initialHeight = (8000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 199
//EmbeddedResources_wflameClass_dataClass (EmbeddedResources_wflameClass_dataClass)
package {
import mx.core.*;
public class EmbeddedResources_wflameClass_dataClass extends ByteArrayAsset {
}
}//package
Section 200
//LiteLoader (LiteLoader)
package {
import flash.events.*;
import debug.*;
import managers.ui.*;
import flash.display.*;
import global.*;
import managers.resources.*;
import managers.modules.*;
import animation.*;
import flash.system.*;
public final class LiteLoader extends Sprite {
private var firstFrame:Boolean;
public var saveFunction:Function;
public var isEngineReady:Boolean;
public var loadFunction:Function;
public static const BUILD_VERSION:String = "BUILD 100";
public function LiteLoader(){
super();
Security.allowDomain("*");
this.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage, false, 0, true);
firstFrame = true;
isEngineReady = false;
}
public function setLogin(username:String, password:String):void{
GlobalData.username = username;
GlobalData.password = password;
}
private function handleAddedToStage(event:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
stage.stageFocusRect = false;
DebugFileWriter.getInstance().setFunctions(saveFunction, loadFunction);
stage.addChild(ResourceManager.getInstance());
stage.addChild(ModuleManager.getInstance());
stage.addChild(InputManager.getInstance());
GlobalData.BUILD_VERSION = BUILD_VERSION;
SwfAnimationConversionTool.validAnchorNameList = null;
var embeddedResourceList:Class = LiteLoader_embeddedResourceList;
var embeddedModuleList:Class = LiteLoader_embeddedModuleList;
ModuleManager.getInstance().setMaster(XML(embeddedModuleList.data), XML(embeddedResourceList.data), new EmbeddedModules(), new EmbeddedResources());
stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame, false, 0, true);
}
private function handleEnterFrame(event:Event):void{
if (ModuleManager.getInstance().isLoadingFinished()){
if (firstFrame){
firstFrame = false;
ResourceManager.getInstance().loadAllResources();
} else {
if (ResourceManager.getInstance().isLoadingFinished()){
isEngineReady = true;
ModuleManager.getInstance().pushModuleIndex(0);
stage.removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
parent.removeChild(this);
};
};
};
}
}
}//package
Section 201
//LiteLoader_embeddedModuleList (LiteLoader_embeddedModuleList)
package {
public class LiteLoader_embeddedModuleList {
public static var data:XML = <modules resList="resources.xml">
<module name="toughlove" url="ToughLove.swf" visible="true">
<resourcePackage name="global"/>
</module>
</modules>
;
}
}//package
Section 202
//LiteLoader_embeddedResourceList (LiteLoader_embeddedResourceList)
package {
public class LiteLoader_embeddedResourceList {
public static var data:XML = <resources resPath="Z:/GameAssets/"> <!-- "Z:/GameAssets/" "GameAssets/" -->
<!-- character -->
<resource id="herodown" packageId="global" url="character/hero/ch_hero_lower.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="heroup" packageId="global" url="character/hero/ch_hero_upper.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="herolarm" packageId="global" url="character/hero/ch_hero_armL.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="herorarm" packageId="global" url="character/hero/ch_hero_armR.swf" type="pure_swf_needcompilation" size="1"/>
<!-- fx -->
<resource id="wflame" packageId="global" url="fx/fx_flame.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="snapout" packageId="global" url="fx/fx_snapOut.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="note" packageId="global" url="fx/fx_note.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="tentacle" packageId="global" url="fx/fx_tentacle.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="cloud1" packageId="global" url="fx/fx_cloud1.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="cloud2" packageId="global" url="fx/fx_cloud2.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="cloud3" packageId="global" url="fx/fx_cloud3.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="cloud4" packageId="global" url="fx/fx_cloud4.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="cloud5" packageId="global" url="fx/fx_cloud5.swf" type="pure_swf_needcompilation" size="1"/>
<!-- monster -->
<resource id="sheep" packageId="global" url="character/monster/ch_sheep.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="bunny" packageId="global" url="character/monster/ch_bunny.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="chick" packageId="global" url="character/monster/ch_chick.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="squid" packageId="global" url="character/monster/CH_SQUID.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="penguin" packageId="global" url="character/monster/ch_penguin.swf" type="pure_swf_needcompilation" size="1"/>
<!-- XML -->
<resource id="levelxml" packageId="global" url="xml/levels.xml" type="xml_data" size="1"/>
<resource id="monstersxml" packageId="global" url="xml/units.xml" type="xml_data" size="1"/>
<resource id="spawnxml" packageId="global" url="xml/monsterSpawn.xml" type="xml_data" size="1"/>
<!-- Levels -->
<resource id="level0" packageId="global" url="levels/level01/level01_front.swf" type="swf" size="1"/>
<resource id="level1" packageId="global" url="levels/level02/level02_front.swf" type="swf" size="1"/>
<resource id="level2" packageId="global" url="levels/level03/level03_front.swf" type="swf" size="1"/>
<resource id="level3" packageId="global" url="levels/level04/level04_front.swf" type="swf" size="1"/>
<resource id="level4" packageId="global" url="levels/level05/level05_front.swf" type="swf" size="1"/>
<resource id="level0_middle" packageId="global" url="levels/level01/level01_middle.swf" type="swf" size="1"/>
<resource id="level1_middle" packageId="global" url="levels/level02/level02_middle.swf" type="swf" size="1"/>
<resource id="level2_middle" packageId="global" url="levels/level03/level03_middle.swf" type="swf" size="1"/>
<resource id="level3_middle" packageId="global" url="levels/level04/level04_middle.swf" type="swf" size="1"/>
<resource id="level4_middle" packageId="global" url="levels/level05/level05_middle.swf" type="swf" size="1"/>
<resource id="level0_far" packageId="global" url="levels/level01/level01_far.swf" type="swf" size="1"/>
<resource id="level1_far" packageId="global" url="levels/level02/level02_far.swf" type="swf" size="1"/>
<resource id="level2_far" packageId="global" url="levels/level03/level03_far.swf" type="swf" size="1"/>
<resource id="level3_far" packageId="global" url="levels/level04/level04_far.swf" type="swf" size="1"/>
<resource id="level4_far" packageId="global" url="levels/level05/level05_far.swf" type="swf" size="1"/>
<resource id="level0_sky" packageId="global" url="levels/level01/level01_sky.swf" type="swf" size="1"/>
<resource id="level1_sky" packageId="global" url="levels/level02/level02_sky.swf" type="swf" size="1"/>
<resource id="level2_sky" packageId="global" url="levels/level03/level03_sky.swf" type="swf" size="1"/>
<resource id="level3_sky" packageId="global" url="levels/level04/level04_sky.swf" type="swf" size="1"/>
<resource id="level4_sky" packageId="global" url="levels/level05/level05_sky.swf" type="swf" size="1"/>
<!-- Screen -->
<resource id="hud" packageId="global" url="screen/hud02.swf" type="swf" size="1"/>
<resource id="mainmenu" packageId="global" url="screen/MainMenu.swf" type="swf" size="1"/>
<resource id="gamedone" packageId="global" url="screen/gameDone.swf" type="swf" size="1"/>
<resource id="gameover" packageId="global" url="screen/gameOver.swf" type="swf" size="1"/>
<resource id="transition" packageId="global" url="screen/transition.swf" type="swf" size="1"/>
<resource id="endstage" packageId="global" url="screen/endingStage.swf" type="swf" size="1"/>
<resource id="splashOdd1" packageId="global" url="screen/splashOdd1.swf" type="swf" size="1"/>
<!-- Background -->
<resource id="sun" packageId="global" url="character/ch_sun.swf" type="pure_swf_needcompilation" size="1"/>
<resource id="clouds" packageId="global" url="fx/fx_cloudy.swf" type="swf" size="1"/>
<!-- Drops -->
<resource id="healthpack" packageId="global" url="drops/d_healthpack.swf" type="swf_needcompilation" size="1"/>
<resource id="gazpack" packageId="global" url="drops/d_gazpack.swf" type="swf_needcompilation" size="1"/>
<resource id="nitropack" packageId="global" url="drops/d_nitropack.swf" type="swf_needcompilation" size="1"/>
<resource id="Boutons" packageId="global" url="sounds/tinkle_highlight_02.mp3" type="sound" size="1"/>
<resource id="Torche" packageId="global" url="sounds/flamer.mp3" type="sound" size="1"/>
<resource id="DeathHero" packageId="global" url="sounds/flamer_dies.mp3" type="sound" size="1"/>
<resource id="MoutonAtk" packageId="global" url="sounds/goat_bleat_16.mp3" type="sound" size="1"/>
<resource id="LapinAtk" packageId="global" url="sounds/raccoon_answer_short_02.mp3" type="sound" size="1"/>
<resource id="PoussinAtk" packageId="global" url="sounds/chick02.mp3" type="sound" size="1"/>
<resource id="PinguinAtk" packageId="global" url="sounds/djscratch03.mp3" type="sound" size="1"/>
<resource id="PieuvreAtk" packageId="global" url="sounds/bone_break05.mp3" type="sound" size="1"/>
<resource id="DeathEnn" packageId="global" url="sounds/bigHit.mp3" type="sound" size="1"/>
<resource id="MainMusic" packageId="global" url="sounds/fantasyland_full_loop.mp3" type="sound" size="1"/>
<resource id="InGameMusic" packageId="global" url="sounds/tastes_like_burning_60.mp3" type="sound" size="1"/>
<resource id="EndStage" packageId="global" url="sounds/powerup_16.mp3" type="sound" size="1"/>
<resource id="DeathMusic" packageId="global" url="sounds/fantasyland_full_loop.mp3" type="sound" size="1"/>
</resources>
;
}
}//package
Section 203
//Preloader (Preloader)
package {
import flash.events.*;
import flash.display.*;
import mochi.as3.*;
import flash.utils.*;
public class Preloader extends MovieClip {
private var _clip:MovieClip;
public function Preloader(){
super();
_clip = new MovieClip();
addChild(_clip);
MochiAd.showPreGameAd({clip:_clip, id:"787756d4d65fdcd0", res:"640x480", ad_finished:MochiAdComplete});
}
private function enterFrameHandler(event:Event):void{
var mainClass:Class;
if (framesLoaded == totalFrames){
nextFrame();
mainClass = Class(getDefinitionByName("LiteLoader"));
if (mainClass){
addChild(new (mainClass));
};
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
};
}
private function MochiAdComplete():void{
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
}
}//package