Section 1
//AI_Base (AI.AI_Base)
package AI {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import Collision.*;
public class AI_Base {
public var AITimer:Timer;
public var stopGroupSend:Boolean;// = false
protected var groupFrom:Planet;
public var cruiser:Boolean;
public var myGame:Game;
public var impulseDrive:Boolean;// = false
public var myEnemyID:int;
private var checkFreeWaySave:Array;
protected var groupTo:Planet;
public var defensiveLaser:Boolean;// = false
protected var supportRequested:Array;// = null
protected var groupSize:int;
public var defenseTimer:Timer;
public var deathStar:Boolean;
public var destroyers:Boolean;// = false
public var shields:Boolean;// = false
public var SHUsed:int;// = 1
public var nanites:Boolean;// = false
public var savingMode:Number;// = 123456789
public function AI_Base(game:Game, enemyID:int=2){
var t:int;
AITimer = new Timer(6000);
defenseTimer = new Timer(750);
checkFreeWaySave = new Array();
super();
myGame = game;
myEnemyID = enemyID;
var i:int;
while (i < (myGame.mySpace.myPlanets.length + 1)) {
checkFreeWaySave.push(new Array());
t = 0;
while (t < (myGame.mySpace.myPlanets.length + 1)) {
checkFreeWaySave[i].push(0);
t++;
};
i++;
};
}
protected function getRebelPlanets():Array{
var result:Array = new Array();
var i:int;
while (i < myGame.mySpace.myPlanets.length) {
if (Planet(myGame.mySpace.myPlanets[i]).myOwner == 3){
result.push(myGame.mySpace.myPlanets[i]);
};
i++;
};
return (result);
}
protected function enemyTotalUnits():int{
var i:int;
var enemyPlanets:Array = getEnemyPlanets();
var total:int;
while (i < enemyPlanets.length) {
total = (total + enemyPlanets[i].myUnits);
i++;
};
return (total);
}
protected function checkFreeWay(from:Planet, destination:Planet):Boolean{
var collisionTester:MovieClip;
var colList:CollisionList;
var i:int;
if (checkFreeWaySave[from.id][destination.id] == 0){
collisionTester = new MovieClip();
this.myGame.mySpace.addChild(collisionTester);
collisionTester.graphics.lineStyle(20, 0xFFFFFF, 1);
collisionTester.graphics.moveTo(from.x, from.y);
collisionTester.graphics.lineTo(destination.x, destination.y);
colList = new CollisionList(collisionTester);
i = 0;
while (i < myGame.mySpace.myAsteroidFields.length) {
colList.addItem(myGame.mySpace.myAsteroidFields[i]);
i++;
};
if (colList.checkCollisions().length > 0){
this.myGame.mySpace.removeChild(collisionTester);
checkFreeWaySave[from.id][destination.id] = 2;
return (false);
};
this.myGame.mySpace.removeChild(collisionTester);
checkFreeWaySave[from.id][destination.id] = 3;
return (true);
} else {
if (checkFreeWaySave[from.id][destination.id] == 2){
return (false);
};
//unresolved if
};
return (!NULL!);
return (true);
}
protected function sendGroup(from:Planet, destination:Planet, number:int):void{
var sender:SenderTimer = new SenderTimer(this, from, destination, number);
sender.addEventListener(TimerEvent.TIMER, sender.selfExecution, false, 0, true);
sender.start();
}
public function getMyPlanets():Array{
var result:Array = new Array();
var i:int;
while (i < myGame.mySpace.myPlanets.length) {
if (Planet(myGame.mySpace.myPlanets[i]).myOwner == myEnemyID){
result.push(myGame.mySpace.myPlanets[i]);
};
i++;
};
return (result);
}
public function getFleetGoingTo(planet:Planet, owner):Array{
var result:Array = new Array();
var i:int;
while (i < myGame.mySpace.myFleets.length) {
if (Fleet(myGame.mySpace.myFleets[i]).myDestination == planet){
if (Fleet(myGame.mySpace.myFleets[i]).myOwner == owner){
result.push(myGame.mySpace.myFleets[i]);
};
};
i++;
};
return (result);
}
protected function getNeutralPlanets():Array{
var result:Array = new Array();
var i:int;
while (i < myGame.mySpace.myPlanets.length) {
if (Planet(myGame.mySpace.myPlanets[i]).myOwner == 0){
result.push(myGame.mySpace.myPlanets[i]);
};
i++;
};
return (result);
}
public function getEnemyPlanets():Array{
var result:Array = new Array();
var i:int;
while (i < myGame.mySpace.myPlanets.length) {
if (((((!((Planet(myGame.mySpace.myPlanets[i]).myOwner == 3))) && (!((Planet(myGame.mySpace.myPlanets[i]).myOwner == 0))))) && (!((Planet(myGame.mySpace.myPlanets[i]).myOwner == myEnemyID))))){
result.push(myGame.mySpace.myPlanets[i]);
};
i++;
};
return (result);
}
protected function myTotalUnits():int{
var i:int;
var myPlanets:Array = getMyPlanets();
var total:int;
while (i < myPlanets.length) {
total = (total + myPlanets[i].myUnits);
i++;
};
return (total);
}
public function shutDown():void{
AITimer.stop();
defenseTimer.stop();
stopGroupSend = true;
}
protected function isPlanetInDanger(planet:Planet, modification:Number=0):Boolean{
if (getFleetGoingTo(planet, 1).length >= ((modification + planet.myUnits) + getFleetGoingTo(planet, myEnemyID).length)){
return (true);
};
return (false);
}
}
}//package AI
Section 2
//AI_Level1 (AI.AI_Level1)
package AI {
import flash.events.*;
public class AI_Level1 extends AI_Base {
public function AI_Level1(game:Game, enemyID:int=2){
super(game, enemyID);
AITimer.addEventListener(TimerEvent.TIMER, act, false, 0, true);
AITimer.start();
}
private function act(e:TimerEvent):void{
if (myGame.isPaused){
return;
};
var myPlanets:Array = getMyPlanets();
var enemyPlanets:Array = getEnemyPlanets();
if ((((enemyPlanets.length == 0)) || ((myPlanets.length == 0)))){
return;
};
var selectedPlanet:Planet = Planet(myPlanets[RandomNumber.generate(0, (myPlanets.length - 1))]);
var randomEnemyPlanet:Planet = Planet(enemyPlanets[RandomNumber.generate(0, (enemyPlanets.length - 1))]);
selectedPlanet.sendFleet(randomEnemyPlanet, SHUsed);
}
}
}//package AI
Section 3
//AI_Level2 (AI.AI_Level2)
package AI {
import flash.events.*;
import flash.utils.*;
public class AI_Level2 extends AI_Base {
public function AI_Level2(game:Game, enemyID:int=2){
super(game, enemyID);
AITimer.delay = 2000;
AITimer.addEventListener(TimerEvent.TIMER, act, false, 0, true);
AITimer.start();
defenseTimer = new Timer(750);
defenseTimer.addEventListener(TimerEvent.TIMER, defense, false, 0, true);
defenseTimer.start();
}
private function centralizeUnits(planet:Planet):void{
var myPlanets:Array = getMyPlanets();
var i:int;
while (i < myPlanets.length) {
if (myPlanets[i] != planet){
if (myPlanets[i].myUnits >= 10){
sendGroup(myPlanets[i], planet, 10);
};
};
i++;
};
}
private function act(e:TimerEvent):void{
var myPlanets:Array;
var action:String;
if (myGame.isPaused){
return;
};
if (savingMode != 123456789){
defenseTimer.stop();
myPlanets = getMyPlanets();
if (myPlanets[savingMode] == null){
savingMode = 123456789;
return;
};
if (myPlanets[savingMode].myUnits < 100){
centralizeUnits(myPlanets[savingMode]);
return;
};
};
var colo:Boolean;
var myUnits:Number = myTotalUnits();
var enemyUnits:Number = enemyTotalUnits();
if (myUnits <= (enemyUnits * 1.25)){
colo = true;
};
if ((((myUnits <= enemyUnits)) && ((myUnits >= 30)))){
colo = false;
};
if (colo){
action = colonize();
action = attack(action);
} else {
if (savingMode != 123456789){
sendDeathStar();
return;
};
action = attack("attack");
if (action == colonize()){
colonize();
};
};
}
private function sendDeathStar():void{
var enemyPlanets:Array = getEnemyPlanets();
enemyPlanets = enemyPlanets.sortOn("mySize", Array.DESCENDING);
var selectedEnemy:Planet = enemyPlanets[0];
sendGroup(getMyPlanets()[savingMode], selectedEnemy, 1);
}
private function defense(e:TimerEvent=null):void{
var k:int;
if (myGame.isPaused){
return;
};
var myPlanets:Array = getMyPlanets();
var planetsToDefend:Array = new Array();
var i:int;
while (i < myPlanets.length) {
if (getFleetGoingTo(myPlanets[i], 1).length >= Planet(myPlanets[i]).myUnits){
planetsToDefend.push(myPlanets[i]);
};
i++;
};
var totalFriendlyUnits:int;
var totalEnemyUnits:int;
i = 0;
while (i < planetsToDefend.length) {
totalEnemyUnits = getFleetGoingTo(planetsToDefend[i], 1).length;
totalFriendlyUnits = (Planet(planetsToDefend[i]).myUnits + getFleetGoingTo(planetsToDefend[i], myEnemyID).length);
k = 0;
while (k < myPlanets.length) {
if (totalEnemyUnits >= totalFriendlyUnits){
if (myPlanets[k] != planetsToDefend[i]){
if (this.checkFreeWay(myPlanets[k], planetsToDefend[i])){
if (getFleetGoingTo(myPlanets[k], 1).length < (Planet(myPlanets[k]).myUnits - (Planet(myPlanets[k]).myUnits / 2))){
totalFriendlyUnits = (totalFriendlyUnits + (Planet(myPlanets[k]).myUnits / 2));
this.sendGroup(myPlanets[k], planetsToDefend[i], (Planet(myPlanets[k]).myUnits / 2));
};
};
};
};
k++;
};
i++;
};
}
private function attack(action:String):String{
var i:int;
var closestPlanet:Planet;
var selectedPlanet:Planet;
var unitsToSend:*;
if (action == null){
return (null);
};
if (action != "attack"){
return (null);
};
var myPlanets:Array = getMyPlanets();
var enemyPlanets:Array = getEnemyPlanets();
var rebelPlanets:Array = getRebelPlanets();
var neutralPlanets:Array = getNeutralPlanets();
if ((((myPlanets.length == 0)) || ((enemyPlanets.length == 0)))){
return (null);
};
enemyPlanets = enemyPlanets.sortOn("myUnits", Array.NUMERIC);
var ChosenEnemyPlanet:Planet = Planet(enemyPlanets[0]);
i = 0;
while (i < myPlanets.length) {
Planet(myPlanets[i]).setAISelectedPlanet(ChosenEnemyPlanet);
i++;
};
myPlanets = myPlanets.sortOn("distanceToSelectedPlanet", Array.NUMERIC);
if (myPlanets.length > 0){
i = (myPlanets.length - 1);
while (i >= 0) {
if (checkFreeWay(myPlanets[i], ChosenEnemyPlanet)){
closestPlanet = myPlanets[0];
};
i--;
};
};
if (closestPlanet == null){
return ("colonize");
};
var unitsNeeded:int = (ChosenEnemyPlanet.myUnits + (2 * ChosenEnemyPlanet.mySize));
if (unitsNeeded < 4){
unitsNeeded = 6;
};
var pCount:int;
while (pCount < myPlanets.length) {
if (unitsNeeded <= 0){
break;
};
selectedPlanet = myPlanets[pCount];
unitsToSend = (unitsNeeded + 1);
if (unitsToSend > selectedPlanet.myUnits){
unitsToSend = Math.round((selectedPlanet.myUnits * 0.6));
};
if (this.checkFreeWay(ChosenEnemyPlanet, selectedPlanet)){
if (isPlanetInDanger(selectedPlanet, unitsToSend) == false){
sendGroup(selectedPlanet, ChosenEnemyPlanet, unitsToSend);
unitsNeeded = (unitsNeeded - unitsToSend);
};
} else {
if (((this.checkFreeWay(closestPlanet, selectedPlanet)) && (!((closestPlanet == selectedPlanet))))){
sendGroup(selectedPlanet, closestPlanet, Math.round((selectedPlanet.myUnits * 0.6)));
} else {
return ("colonization");
};
};
pCount++;
};
return (null);
}
private function colonize():String{
var i:int;
var myPlanets:Array = getMyPlanets();
var enemyPlanets:Array = getEnemyPlanets();
var rebelPlanets:Array = getRebelPlanets();
var neutralPlanets:Array = getNeutralPlanets();
var selectedPlanet:Planet = Planet(myPlanets[RandomNumber.generate(0, (myPlanets.length - 1))]);
var randomEnemyPlanet:Planet = Planet(enemyPlanets[RandomNumber.generate(0, (enemyPlanets.length - 1))]);
if ((((enemyPlanets.length == 0)) || ((myPlanets.length == 0)))){
return (null);
};
var action:String = "colonize";
var neutralColoImpossible:Boolean;
if ((((action == "colonize")) && ((selectedPlanet.myUnits > 2)))){
if (neutralPlanets.length != 0){
if ((((neutralPlanets.length == 0)) && ((rebelPlanets.length == 0)))){
action = "attack";
};
i = 0;
while (i < neutralPlanets.length) {
Planet(neutralPlanets[i]).setAISelectedPlanet(selectedPlanet);
i++;
};
neutralPlanets = neutralPlanets.sortOn("distanceToSelectedPlanet", Array.DESCENDING);
i = 0;
while (i < neutralPlanets.length) {
if (this.checkFreeWay(neutralPlanets[i], selectedPlanet)){
if (isPlanetInDanger(selectedPlanet, -(Math.round((selectedPlanet.myUnits / 4)))) == false){
neutralColoImpossible = false;
sendGroup(selectedPlanet, neutralPlanets[i], Math.round((selectedPlanet.myUnits / 4)));
action = "colonize";
};
};
i++;
};
};
};
if ((((neutralPlanets.length == 0)) || (neutralColoImpossible))){
i = 0;
while (i < rebelPlanets.length) {
Planet(rebelPlanets[i]).setAISelectedPlanet(selectedPlanet);
i++;
};
rebelPlanets = rebelPlanets.sortOn("distanceToSelectedPlanet", Array.DESCENDING);
i = 0;
while (i < rebelPlanets.length) {
if (Planet(rebelPlanets[i]).myUnits <= (selectedPlanet.myUnits * 0.75)){
if (this.checkFreeWay(rebelPlanets[i], selectedPlanet)){
sendGroup(selectedPlanet, rebelPlanets[i], Math.round((selectedPlanet.myUnits * 0.75)));
return (null);
};
};
if (selectedPlanet.myUnits == selectedPlanet.myMax){
if (this.checkFreeWay(rebelPlanets[i], selectedPlanet)){
sendGroup(selectedPlanet, rebelPlanets[i], Math.round((selectedPlanet.myMax / 2)));
return (null);
};
};
i++;
};
};
if ((((neutralPlanets.length == 0)) && ((rebelPlanets.length == 0)))){
action = "attack";
};
if ((((rebelPlanets.length == 0)) && (neutralColoImpossible))){
action = "attack";
};
return (action);
}
private function transferFor(from:Planet, target:Planet, numShip:int, recured:Boolean=false):void{
var i:int;
var myPlanets:Array = getMyPlanets();
while (i < myPlanets.length) {
if (checkFreeWay(myPlanets[i], target)){
if (checkFreeWay(from, myPlanets[i])){
sendGroup(from, myPlanets[i], numShip);
return;
};
if (recured){
return;
};
transferFor(from, target, numShip, true);
};
i++;
};
}
}
}//package AI
Section 4
//SenderTimer (AI.SenderTimer)
package AI {
import flash.events.*;
import flash.utils.*;
public class SenderTimer extends Timer {
public var groupSize:int;
private var realDelay:int;
public var groupFrom:Planet;
public var myEnemyID:int;
public var groupTo:Planet;
public var myAI:AI_Base;
public function SenderTimer(ai:AI_Base, from:Planet, destination:Planet, size:int, repeatCount:int=0){
realDelay = RandomNumber.generate(60, 100);
super(RandomNumber.generate(100, 400), repeatCount);
groupFrom = from;
groupTo = destination;
groupSize = size;
myAI = ai;
myEnemyID = ai.myEnemyID;
}
public function selfExecution(e:TimerEvent):void{
if (myAI.myGame.isPaused){
return;
};
delay = realDelay;
if (myAI.stopGroupSend){
this.stop();
this.myAI = null;
this.groupFrom = null;
this.groupTo = null;
return;
};
if (groupFrom.myOwner != this.myEnemyID){
(groupSize == 0);
};
if (groupSize <= 0){
this.stop();
this.myAI = null;
this.groupFrom = null;
this.groupTo = null;
return;
};
groupSize--;
if ((((groupFrom.myUnits >= 2)) && (myAI.destroyers))){
myAI.SHUsed = 2;
};
if ((((groupFrom.myUnits >= 20)) && (myAI.cruiser))){
myAI.SHUsed = 3;
};
if ((((groupFrom.myUnits >= 100)) && (myAI.deathStar))){
myAI.SHUsed = 4;
};
groupFrom.sendFleet(groupTo, myAI.SHUsed);
}
}
}//package AI
Section 5
//SoundShortcuts (caurina.transitions.properties.SoundShortcuts)
package caurina.transitions.properties {
import caurina.transitions.*;
import flash.media.*;
public class SoundShortcuts {
public function SoundShortcuts(){
super();
trace("This is an static class and should not be instantiated.");
}
public static function init():void{
Tweener.registerSpecialProperty("_sound_volume", _sound_volume_get, _sound_volume_set);
Tweener.registerSpecialProperty("_sound_pan", _sound_pan_get, _sound_pan_set);
}
public static function _sound_pan_set(p_obj:Object, p_value:Number, p_parameters:Array, p_extra:Object=null):void{
var sndTransform:SoundTransform = p_obj.soundTransform;
sndTransform.pan = p_value;
p_obj.soundTransform = sndTransform;
}
public static function _sound_volume_set(p_obj:Object, p_value:Number, p_parameters:Array, p_extra:Object=null):void{
var sndTransform:SoundTransform = p_obj.soundTransform;
sndTransform.volume = p_value;
p_obj.soundTransform = sndTransform;
}
public static function _sound_pan_get(p_obj:Object, p_parameters:Array, p_extra:Object=null):Number{
return (p_obj.soundTransform.pan);
}
public static function _sound_volume_get(p_obj:Object, p_parameters:Array, p_extra:Object=null):Number{
return (p_obj.soundTransform.volume);
}
}
}//package caurina.transitions.properties
Section 6
//AuxFunctions (caurina.transitions.AuxFunctions)
package caurina.transitions {
public class AuxFunctions {
public function AuxFunctions(){
super();
}
public static function getObjectLength(p_object:Object):uint{
var pName:String;
var totalProperties:uint;
for (pName in p_object) {
totalProperties++;
};
return (totalProperties);
}
public static function numberToG(p_num:Number):Number{
return (((p_num & 0xFF00) >> 8));
}
public static function numberToB(p_num:Number):Number{
return ((p_num & 0xFF));
}
public static function numberToR(p_num:Number):Number{
return (((p_num & 0xFF0000) >> 16));
}
public static function concatObjects(... _args):Object{
var currentObject:Object;
var prop:String;
var finalObject:Object = {};
var i:int;
while (i < _args.length) {
currentObject = _args[i];
for (prop in currentObject) {
if (currentObject[prop] == null){
delete finalObject[prop];
} else {
finalObject[prop] = currentObject[prop];
};
};
i++;
};
return (finalObject);
}
}
}//package caurina.transitions
Section 7
//Equations (caurina.transitions.Equations)
package caurina.transitions {
public class Equations {
public function Equations(){
super();
trace("Equations is a static class and should not be instantiated.");
}
public static function easeOutBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
if (t < (1 / 2.75)){
return (((c * ((7.5625 * t) * t)) + b));
};
if (t < (2 / 2.75)){
t = (t - (1.5 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.75)) + b));
};
if (t < (2.5 / 2.75)){
t = (t - (2.25 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.9375)) + b));
};
t = (t - (2.625 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.984375)) + b));
}
public static function easeInOutElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / (d / 2));
if (t == 2){
return ((b + c));
};
var p:Number = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * (0.3 * 1.5)) : p_params.period;
var a:Number = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
if (t < 1){
--t;
return (((-0.5 * ((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
};
--t;
return ((((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) * 0.5) + c) + b));
}
public static function easeInOutQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * t) * t) + b));
};
--t;
return ((((-(c) / 2) * ((t * (t - 2)) - 1)) + b));
}
public static function easeInOutBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (((easeInBounce((t * 2), 0, c, d) * 0.5) + b));
};
return ((((easeOutBounce(((t * 2) - d), 0, c, d) * 0.5) + (c * 0.5)) + b));
}
public static function easeInOutBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = (t / (d / 2));
if (t < 1){
s = (s * 1.525);
return ((((c / 2) * ((t * t) * (((s + 1) * t) - s))) + b));
};
t = (t - 2);
s = (s * 1.525);
return ((((c / 2) * (((t * t) * (((s + 1) * t) + s)) + 2)) + b));
}
public static function easeOutInCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutCubic((t * 2), b, (c / 2), d, p_params));
};
return (easeInCubic(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeNone(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((c * t) / d) + b));
}
public static function easeOutBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = ((t / d) - 1);
return (((c * (((t * t) * (((s + 1) * t) + s)) + 1)) + b));
}
public static function easeInOutSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((-(c) / 2) * (Math.cos(((Math.PI * t) / d)) - 1)) + b));
}
public static function easeInBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = (t / d);
return (((((c * t) * t) * (((s + 1) * t) - s)) + b));
}
public static function easeInQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((((c * t) * t) * t) * t) + b));
}
public static function easeOutInQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuint((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuint(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutInBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutBounce((t * 2), b, (c / 2), d, p_params));
};
return (easeInBounce(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function init():void{
Tweener.registerTransition("easenone", easeNone);
Tweener.registerTransition("linear", easeNone);
Tweener.registerTransition("easeinquad", easeInQuad);
Tweener.registerTransition("easeoutquad", easeOutQuad);
Tweener.registerTransition("easeinoutquad", easeInOutQuad);
Tweener.registerTransition("easeoutinquad", easeOutInQuad);
Tweener.registerTransition("easeincubic", easeInCubic);
Tweener.registerTransition("easeoutcubic", easeOutCubic);
Tweener.registerTransition("easeinoutcubic", easeInOutCubic);
Tweener.registerTransition("easeoutincubic", easeOutInCubic);
Tweener.registerTransition("easeinquart", easeInQuart);
Tweener.registerTransition("easeoutquart", easeOutQuart);
Tweener.registerTransition("easeinoutquart", easeInOutQuart);
Tweener.registerTransition("easeoutinquart", easeOutInQuart);
Tweener.registerTransition("easeinquint", easeInQuint);
Tweener.registerTransition("easeoutquint", easeOutQuint);
Tweener.registerTransition("easeinoutquint", easeInOutQuint);
Tweener.registerTransition("easeoutinquint", easeOutInQuint);
Tweener.registerTransition("easeinsine", easeInSine);
Tweener.registerTransition("easeoutsine", easeOutSine);
Tweener.registerTransition("easeinoutsine", easeInOutSine);
Tweener.registerTransition("easeoutinsine", easeOutInSine);
Tweener.registerTransition("easeincirc", easeInCirc);
Tweener.registerTransition("easeoutcirc", easeOutCirc);
Tweener.registerTransition("easeinoutcirc", easeInOutCirc);
Tweener.registerTransition("easeoutincirc", easeOutInCirc);
Tweener.registerTransition("easeinexpo", easeInExpo);
Tweener.registerTransition("easeoutexpo", easeOutExpo);
Tweener.registerTransition("easeinoutexpo", easeInOutExpo);
Tweener.registerTransition("easeoutinexpo", easeOutInExpo);
Tweener.registerTransition("easeinelastic", easeInElastic);
Tweener.registerTransition("easeoutelastic", easeOutElastic);
Tweener.registerTransition("easeinoutelastic", easeInOutElastic);
Tweener.registerTransition("easeoutinelastic", easeOutInElastic);
Tweener.registerTransition("easeinback", easeInBack);
Tweener.registerTransition("easeoutback", easeOutBack);
Tweener.registerTransition("easeinoutback", easeInOutBack);
Tweener.registerTransition("easeoutinback", easeOutInBack);
Tweener.registerTransition("easeinbounce", easeInBounce);
Tweener.registerTransition("easeoutbounce", easeOutBounce);
Tweener.registerTransition("easeinoutbounce", easeInOutBounce);
Tweener.registerTransition("easeoutinbounce", easeOutInBounce);
}
public static function easeOutExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((t)==d) ? (b + c) : (((c * 1.001) * (-(Math.pow(2, ((-10 * t) / d))) + 1)) + b));
}
public static function easeOutInBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutBack((t * 2), b, (c / 2), d, p_params));
};
return (easeInBack(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((t)==0) ? b : (((c * Math.pow(2, (10 * ((t / d) - 1)))) + b) - (c * 0.001)));
}
public static function easeInCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((((c * t) * t) * t) + b));
}
public static function easeInQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((((((c * t) * t) * t) * t) * t) + b));
}
public static function easeInOutCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((-(c) / 2) * (Math.sqrt((1 - (t * t))) - 1)) + b));
};
t = (t - 2);
return ((((c / 2) * (Math.sqrt((1 - (t * t))) + 1)) + b));
}
public static function easeInQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((c * t) * t) + b));
}
public static function easeInBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((c - easeOutBounce((d - t), 0, c, d)) + b));
}
public static function easeOutInExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutExpo((t * 2), b, (c / 2), d, p_params));
};
return (easeInExpo(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((-(c) * ((((t * t) * t) * t) - 1)) + b));
}
public static function easeInSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((-(c) * Math.cos(((t / d) * (Math.PI / 2)))) + c) + b));
}
public static function easeInOutQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return (((((((c / 2) * t) * t) * t) * t) + b));
};
t = (t - 2);
return ((((-(c) / 2) * ((((t * t) * t) * t) - 2)) + b));
}
public static function easeOutQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((-(c) * t) * (t - 2)) + b));
}
public static function easeOutInElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutElastic((t * 2), b, (c / 2), d, p_params));
};
return (easeInElastic(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
var p:Number = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
var a:Number = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
--t;
return ((-(((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
}
public static function easeOutCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * (((t * t) * t) + 1)) + b));
}
public static function easeOutQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * (((((t * t) * t) * t) * t) + 1)) + b));
}
public static function easeOutInQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuad((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuad(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((c * Math.sin(((t / d) * (Math.PI / 2)))) + b));
}
public static function easeInOutCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((((c / 2) * t) * t) * t) + b));
};
t = (t - 2);
return ((((c / 2) * (((t * t) * t) + 2)) + b));
}
public static function easeInOutQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((((((c / 2) * t) * t) * t) * t) * t) + b));
};
t = (t - 2);
return ((((c / 2) * (((((t * t) * t) * t) * t) + 2)) + b));
}
public static function easeInCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((-(c) * (Math.sqrt((1 - (t * t))) - 1)) + b));
}
public static function easeOutInSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutSine((t * 2), b, (c / 2), d, p_params));
};
return (easeInSine(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInOutExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t == 0){
return (b);
};
if (t == d){
return ((b + c));
};
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * Math.pow(2, (10 * (t - 1)))) + b) - (c * 0.0005)));
};
--t;
return (((((c / 2) * 1.0005) * (-(Math.pow(2, (-10 * t))) + 2)) + b));
}
public static function easeOutElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
var p:Number = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
var a:Number = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
return (((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) + c) + b));
}
public static function easeOutCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * Math.sqrt((1 - (t * t)))) + b));
}
public static function easeOutInQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuart((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuart(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutInCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutCirc((t * 2), b, (c / 2), d, p_params));
};
return (easeInCirc(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
}
}//package caurina.transitions
Section 8
//PropertyInfoObj (caurina.transitions.PropertyInfoObj)
package caurina.transitions {
public class PropertyInfoObj {
public var modifierParameters:Array;
public var isSpecialProperty:Boolean;
public var valueComplete:Number;
public var modifierFunction:Function;
public var extra:Object;
public var valueStart:Number;
public var hasModifier:Boolean;
public var arrayIndex:Number;
public var originalValueComplete:Object;
public function PropertyInfoObj(p_valueStart:Number, p_valueComplete:Number, p_originalValueComplete:Object, p_arrayIndex:Number, p_extra:Object, p_isSpecialProperty:Boolean, p_modifierFunction:Function, p_modifierParameters:Array){
super();
valueStart = p_valueStart;
valueComplete = p_valueComplete;
originalValueComplete = p_originalValueComplete;
arrayIndex = p_arrayIndex;
extra = p_extra;
isSpecialProperty = p_isSpecialProperty;
hasModifier = Boolean(p_modifierFunction);
modifierFunction = p_modifierFunction;
modifierParameters = p_modifierParameters;
}
public function toString():String{
var returnStr:String = "\n[PropertyInfoObj ";
returnStr = (returnStr + ("valueStart:" + String(valueStart)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("valueComplete:" + String(valueComplete)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("originalValueComplete:" + String(originalValueComplete)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("arrayIndex:" + String(arrayIndex)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("extra:" + String(extra)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("isSpecialProperty:" + String(isSpecialProperty)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("hasModifier:" + String(hasModifier)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("modifierFunction:" + String(modifierFunction)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("modifierParameters:" + String(modifierParameters)));
returnStr = (returnStr + "]\n");
return (returnStr);
}
public function clone():PropertyInfoObj{
var nProperty:PropertyInfoObj = new PropertyInfoObj(valueStart, valueComplete, originalValueComplete, arrayIndex, extra, isSpecialProperty, modifierFunction, modifierParameters);
return (nProperty);
}
}
}//package caurina.transitions
Section 9
//SpecialProperty (caurina.transitions.SpecialProperty)
package caurina.transitions {
public class SpecialProperty {
public var parameters:Array;
public var getValue:Function;
public var preProcess:Function;
public var setValue:Function;
public function SpecialProperty(p_getFunction:Function, p_setFunction:Function, p_parameters:Array=null, p_preProcessFunction:Function=null){
super();
getValue = p_getFunction;
setValue = p_setFunction;
parameters = p_parameters;
preProcess = p_preProcessFunction;
}
public function toString():String{
var value:String = "";
value = (value + "[SpecialProperty ");
value = (value + ("getValue:" + String(getValue)));
value = (value + ", ");
value = (value + ("setValue:" + String(setValue)));
value = (value + ", ");
value = (value + ("parameters:" + String(parameters)));
value = (value + ", ");
value = (value + ("preProcess:" + String(preProcess)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 10
//SpecialPropertyModifier (caurina.transitions.SpecialPropertyModifier)
package caurina.transitions {
public class SpecialPropertyModifier {
public var getValue:Function;
public var modifyValues:Function;
public function SpecialPropertyModifier(p_modifyFunction:Function, p_getFunction:Function){
super();
modifyValues = p_modifyFunction;
getValue = p_getFunction;
}
public function toString():String{
var value:String = "";
value = (value + "[SpecialPropertyModifier ");
value = (value + ("modifyValues:" + String(modifyValues)));
value = (value + ", ");
value = (value + ("getValue:" + String(getValue)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 11
//SpecialPropertySplitter (caurina.transitions.SpecialPropertySplitter)
package caurina.transitions {
public class SpecialPropertySplitter {
public var parameters:Array;
public var splitValues:Function;
public function SpecialPropertySplitter(p_splitFunction:Function, p_parameters:Array){
super();
splitValues = p_splitFunction;
parameters = p_parameters;
}
public function toString():String{
var value:String = "";
value = (value + "[SpecialPropertySplitter ");
value = (value + ("splitValues:" + String(splitValues)));
value = (value + ", ");
value = (value + ("parameters:" + String(parameters)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 12
//Tweener (caurina.transitions.Tweener)
package caurina.transitions {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Tweener {
private static var _timeScale:Number = 1;
private static var _currentTimeFrame:Number;
private static var _specialPropertySplitterList:Object;
private static var _engineExists:Boolean = false;
private static var _specialPropertyModifierList:Object;
private static var _currentTime:Number;
private static var _tweenList:Array;
private static var _specialPropertyList:Object;
private static var _transitionList:Object;
private static var _inited:Boolean = false;
private static var __tweener_controller__:MovieClip;
public function Tweener(){
super();
trace("Tweener is a static class and should not be instantiated.");
}
public static function registerSpecialPropertyModifier(p_name:String, p_modifyFunction:Function, p_getFunction:Function):void{
if (!_inited){
init();
};
var spm:SpecialPropertyModifier = new SpecialPropertyModifier(p_modifyFunction, p_getFunction);
_specialPropertyModifierList[p_name] = spm;
}
public static function registerSpecialProperty(p_name:String, p_getFunction:Function, p_setFunction:Function, p_parameters:Array=null, p_preProcessFunction:Function=null):void{
if (!_inited){
init();
};
var sp:SpecialProperty = new SpecialProperty(p_getFunction, p_setFunction, p_parameters, p_preProcessFunction);
_specialPropertyList[p_name] = sp;
}
public static function init(... _args):void{
_inited = true;
_transitionList = new Object();
Equations.init();
_specialPropertyList = new Object();
_specialPropertyModifierList = new Object();
_specialPropertySplitterList = new Object();
}
private static function updateTweens():Boolean{
var i:int;
if (_tweenList.length == 0){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if ((((_tweenList[i] == undefined)) || (!(_tweenList[i].isPaused)))){
if (!updateTweenByIndex(i)){
removeTweenByIndex(i);
};
if (_tweenList[i] == null){
removeTweenByIndex(i, true);
i--;
};
};
i++;
};
return (true);
}
public static function addCaller(p_scopes:Object=null, p_parameters:Object=null):Boolean{
var i:Number;
var rScopes:Array;
var rTransition:Function;
var nTween:TweenListObj;
var myT:Number;
var trans:String;
if (!Boolean(p_scopes)){
return (false);
};
if ((p_scopes is Array)){
rScopes = p_scopes.concat();
} else {
rScopes = [p_scopes];
};
var p_obj:Object = p_parameters;
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var rTime:Number = (isNaN(p_obj.time)) ? 0 : p_obj.time;
var rDelay:Number = (isNaN(p_obj.delay)) ? 0 : p_obj.delay;
if (typeof(p_obj.transition) == "string"){
trans = p_obj.transition.toLowerCase();
rTransition = _transitionList[trans];
} else {
rTransition = p_obj.transition;
};
if (!Boolean(rTransition)){
rTransition = _transitionList["easeoutexpo"];
};
i = 0;
while (i < rScopes.length) {
if (p_obj.useFrames == true){
nTween = new TweenListObj(rScopes[i], (_currentTimeFrame + (rDelay / _timeScale)), (_currentTimeFrame + ((rDelay + rTime) / _timeScale)), true, rTransition, p_obj.transitionParams);
} else {
nTween = new TweenListObj(rScopes[i], (_currentTime + ((rDelay * 1000) / _timeScale)), (_currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale)), false, rTransition, p_obj.transitionParams);
};
nTween.properties = null;
nTween.onStart = p_obj.onStart;
nTween.onUpdate = p_obj.onUpdate;
nTween.onComplete = p_obj.onComplete;
nTween.onOverwrite = p_obj.onOverwrite;
nTween.onStartParams = p_obj.onStartParams;
nTween.onUpdateParams = p_obj.onUpdateParams;
nTween.onCompleteParams = p_obj.onCompleteParams;
nTween.onOverwriteParams = p_obj.onOverwriteParams;
nTween.onStartScope = p_obj.onStartScope;
nTween.onUpdateScope = p_obj.onUpdateScope;
nTween.onCompleteScope = p_obj.onCompleteScope;
nTween.onOverwriteScope = p_obj.onOverwriteScope;
nTween.onErrorScope = p_obj.onErrorScope;
nTween.isCaller = true;
nTween.count = p_obj.count;
nTween.waitFrames = p_obj.waitFrames;
_tweenList.push(nTween);
if ((((rTime == 0)) && ((rDelay == 0)))){
myT = (_tweenList.length - 1);
updateTweenByIndex(myT);
removeTweenByIndex(myT);
};
i++;
};
return (true);
}
public static function pauseAllTweens():Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
var paused:Boolean;
i = 0;
while (i < _tweenList.length) {
pauseTweenByIndex(i);
paused = true;
i++;
};
return (paused);
}
public static function removeTweens(p_scope:Object, ... _args):Boolean{
var i:uint;
var sps:SpecialPropertySplitter;
var specialProps:Array;
var j:uint;
var properties:Array = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && ((properties.indexOf(_args[i]) == -1)))){
if (_specialPropertySplitterList[_args[i]]){
sps = _specialPropertySplitterList[_args[i]];
specialProps = sps.splitValues(p_scope, null);
j = 0;
while (j < specialProps.length) {
properties.push(specialProps[j].name);
j++;
};
} else {
properties.push(_args[i]);
};
};
i++;
};
return (affectTweens(removeTweenByIndex, p_scope, properties));
}
public static function splitTweens(p_tween:Number, p_properties:Array):uint{
var i:uint;
var pName:String;
var found:Boolean;
var originalTween:TweenListObj = _tweenList[p_tween];
var newTween:TweenListObj = originalTween.clone(false);
i = 0;
while (i < p_properties.length) {
pName = p_properties[i];
if (Boolean(originalTween.properties[pName])){
originalTween.properties[pName] = undefined;
delete originalTween.properties[pName];
};
i++;
};
for (pName in newTween.properties) {
found = false;
i = 0;
while (i < p_properties.length) {
if (p_properties[i] == pName){
found = true;
break;
};
i++;
};
if (!found){
newTween.properties[pName] = undefined;
delete newTween.properties[pName];
};
};
_tweenList.push(newTween);
return ((_tweenList.length - 1));
}
public static function updateFrame():void{
_currentTimeFrame++;
}
public static function resumeTweenByIndex(p_tween:Number):Boolean{
var tTweening:TweenListObj = _tweenList[p_tween];
if ((((tTweening == null)) || (!(tTweening.isPaused)))){
return (false);
};
var cTime:Number = getCurrentTweeningTime(tTweening);
tTweening.timeStart = (tTweening.timeStart + (cTime - tTweening.timePaused));
tTweening.timeComplete = (tTweening.timeComplete + (cTime - tTweening.timePaused));
tTweening.timePaused = undefined;
tTweening.isPaused = false;
return (true);
}
public static function getVersion():String{
return ("AS3 1.31.74");
}
public static function onEnterFrame(e:Event):void{
updateTime();
updateFrame();
var hasUpdated:Boolean;
hasUpdated = updateTweens();
if (!hasUpdated){
stopEngine();
};
}
public static function updateTime():void{
_currentTime = getTimer();
}
private static function updateTweenByIndex(i:Number):Boolean{
var tTweening:TweenListObj;
var mustUpdate:Boolean;
var nv:Number;
var t:Number;
var b:Number;
var c:Number;
var d:Number;
var pName:String;
var eventScope:Object;
var tScope:Object;
var tProperty:Object;
var pv:Number;
var i = i;
tTweening = _tweenList[i];
if ((((tTweening == null)) || (!(Boolean(tTweening.scope))))){
return (false);
};
var isOver:Boolean;
var cTime:Number = getCurrentTweeningTime(tTweening);
if (cTime >= tTweening.timeStart){
tScope = tTweening.scope;
if (tTweening.isCaller){
do {
t = (((tTweening.timeComplete - tTweening.timeStart) / tTweening.count) * (tTweening.timesCalled + 1));
b = tTweening.timeStart;
c = (tTweening.timeComplete - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d);
//unresolved if
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
continue;
var _slot1 = e1;
handleError(tTweening, _slot1, "onUpdate");
};
} while (tTweening.timesCalled++, !(tTweening.timesCalled >= tTweening.count));
} else {
mustUpdate = (((((tTweening.skipUpdates < 1)) || (!(tTweening.skipUpdates)))) || ((tTweening.updatesSkipped >= tTweening.skipUpdates)));
if (cTime >= tTweening.timeComplete){
isOver = true;
mustUpdate = true;
};
if (!tTweening.hasStarted){
if (Boolean(tTweening.onStart)){
eventScope = (Boolean(tTweening.onStartScope)) ? tTweening.onStartScope : tScope;
tTweening.onStart.apply(eventScope, tTweening.onStartParams);
//unresolved jump
var _slot1 = e2;
handleError(tTweening, _slot1, "onStart");
};
for (pName in tTweening.properties) {
if (tTweening.properties[pName].isSpecialProperty){
if (Boolean(_specialPropertyList[pName].preProcess)){
tTweening.properties[pName].valueComplete = _specialPropertyList[pName].preProcess(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].originalValueComplete, tTweening.properties[pName].extra);
};
pv = _specialPropertyList[pName].getValue(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
pv = tScope[pName];
};
tTweening.properties[pName].valueStart = (isNaN(pv)) ? tTweening.properties[pName].valueComplete : pv;
};
mustUpdate = true;
tTweening.hasStarted = true;
};
if (mustUpdate){
for (pName in tTweening.properties) {
tProperty = tTweening.properties[pName];
if (isOver){
nv = tProperty.valueComplete;
} else {
if (tProperty.hasModifier){
t = (cTime - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, 0, 1, d, tTweening.transitionParams);
nv = tProperty.modifierFunction(tProperty.valueStart, tProperty.valueComplete, nv, tProperty.modifierParameters);
} else {
t = (cTime - tTweening.timeStart);
b = tProperty.valueStart;
c = (tProperty.valueComplete - tProperty.valueStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d, tTweening.transitionParams);
};
};
if (tTweening.rounded){
nv = Math.round(nv);
};
if (tProperty.isSpecialProperty){
_specialPropertyList[pName].setValue(tScope, nv, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
tScope[pName] = nv;
};
};
tTweening.updatesSkipped = 0;
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
//unresolved jump
var _slot1 = e3;
handleError(tTweening, _slot1, "onUpdate");
};
} else {
tTweening.updatesSkipped++;
};
};
if (((isOver) && (Boolean(tTweening.onComplete)))){
eventScope = (Boolean(tTweening.onCompleteScope)) ? tTweening.onCompleteScope : tScope;
tTweening.onComplete.apply(eventScope, tTweening.onCompleteParams);
//unresolved jump
var _slot1 = e4;
handleError(tTweening, _slot1, "onComplete");
};
return (!(isOver));
};
return (true);
}
public static function setTimeScale(p_time:Number):void{
var i:Number;
var cTime:Number;
if (isNaN(p_time)){
p_time = 1;
};
if (p_time < 1E-5){
p_time = 1E-5;
};
if (p_time != _timeScale){
if (_tweenList != null){
i = 0;
while (i < _tweenList.length) {
cTime = getCurrentTweeningTime(_tweenList[i]);
_tweenList[i].timeStart = (cTime - (((cTime - _tweenList[i].timeStart) * _timeScale) / p_time));
_tweenList[i].timeComplete = (cTime - (((cTime - _tweenList[i].timeComplete) * _timeScale) / p_time));
if (_tweenList[i].timePaused != undefined){
_tweenList[i].timePaused = (cTime - (((cTime - _tweenList[i].timePaused) * _timeScale) / p_time));
};
i++;
};
};
_timeScale = p_time;
};
}
public static function resumeAllTweens():Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
var resumed:Boolean;
i = 0;
while (i < _tweenList.length) {
resumeTweenByIndex(i);
resumed = true;
i++;
};
return (resumed);
}
private static function handleError(pTweening:TweenListObj, pError:Error, pCallBackName:String):void{
var eventScope:Object;
var pTweening = pTweening;
var pError = pError;
var pCallBackName = pCallBackName;
if (((Boolean(pTweening.onError)) && ((pTweening.onError is Function)))){
eventScope = (Boolean(pTweening.onErrorScope)) ? pTweening.onErrorScope : pTweening.scope;
pTweening.onError.apply(eventScope, [pTweening.scope, pError]);
//unresolved jump
var _slot1 = metaError;
printError(((((String(pTweening.scope) + " raised an error while executing the 'onError' handler. Original error:\n ") + pError.getStackTrace()) + "\nonError error: ") + _slot1.getStackTrace()));
} else {
if (!Boolean(pTweening.onError)){
printError(((((String(pTweening.scope) + " raised an error while executing the '") + pCallBackName) + "'handler. \n") + pError.getStackTrace()));
};
};
}
private static function startEngine():void{
_engineExists = true;
_tweenList = new Array();
__tweener_controller__ = new MovieClip();
__tweener_controller__.addEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
_currentTimeFrame = 0;
updateTime();
}
public static function removeAllTweens():Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
var removed:Boolean;
i = 0;
while (i < _tweenList.length) {
removeTweenByIndex(i);
removed = true;
i++;
};
return (removed);
}
public static function addTween(p_scopes:Object=null, p_parameters:Object=null):Boolean{
var i:Number;
var j:Number;
var istr:String;
var rScopes:Array;
var rTransition:Function;
var nProperties:Object;
var nTween:TweenListObj;
var myT:Number;
var splitProperties:Array;
var splitProperties2:Array;
var tempModifiedProperties:Array;
var trans:String;
if (!Boolean(p_scopes)){
return (false);
};
if ((p_scopes is Array)){
rScopes = p_scopes.concat();
} else {
rScopes = [p_scopes];
};
var p_obj:Object = TweenListObj.makePropertiesChain(p_parameters);
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var rTime:Number = (isNaN(p_obj.time)) ? 0 : p_obj.time;
var rDelay:Number = (isNaN(p_obj.delay)) ? 0 : p_obj.delay;
var rProperties:Array = new Array();
var restrictedWords:Object = {time:true, delay:true, useFrames:true, skipUpdates:true, transition:true, transitionParams:true, onStart:true, onUpdate:true, onComplete:true, onOverwrite:true, onError:true, rounded:true, onStartParams:true, onUpdateParams:true, onCompleteParams:true, onOverwriteParams:true, onStartScope:true, onUpdateScope:true, onCompleteScope:true, onOverwriteScope:true, onErrorScope:true};
var modifiedProperties:Object = new Object();
for (istr in p_obj) {
if (!restrictedWords[istr]){
if (_specialPropertySplitterList[istr]){
splitProperties = _specialPropertySplitterList[istr].splitValues(p_obj[istr], _specialPropertySplitterList[istr].parameters);
i = 0;
while (i < splitProperties.length) {
if (_specialPropertySplitterList[splitProperties[i].name]){
splitProperties2 = _specialPropertySplitterList[splitProperties[i].name].splitValues(splitProperties[i].value, _specialPropertySplitterList[splitProperties[i].name].parameters);
j = 0;
while (j < splitProperties2.length) {
rProperties[splitProperties2[j].name] = {valueStart:undefined, valueComplete:splitProperties2[j].value, arrayIndex:splitProperties2[j].arrayIndex, isSpecialProperty:false};
j++;
};
} else {
rProperties[splitProperties[i].name] = {valueStart:undefined, valueComplete:splitProperties[i].value, arrayIndex:splitProperties[i].arrayIndex, isSpecialProperty:false};
};
i++;
};
} else {
if (_specialPropertyModifierList[istr] != undefined){
tempModifiedProperties = _specialPropertyModifierList[istr].modifyValues(p_obj[istr]);
i = 0;
while (i < tempModifiedProperties.length) {
modifiedProperties[tempModifiedProperties[i].name] = {modifierParameters:tempModifiedProperties[i].parameters, modifierFunction:_specialPropertyModifierList[istr].getValue};
i++;
};
} else {
rProperties[istr] = {valueStart:undefined, valueComplete:p_obj[istr]};
};
};
};
};
for (istr in rProperties) {
if (_specialPropertyList[istr] != undefined){
rProperties[istr].isSpecialProperty = true;
} else {
if (rScopes[0][istr] == undefined){
printError((((("The property '" + istr) + "' doesn't seem to be a normal object property of ") + String(rScopes[0])) + " or a registered special property."));
};
};
};
for (istr in modifiedProperties) {
if (rProperties[istr] != undefined){
rProperties[istr].modifierParameters = modifiedProperties[istr].modifierParameters;
rProperties[istr].modifierFunction = modifiedProperties[istr].modifierFunction;
};
};
if (typeof(p_obj.transition) == "string"){
trans = p_obj.transition.toLowerCase();
rTransition = _transitionList[trans];
} else {
rTransition = p_obj.transition;
};
if (!Boolean(rTransition)){
rTransition = _transitionList["easeoutexpo"];
};
i = 0;
while (i < rScopes.length) {
nProperties = new Object();
for (istr in rProperties) {
nProperties[istr] = new PropertyInfoObj(rProperties[istr].valueStart, rProperties[istr].valueComplete, rProperties[istr].valueComplete, rProperties[istr].arrayIndex, {}, rProperties[istr].isSpecialProperty, rProperties[istr].modifierFunction, rProperties[istr].modifierParameters);
};
if (p_obj.useFrames == true){
nTween = new TweenListObj(rScopes[i], (_currentTimeFrame + (rDelay / _timeScale)), (_currentTimeFrame + ((rDelay + rTime) / _timeScale)), true, rTransition, p_obj.transitionParams);
} else {
nTween = new TweenListObj(rScopes[i], (_currentTime + ((rDelay * 1000) / _timeScale)), (_currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale)), false, rTransition, p_obj.transitionParams);
};
nTween.properties = nProperties;
nTween.onStart = p_obj.onStart;
nTween.onUpdate = p_obj.onUpdate;
nTween.onComplete = p_obj.onComplete;
nTween.onOverwrite = p_obj.onOverwrite;
nTween.onError = p_obj.onError;
nTween.onStartParams = p_obj.onStartParams;
nTween.onUpdateParams = p_obj.onUpdateParams;
nTween.onCompleteParams = p_obj.onCompleteParams;
nTween.onOverwriteParams = p_obj.onOverwriteParams;
nTween.onStartScope = p_obj.onStartScope;
nTween.onUpdateScope = p_obj.onUpdateScope;
nTween.onCompleteScope = p_obj.onCompleteScope;
nTween.onOverwriteScope = p_obj.onOverwriteScope;
nTween.onErrorScope = p_obj.onErrorScope;
nTween.rounded = p_obj.rounded;
nTween.skipUpdates = p_obj.skipUpdates;
removeTweensByTime(nTween.scope, nTween.properties, nTween.timeStart, nTween.timeComplete);
_tweenList.push(nTween);
if ((((rTime == 0)) && ((rDelay == 0)))){
myT = (_tweenList.length - 1);
updateTweenByIndex(myT);
removeTweenByIndex(myT);
};
i++;
};
return (true);
}
public static function registerTransition(p_name:String, p_function:Function):void{
if (!_inited){
init();
};
_transitionList[p_name] = p_function;
}
public static function printError(p_message:String):void{
trace(("## [Tweener] Error: " + p_message));
}
private static function affectTweens(p_affectFunction:Function, p_scope:Object, p_properties:Array):Boolean{
var i:uint;
var affectedProperties:Array;
var j:uint;
var objectProperties:uint;
var slicedTweenIndex:uint;
var affected:Boolean;
if (!Boolean(_tweenList)){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if (((_tweenList[i]) && ((_tweenList[i].scope == p_scope)))){
if (p_properties.length == 0){
p_affectFunction(i);
affected = true;
} else {
affectedProperties = new Array();
j = 0;
while (j < p_properties.length) {
if (Boolean(_tweenList[i].properties[p_properties[j]])){
affectedProperties.push(p_properties[j]);
};
j++;
};
if (affectedProperties.length > 0){
objectProperties = AuxFunctions.getObjectLength(_tweenList[i].properties);
if (objectProperties == affectedProperties.length){
p_affectFunction(i);
affected = true;
} else {
slicedTweenIndex = splitTweens(i, affectedProperties);
p_affectFunction(slicedTweenIndex);
affected = true;
};
};
};
};
i++;
};
return (affected);
}
public static function getTweens(p_scope:Object):Array{
var i:uint;
var pName:String;
if (!Boolean(_tweenList)){
return ([]);
};
var tList:Array = new Array();
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
for (pName in _tweenList[i].properties) {
tList.push(pName);
};
};
i++;
};
return (tList);
}
public static function isTweening(p_scope:Object):Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
return (true);
};
i++;
};
return (false);
}
public static function pauseTweenByIndex(p_tween:Number):Boolean{
var tTweening:TweenListObj = _tweenList[p_tween];
if ((((tTweening == null)) || (tTweening.isPaused))){
return (false);
};
tTweening.timePaused = getCurrentTweeningTime(tTweening);
tTweening.isPaused = true;
return (true);
}
public static function getCurrentTweeningTime(p_tweening:Object):Number{
return ((p_tweening.useFrames) ? _currentTimeFrame : _currentTime);
}
public static function getTweenCount(p_scope:Object):Number{
var i:uint;
if (!Boolean(_tweenList)){
return (0);
};
var c:Number = 0;
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
c = (c + AuxFunctions.getObjectLength(_tweenList[i].properties));
};
i++;
};
return (c);
}
private static function stopEngine():void{
_engineExists = false;
_tweenList = null;
_currentTime = 0;
_currentTimeFrame = 0;
__tweener_controller__.removeEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
__tweener_controller__ = null;
}
public static function removeTweensByTime(p_scope:Object, p_properties:Object, p_timeStart:Number, p_timeComplete:Number):Boolean{
var removedLocally:Boolean;
var i:uint;
var pName:String;
var eventScope:Object;
var p_scope = p_scope;
var p_properties = p_properties;
var p_timeStart = p_timeStart;
var p_timeComplete = p_timeComplete;
var removed:Boolean;
var tl:uint = _tweenList.length;
i = 0;
while (i < tl) {
if (((Boolean(_tweenList[i])) && ((p_scope == _tweenList[i].scope)))){
if ((((p_timeComplete > _tweenList[i].timeStart)) && ((p_timeStart < _tweenList[i].timeComplete)))){
removedLocally = false;
for (pName in _tweenList[i].properties) {
if (Boolean(p_properties[pName])){
if (Boolean(_tweenList[i].onOverwrite)){
eventScope = (Boolean(_tweenList[i].onOverwriteScope)) ? _tweenList[i].onOverwriteScope : _tweenList[i].scope;
_tweenList[i].onOverwrite.apply(eventScope, _tweenList[i].onOverwriteParams);
//unresolved jump
var _slot1 = e;
handleError(_tweenList[i], _slot1, "onOverwrite");
};
_tweenList[i].properties[pName] = undefined;
delete _tweenList[i].properties[pName];
removedLocally = true;
removed = true;
};
};
if (removedLocally){
if (AuxFunctions.getObjectLength(_tweenList[i].properties) == 0){
removeTweenByIndex(i);
};
};
};
};
i = (i + 1);
};
return (removed);
}
public static function registerSpecialPropertySplitter(p_name:String, p_splitFunction:Function, p_parameters:Array=null):void{
if (!_inited){
init();
};
var sps:SpecialPropertySplitter = new SpecialPropertySplitter(p_splitFunction, p_parameters);
_specialPropertySplitterList[p_name] = sps;
}
public static function removeTweenByIndex(i:Number, p_finalRemoval:Boolean=false):Boolean{
_tweenList[i] = null;
if (p_finalRemoval){
_tweenList.splice(i, 1);
};
return (true);
}
public static function resumeTweens(p_scope:Object, ... _args):Boolean{
var i:uint;
var properties:Array = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && ((properties.indexOf(_args[i]) == -1)))){
properties.push(_args[i]);
};
i++;
};
return (affectTweens(resumeTweenByIndex, p_scope, properties));
}
public static function pauseTweens(p_scope:Object, ... _args):Boolean{
var i:uint;
var properties:Array = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && ((properties.indexOf(_args[i]) == -1)))){
properties.push(_args[i]);
};
i++;
};
return (affectTweens(pauseTweenByIndex, p_scope, properties));
}
}
}//package caurina.transitions
Section 13
//TweenListObj (caurina.transitions.TweenListObj)
package caurina.transitions {
public class TweenListObj {
public var hasStarted:Boolean;
public var onUpdate:Function;
public var useFrames:Boolean;
public var count:Number;
public var onOverwriteParams:Array;
public var timeStart:Number;
public var timeComplete:Number;
public var onStartParams:Array;
public var onUpdateScope:Object;
public var rounded:Boolean;
public var onUpdateParams:Array;
public var properties:Object;
public var onComplete:Function;
public var transitionParams:Object;
public var updatesSkipped:Number;
public var onStart:Function;
public var onOverwriteScope:Object;
public var skipUpdates:Number;
public var onStartScope:Object;
public var scope:Object;
public var isCaller:Boolean;
public var timePaused:Number;
public var transition:Function;
public var onCompleteParams:Array;
public var onError:Function;
public var timesCalled:Number;
public var onErrorScope:Object;
public var onOverwrite:Function;
public var isPaused:Boolean;
public var waitFrames:Boolean;
public var onCompleteScope:Object;
public function TweenListObj(p_scope:Object, p_timeStart:Number, p_timeComplete:Number, p_useFrames:Boolean, p_transition:Function, p_transitionParams:Object){
super();
scope = p_scope;
timeStart = p_timeStart;
timeComplete = p_timeComplete;
useFrames = p_useFrames;
transition = p_transition;
transitionParams = p_transitionParams;
properties = new Object();
isPaused = false;
timePaused = undefined;
isCaller = false;
updatesSkipped = 0;
timesCalled = 0;
skipUpdates = 0;
hasStarted = false;
}
public function clone(omitEvents:Boolean):TweenListObj{
var pName:String;
var nTween:TweenListObj = new TweenListObj(scope, timeStart, timeComplete, useFrames, transition, transitionParams);
nTween.properties = new Array();
for (pName in properties) {
nTween.properties[pName] = properties[pName].clone();
};
nTween.skipUpdates = skipUpdates;
nTween.updatesSkipped = updatesSkipped;
if (!omitEvents){
nTween.onStart = onStart;
nTween.onUpdate = onUpdate;
nTween.onComplete = onComplete;
nTween.onOverwrite = onOverwrite;
nTween.onError = onError;
nTween.onStartParams = onStartParams;
nTween.onUpdateParams = onUpdateParams;
nTween.onCompleteParams = onCompleteParams;
nTween.onOverwriteParams = onOverwriteParams;
nTween.onStartScope = onStartScope;
nTween.onUpdateScope = onUpdateScope;
nTween.onCompleteScope = onCompleteScope;
nTween.onOverwriteScope = onOverwriteScope;
nTween.onErrorScope = onErrorScope;
};
nTween.rounded = rounded;
nTween.isPaused = isPaused;
nTween.timePaused = timePaused;
nTween.isCaller = isCaller;
nTween.count = count;
nTween.timesCalled = timesCalled;
nTween.waitFrames = waitFrames;
nTween.hasStarted = hasStarted;
return (nTween);
}
public function toString():String{
var i:String;
var returnStr:String = "\n[TweenListObj ";
returnStr = (returnStr + ("scope:" + String(scope)));
returnStr = (returnStr + ", properties:");
var isFirst:Boolean;
for (i in properties) {
if (!isFirst){
returnStr = (returnStr + ",");
};
returnStr = (returnStr + ("[name:" + properties[i].name));
returnStr = (returnStr + (",valueStart:" + properties[i].valueStart));
returnStr = (returnStr + (",valueComplete:" + properties[i].valueComplete));
returnStr = (returnStr + "]");
isFirst = false;
};
returnStr = (returnStr + (", timeStart:" + String(timeStart)));
returnStr = (returnStr + (", timeComplete:" + String(timeComplete)));
returnStr = (returnStr + (", useFrames:" + String(useFrames)));
returnStr = (returnStr + (", transition:" + String(transition)));
returnStr = (returnStr + (", transitionParams:" + String(transitionParams)));
if (skipUpdates){
returnStr = (returnStr + (", skipUpdates:" + String(skipUpdates)));
};
if (updatesSkipped){
returnStr = (returnStr + (", updatesSkipped:" + String(updatesSkipped)));
};
if (Boolean(onStart)){
returnStr = (returnStr + (", onStart:" + String(onStart)));
};
if (Boolean(onUpdate)){
returnStr = (returnStr + (", onUpdate:" + String(onUpdate)));
};
if (Boolean(onComplete)){
returnStr = (returnStr + (", onComplete:" + String(onComplete)));
};
if (Boolean(onOverwrite)){
returnStr = (returnStr + (", onOverwrite:" + String(onOverwrite)));
};
if (Boolean(onError)){
returnStr = (returnStr + (", onError:" + String(onError)));
};
if (onStartParams){
returnStr = (returnStr + (", onStartParams:" + String(onStartParams)));
};
if (onUpdateParams){
returnStr = (returnStr + (", onUpdateParams:" + String(onUpdateParams)));
};
if (onCompleteParams){
returnStr = (returnStr + (", onCompleteParams:" + String(onCompleteParams)));
};
if (onOverwriteParams){
returnStr = (returnStr + (", onOverwriteParams:" + String(onOverwriteParams)));
};
if (onStartScope){
returnStr = (returnStr + (", onStartScope:" + String(onStartScope)));
};
if (onUpdateScope){
returnStr = (returnStr + (", onUpdateScope:" + String(onUpdateScope)));
};
if (onCompleteScope){
returnStr = (returnStr + (", onCompleteScope:" + String(onCompleteScope)));
};
if (onOverwriteScope){
returnStr = (returnStr + (", onOverwriteScope:" + String(onOverwriteScope)));
};
if (onErrorScope){
returnStr = (returnStr + (", onErrorScope:" + String(onErrorScope)));
};
if (rounded){
returnStr = (returnStr + (", rounded:" + String(rounded)));
};
if (isPaused){
returnStr = (returnStr + (", isPaused:" + String(isPaused)));
};
if (timePaused){
returnStr = (returnStr + (", timePaused:" + String(timePaused)));
};
if (isCaller){
returnStr = (returnStr + (", isCaller:" + String(isCaller)));
};
if (count){
returnStr = (returnStr + (", count:" + String(count)));
};
if (timesCalled){
returnStr = (returnStr + (", timesCalled:" + String(timesCalled)));
};
if (waitFrames){
returnStr = (returnStr + (", waitFrames:" + String(waitFrames)));
};
if (hasStarted){
returnStr = (returnStr + (", hasStarted:" + String(hasStarted)));
};
returnStr = (returnStr + "]\n");
return (returnStr);
}
public static function makePropertiesChain(p_obj:Object):Object{
var chainedObject:Object;
var chain:Object;
var currChainObj:Object;
var len:Number;
var i:Number;
var k:Number;
var baseObject:Object = p_obj.base;
if (baseObject){
chainedObject = {};
if ((baseObject is Array)){
chain = [];
k = 0;
while (k < baseObject.length) {
chain.push(baseObject[k]);
k++;
};
} else {
chain = [baseObject];
};
chain.push(p_obj);
len = chain.length;
i = 0;
while (i < len) {
if (chain[i]["base"]){
currChainObj = AuxFunctions.concatObjects(makePropertiesChain(chain[i]["base"]), chain[i]);
} else {
currChainObj = chain[i];
};
chainedObject = AuxFunctions.concatObjects(chainedObject, currChainObj);
i++;
};
if (chainedObject["base"]){
delete chainedObject["base"];
};
return (chainedObject);
//unresolved jump
};
return (p_obj);
}
}
}//package caurina.transitions
Section 14
//CDK (Collision.CDK)
package Collision {
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.text.*;
public class CDK {
private var colorTransform1:ColorTransform;
private var colorTransform2:ColorTransform;
private var _returnAngleType:String;
private var pixels1:ByteArray;
private var pixels2:ByteArray;
private var bmdResample:BitmapData;
private var _root;
private var _returnAngle:Boolean;
private var transMatrix2:Matrix;
private var rect1:Rectangle;
private var rect2:Rectangle;
private var transMatrix1:Matrix;
protected var objectCheckArray:Array;
private var _alphaThreshold:Number;
private var item1Registration:Point;
private var bmd1:BitmapData;
private var bmd2:BitmapData;
protected var objectArray:Array;
private var item2Registration:Point;
protected var objectCollisionArray:Array;
private var _numChildren:uint;
private var colorExclusionArray:Array;
public function CDK():void{
super();
if (getQualifiedClassName(this) == "coreyoneil.collision::CDK"){
throw (new Error("CDK is an abstract class and is not meant for instantiation - use CollisionGroup or CollisionList"));
};
init();
}
public function get returnAngle():Boolean{
return (_returnAngle);
}
public function set returnAngle(option):void{
if (typeof(option) == "boolean"){
_returnAngle = option;
} else {
throw (new Error("returnAngle expects a Boolean value (true/false)"));
};
}
private function init():void{
objectCheckArray = new Array();
objectCollisionArray = new Array();
objectArray = new Array();
colorExclusionArray = new Array();
_alphaThreshold = 0;
_returnAngle = false;
_returnAngleType = "RADIANS";
}
protected function findCollisions(item1, item2):void{
var tf:TextFormat;
var alpha1:uint;
var alpha2:uint;
var colorFlag:Boolean;
var red1:uint;
var red2:uint;
var green1:uint;
var green2:uint;
var blue1:uint;
var blue2:uint;
var a:uint;
var r:uint;
var g:uint;
var b:uint;
var item1Flags:uint;
var item2Flags:uint;
var n:uint;
var angle:Number;
var recordedCollision:Object;
var item1 = item1;
var item2 = item2;
var item1_isText:Boolean;
var item2_isText:Boolean;
tf = item1.getTextFormat();
item1_isText = ((item1.antiAliasType)=="advanced") ? true : false;
item1.antiAliasType = ((item1.antiAliasType)=="advanced") ? "normal" : item1.antiAliasType;
//unresolved jump
var _slot1 = e;
tf = item2.getTextFormat();
item2_isText = ((item1.antiAliasType)=="advanced") ? true : false;
item2.antiAliasType = ((item2.antiAliasType)=="advanced") ? "normal" : item2.antiAliasType;
//unresolved jump
var _slot1 = e;
colorTransform1 = item1.transform.colorTransform;
colorTransform2 = item2.transform.colorTransform;
item1Registration = new Point(item1.x, item1.y);
item2Registration = new Point(item2.x, item2.y);
item1Registration = item1.parent.localToGlobal(item1Registration);
item2Registration = item2.parent.localToGlobal(item2Registration);
if ((item2.width * item2.height) > (item1.width * item1.height)){
bmd1 = new BitmapData(item1.width, item1.height, true, 0xFFFFFF);
bmd2 = new BitmapData(item1.width, item1.height, true, 0xFFFFFF);
rect1 = item1.getBounds(_root.stage);
transMatrix1 = item1.transform.matrix;
transMatrix1.tx = (item1Registration.x - rect1.left);
transMatrix1.ty = (item1Registration.y - rect1.top);
transMatrix2 = item2.transform.matrix;
transMatrix2.tx = (item2Registration.x - rect1.left);
transMatrix2.ty = (item2Registration.y - rect1.top);
} else {
bmd1 = new BitmapData(item2.width, item2.height, true, 0xFFFFFF);
bmd2 = new BitmapData(item2.width, item2.height, true, 0xFFFFFF);
rect2 = item2.getBounds(_root.stage);
transMatrix1 = item1.transform.matrix;
transMatrix1.tx = (item1Registration.x - rect2.left);
transMatrix1.ty = (item1Registration.y - rect2.top);
transMatrix2 = item2.transform.matrix;
transMatrix2.tx = (item2Registration.x - rect2.left);
transMatrix2.ty = (item2Registration.y - rect2.top);
};
bmd1.draw(item1, transMatrix1, colorTransform1, null, null, true);
bmd2.draw(item2, transMatrix2, colorTransform2, null, null, true);
pixels1 = bmd1.getPixels(new Rectangle(0, 0, bmd1.width, bmd1.height));
pixels2 = bmd2.getPixels(new Rectangle(0, 0, bmd1.width, bmd1.height));
var k:uint;
var value1:uint;
var value2:uint;
var collisionPoint:Number = -1;
var overlap:uint;
pixels1.position = 0;
pixels2.position = 0;
for (;k < pixels1.length;(alpha1 = ((value1 >> 24) & 0xFF)), (alpha2 = ((value2 >> 24) & 0xFF)), if ((((alpha1 > _alphaThreshold)) && ((alpha2 > _alphaThreshold)))){
colorFlag = false;
if (colorExclusionArray.length){
red1 = ((value1 >> 16) & 0xFF);
red2 = ((value2 >> 16) & 0xFF);
green1 = ((value1 >> 8) & 0xFF);
green2 = ((value2 >> 8) & 0xFF);
blue1 = (value1 & 0xFF);
blue2 = (value2 & 0xFF);
n = 0;
while (n < colorExclusionArray.length) {
a = ((colorExclusionArray[n].color >> 24) & 0xFF);
r = ((colorExclusionArray[n].color >> 16) & 0xFF);
g = ((colorExclusionArray[n].color >> 8) & 0xFF);
b = (colorExclusionArray[n].color & 0xFF);
item1Flags = 0;
item2Flags = 0;
if ((((blue1 >= (b - colorExclusionArray[n].blue))) && ((blue1 <= (b + colorExclusionArray[n].blue))))){
item1Flags = (item1Flags + 1);
};
if ((((blue2 >= (b - colorExclusionArray[n].blue))) && ((blue2 <= (b + colorExclusionArray[n].blue))))){
item2Flags = (item2Flags + 1);
};
if ((((green1 >= (g - colorExclusionArray[n].green))) && ((green1 <= (g + colorExclusionArray[n].green))))){
item1Flags = (item1Flags + 1);
};
if ((((green2 >= (g - colorExclusionArray[n].green))) && ((green2 <= (g + colorExclusionArray[n].green))))){
item2Flags = (item2Flags + 1);
};
if ((((red1 >= (r - colorExclusionArray[n].red))) && ((red1 <= (r + colorExclusionArray[n].red))))){
item1Flags = (item1Flags + 1);
};
if ((((red2 >= (r - colorExclusionArray[n].red))) && ((red2 <= (r + colorExclusionArray[n].red))))){
item2Flags = (item2Flags + 1);
};
if ((((alpha1 >= (a - colorExclusionArray[n].alpha))) && ((alpha1 <= (a + colorExclusionArray[n].alpha))))){
item1Flags = (item1Flags + 1);
};
if ((((alpha2 >= (a - colorExclusionArray[n].alpha))) && ((alpha2 <= (a + colorExclusionArray[n].alpha))))){
item2Flags = (item2Flags + 1);
};
if ((((item1Flags == 4)) || ((item2Flags == 4)))){
colorFlag = true;
};
n = (n + 1);
};
};
if ((((collisionPoint == -1)) && (!(colorFlag)))){
if (_returnAngle){
collisionPoint = (k / 4);
angle = findAngle(item1, item2, collisionPoint);
} else {
angle = -1;
collisionPoint = 0;
};
};
overlap = (colorFlag) ? overlap : (overlap + 1);
}) {
k = pixels1.position;
value1 = pixels1.readUnsignedInt();
value2 = pixels2.readUnsignedInt();
continue;
var _slot1 = e;
break;
};
if (overlap){
if ((item2.width * item2.height) < (item1.width * item1.height)){
recordedCollision = {object1:item2, object2:item1, angle:angle, overlap:overlap};
objectCollisionArray.push(recordedCollision);
} else {
recordedCollision = {object1:item1, object2:item2, angle:angle, overlap:overlap};
objectCollisionArray.push(recordedCollision);
};
};
if (item1_isText){
item1.antiAliasType = "advanced";
};
if (item2_isText){
item2.antiAliasType = "advanced";
};
var _local4:Boolean;
item2_isText = _local4;
item1_isText = _local4;
}
private function returnRadians(degs:Number):Number{
var rads:Number = ((degs * Math.PI) / 180);
return (rads);
}
public function excludeColor(theColor:uint, alphaRange:uint=0xFF, redRange:uint=20, greenRange:uint=20, blueRange:uint=20):void{
var colorExclusion:Object = {color:theColor, alpha:alphaRange, red:redRange, green:greenRange, blue:blueRange};
colorExclusionArray.push(colorExclusion);
}
public function get numChildren():uint{
return (objectArray.length);
}
public function get alphaThreshold():Number{
return (_alphaThreshold);
}
public function removeItem(obj):void{
var found:Boolean;
var numObjs:int = objectArray.length;
var i:uint;
while (i < numObjs) {
if (objectArray[i] == obj){
objectArray.splice(i, 1);
found = true;
break;
};
i++;
};
if (!found){
throw (new Error((obj + " could not be removed - object not found in item list.")));
};
}
public function set returnAngleType(returnType:String):void{
returnType = returnType.toUpperCase();
switch (returnType){
case "DEGREES":
case "DEGREE":
case "DEG":
case "DEGS":
_returnAngleType = "DEGREES";
break;
case "RADIANS":
case "RADIAN":
case "RAD":
case "RADS":
_returnAngleType = "RADIANS";
break;
default:
throw (new Error("returnAngleType expects 'DEGREES' or 'RADIANS'"));
};
}
private function findAngle(item1, item2, collisionPoint):Number{
var pixel:uint;
var thisAlpha:uint;
var lastAlpha:int;
var edgePoint:uint;
var edgeY:uint;
var edgeX:uint;
var slope:Point;
var rowWidth:uint;
var columnHeight:uint;
var center:Point;
var pixels:ByteArray;
var k:uint;
var colorFlag:Boolean;
var red1:uint;
var green1:uint;
var blue1:uint;
var a:uint;
var r:uint;
var g:uint;
var b:uint;
var item1Flags:uint;
var numColors:uint;
var n:uint;
var item1 = item1;
var item2 = item2;
var collisionPoint = collisionPoint;
if ((item2.width * item2.height) > (item1.width * item1.height)){
rowWidth = Math.round(item1.width);
columnHeight = Math.round(item1.height);
center = new Point((item1.width >> 1), (item1.height >> 1));
pixels = pixels2;
} else {
rowWidth = Math.round(item2.width);
columnHeight = Math.round(item2.height);
center = new Point((item2.width >> 1), (item2.height >> 1));
pixels = pixels1;
};
var collisionY:* = (collisionPoint / rowWidth);
var collisionX:* = (collisionPoint % rowWidth);
collisionX = ((collisionX)!=0) ? ((collisionX >> 5) * rowWidth) : 0;
if ((((collisionX == 0)) && ((collisionY == 0)))){
var _local5 = 1;
collisionY = _local5;
collisionX = _local5;
};
if ((item2.width * item2.height) > (item1.width * item1.height)){
transMatrix2.tx = (transMatrix2.tx + center.x);
transMatrix2.ty = (transMatrix2.ty + center.y);
bmdResample = new BitmapData((item1.width * 2), (item1.height * 2), true, 0xFFFFFF);
bmdResample.draw(item2, transMatrix2, colorTransform2, null, null, true);
pixels = bmdResample.getPixels(new Rectangle(0, 0, bmdResample.width, bmdResample.height));
} else {
transMatrix1.tx = (transMatrix1.tx + center.x);
transMatrix1.ty = (transMatrix1.ty + center.y);
bmdResample = new BitmapData((item2.width * 2), (item2.height * 2), true, 0xFFFFFF);
bmdResample.draw(item1, transMatrix1, colorTransform1, null, null, true);
pixels = bmdResample.getPixels(new Rectangle(0, 0, bmdResample.width, bmdResample.height));
};
center.x = (bmdResample.width >> 1);
center.y = (bmdResample.height >> 1);
columnHeight = Math.round(bmdResample.height);
rowWidth = Math.round(bmdResample.width);
var edgeArray:Array = new Array();
var j:uint;
while (j < columnHeight) {
k = ((j * 4) * rowWidth);
pixels.position = k;
lastAlpha = -1;
for (;k < (((j + 1) * rowWidth) * 4);(thisAlpha = ((pixel >> 24) & 0xFF)), if (lastAlpha == -1){
lastAlpha = thisAlpha;
} else {
if (thisAlpha > _alphaThreshold){
colorFlag = false;
if (colorExclusionArray.length){
red1 = ((pixel >> 16) & 0xFF);
green1 = ((pixel >> 8) & 0xFF);
blue1 = (pixel & 0xFF);
numColors = colorExclusionArray.length;
n = 0;
while (n < numColors) {
a = ((colorExclusionArray[n].color >> 24) & 0xFF);
r = ((colorExclusionArray[n].color >> 16) & 0xFF);
g = ((colorExclusionArray[n].color >> 8) & 0xFF);
b = (colorExclusionArray[n].color & 0xFF);
item1Flags = 0;
if ((((blue1 >= (b - colorExclusionArray[n].blue))) && ((blue1 <= (b + colorExclusionArray[n].blue))))){
item1Flags = (item1Flags + 1);
};
if ((((green1 >= (g - colorExclusionArray[n].green))) && ((green1 <= (g + colorExclusionArray[n].green))))){
item1Flags = (item1Flags + 1);
};
if ((((red1 >= (r - colorExclusionArray[n].red))) && ((red1 <= (r + colorExclusionArray[n].red))))){
item1Flags = (item1Flags + 1);
};
if ((((thisAlpha >= (a - colorExclusionArray[n].alpha))) && ((thisAlpha <= (a + colorExclusionArray[n].alpha))))){
item1Flags = (item1Flags + 1);
};
if (item1Flags == 4){
colorFlag = true;
};
n = (n + 1);
};
};
if (!colorFlag){
edgeArray.push((k / 4));
};
};
}) {
k = pixels.position;
pixel = pixels.readUnsignedInt();
continue;
var _slot1 = e;
break;
};
j = (j + 1);
};
var angleArray:Array = new Array();
var numYAdjusted:uint;
var numXAdjusted:uint;
var slopeArray:Array = new Array();
var numEdges:int = edgeArray.length;
j = 0;
while (j < numEdges) {
edgePoint = edgeArray[j];
edgeY = (edgePoint / rowWidth);
edgeX = (edgePoint % rowWidth);
edgeX = ((edgeX)!=0) ? ((edgeX / bmdResample.width) * rowWidth) : 0;
slope = new Point((edgeX - center.x), (center.y - edgeY));
slopeArray.push(slope);
j = (j + 1);
};
var slopeYAvg:Number = 0;
var slopeXAvg:Number = 0;
var numSlopes:int = slopeArray.length;
j = 0;
while (j < numSlopes) {
slopeYAvg = (slopeYAvg + slopeArray[j].y);
slopeXAvg = (slopeXAvg + slopeArray[j].x);
j = (j + 1);
};
var average:Number = returnDegrees(Math.atan2(slopeYAvg, slopeXAvg));
average = (~(average) + 1);
average = ((_returnAngleType == "RADIANS")) ? returnRadians(average) : average;
return (average);
}
public function addItem(obj):void{
if ((obj is DisplayObject)){
_root = obj.root;
if (_root == null){
throw (new Error((("Cannot add item: " + obj) + " - Items added for collision detection must be on the display list.")));
};
objectArray.push(obj);
} else {
throw (new Error((("Cannot add item: " + obj) + " - item must be a Display Object.")));
};
}
public function get returnAngleType():String{
return (_returnAngleType);
}
private function returnDegrees(rads:Number):Number{
var degs:Number = ((rads * 180) / Math.PI);
return (degs);
}
public function set alphaThreshold(theAlpha:Number):void{
if ((((theAlpha <= 1)) && ((theAlpha >= 0)))){
_alphaThreshold = (theAlpha * 0xFF);
} else {
throw (new Error("alphaThreshold expects a value from 0 to 1"));
};
}
public function removeExcludeColor(theColor:uint):void{
var found:Boolean;
var numColors:int = colorExclusionArray.length;
var i:uint;
while (i < numColors) {
if (colorExclusionArray[i].color == theColor){
colorExclusionArray.splice(i, 1);
found = true;
break;
};
i++;
};
if (!found){
throw (new Error((("Color could not be removed - color not found in exclusion list [" + theColor) + "]")));
};
}
protected function clearArrays():void{
while (objectCheckArray.length) {
objectCheckArray.pop();
};
while (objectCollisionArray.length) {
objectCollisionArray.pop();
};
}
}
}//package Collision
Section 15
//CollisionList (Collision.CollisionList)
package Collision {
import flash.display.*;
public class CollisionList extends CDK {
public function CollisionList(target, ... _args):void{
super();
addItem(target);
var i:uint;
while (i < _args.length) {
addItem(_args[i]);
i++;
};
}
public function checkCollisions():Array{
var item2:*;
clearArrays();
var NUM_OBJS:uint = objectArray.length;
var item1:* = objectArray[0];
var i:uint = 1;
while (i < NUM_OBJS) {
item2 = objectArray[i];
if (item1.hitTestObject(item2)){
objectCheckArray.push([item1, item2]);
};
i++;
};
if (objectCheckArray.length){
NUM_OBJS = objectCheckArray.length;
i = 0;
while (i < NUM_OBJS) {
findCollisions(objectCheckArray[i][0], objectCheckArray[i][1]);
i++;
};
};
return (objectCollisionArray);
}
public function swapTarget(target):void{
var _root:*;
if ((target is DisplayObject)){
_root = target.root;
if (_root == null){
throw (new Error("Items added for collision detection must be on the display list."));
};
objectArray[0] = target;
} else {
throw (new Error((("Cannot swap target: " + target) + " - item must be a Display Object.")));
};
}
override public function removeItem(obj):void{
var found:Boolean;
var numObjs:int = objectArray.length;
var i:uint;
while (i < numObjs) {
if (objectArray[i] == obj){
if (i == 0){
throw (new Error("You cannot remove the target from CollisionList. Use swapTarget to change the target."));
};
objectArray.splice(i, 1);
found = true;
break;
};
i++;
};
if (!found){
throw (new Error((obj + " could not be removed - object not found in item list.")));
};
}
}
}//package Collision
Section 16
//AS3_vs_AS2 (come2play_as3.api.auto_copied.AS3_vs_AS2)
package come2play_as3.api.auto_copied {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
public final class AS3_vs_AS2 {
public static const isAS3:Boolean = true;
public static var TRACE_LOADING:Boolean = false;
private static var prevent_garbage_collection:Array = [];
public static var myAddTimeoutFunc:Function = null;
public static var NATIVE_SERIALIZERS:Array;
public static var myShowError:Function = null;
public static var DO_TRACE:Boolean = false;
private static var name2classFields:Object = {};
public static var myAddEventListenerFunc:Function = null;
private static var checkedClasses:Object = {};
public function AS3_vs_AS2(){
super();
}
public static function convertToInt(o:Object):int{
return (int(o));
}
public static function delegate(thisObj:Object, handler:Function, ... _args):Function{
var thisObj = thisObj;
var handler = handler;
var args = _args;
return (function (... _args):Object{
return (handler.apply(thisObj, _args.concat(args)));
});
}
public static function scaleMovie(graphics:DisplayObject, x_percentage:int, y_percentage:int):void{
scaleMovieX(graphics, x_percentage);
scaleMovieY(graphics, y_percentage);
}
public static function stringLastIndexOf(str:String, val:String, startIndex:int=2147483647):int{
return (str.lastIndexOf(val, startIndex));
}
public static function showError(graphics:DisplayObjectContainer, msg:String):void{
var blackBox:Sprite;
var graphics = graphics;
var msg = msg;
trace(((((((("Showing error: myShowError=" + myShowError) + " graphics=") + graphics) + " graphics.stage=") + ((graphics == null)) ? "null" : graphics.stage) + " msg=") + msg));
if (myShowError != null){
myShowError(msg);
return;
};
if (graphics == null){
return;
};
graphics = graphics.stage;
if (graphics == null){
return;
};
blackBox = new Sprite();
blackBox.graphics.beginFill(0);
blackBox.graphics.drawRect(0, 0, 500, 500);
blackBox.graphics.endFill();
var child:TextField = new TextField();
child.text = msg;
child.width = 500;
child.height = 500;
var buttonText:TextField = new TextField();
buttonText.text = "close";
buttonText.setTextFormat(new TextFormat("Times New Roman", 14, 0), 0, 5);
buttonText.selectable = false;
var buttonBox:Sprite = new Sprite();
buttonBox.graphics.beginFill(0xFFFFFF);
buttonBox.graphics.drawRect(0, 0, 40, 20);
buttonBox.graphics.endFill();
buttonBox.addChild(buttonText);
buttonBox.x = 440;
buttonBox.y = 460;
var closeBtn:SimpleButton = new SimpleButton(buttonBox, buttonBox, buttonBox, buttonBox);
blackBox.addChild(child);
blackBox.addChild(closeBtn);
child.textColor = 0xFF0000;
graphics.addChild(blackBox);
myAddEventListener(closeBtn, MouseEvent.CLICK, function ():void{
trace("close");
graphics.removeChild(blackBox);
});
trace("Finished showing error message");
}
public static function removeMovie(graphics:DisplayObject):void{
graphics.parent.removeChild(graphics);
}
public static function checkObjectIsSerializable(obj:Object):void{
var field:Object;
if (obj == null){
return;
};
if ((((((obj is Boolean)) || ((obj is String)))) || ((obj is Number)))){
return;
};
var className:String = getClassName(obj);
if (((!((className == "Array"))) && (!((className == "Object"))))){
if (!(obj is SerializableClass)){
throw (new Error((("className=" + className) + " should extend SerializableClass because it was sent over a LocalConnection")));
};
};
for each (field in obj) {
checkObjectIsSerializable(field);
};
}
public static function scaleMovieX(graphics:DisplayObject, x_percentage:int):void{
graphics.scaleX = (Number(x_percentage) / 100);
}
public static function isNumber(o:Object):Boolean{
return ((o is Number));
}
public static function myTimeout(func:Function, in_milliseconds:int):void{
if (SerializableClass.IS_IN_FRAMEWORK){
StaticFunctions.assert(!((myAddTimeoutFunc == null)), ["Come2play forgot to set myAddTimeoutFunc"]);
myAddTimeoutFunc(func, in_milliseconds);
} else {
setTimeout(func, in_milliseconds);
};
}
public static function asBoolean(o:Object):Boolean{
return ((o as Boolean));
}
public static function addOnMouseOver(movie:IEventDispatcher, mouseOverFunc:Function, mouseOutFunc:Function, isActive:Boolean):void{
assertNotFramework();
movie.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverFunc);
movie.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutFunc);
if (isActive){
movie.addEventListener(MouseEvent.MOUSE_OVER, mouseOverFunc);
movie.addEventListener(MouseEvent.MOUSE_OUT, mouseOutFunc);
};
}
public static function scaleMovieY(graphics:DisplayObject, y_percentage:int):void{
graphics.scaleY = (Number(y_percentage) / 100);
}
public static function setAlpha(target:DisplayObject, alphaPercentage:int):void{
target.alpha = (alphaPercentage / 100);
}
public static function isBoolean(o:Object):Boolean{
return ((o is Boolean));
}
public static function xml_getSimpleContent(xml:XML):String{
return (xml.toString());
}
private static function myAddEventListener(dispatcher:IEventDispatcher, type:String, listener:Function):void{
if (SerializableClass.IS_IN_FRAMEWORK){
StaticFunctions.assert(!((myAddEventListenerFunc == null)), ["Come2play forgot to set myAddEventListenerFunc"]);
myAddEventListenerFunc(dispatcher, type, listener);
} else {
dispatcher.addEventListener(type, listener);
};
}
public static function getLoaderInfoParameters(someMovieClip:DisplayObject):Object{
return (someMovieClip.loaderInfo.parameters);
}
public static function xml_create(str:String):XML{
return (new XML(str));
}
public static function registerNativeSerializers():void{
var serializerClass:Class;
var serializer:NativeSerializable;
var classes:Array = [ErrorSerializable, XMLSerializable, ByteArraySerializable, DictionarySerializable, DateSerializable];
NATIVE_SERIALIZERS = [];
for each (serializerClass in classes) {
serializer = new (serializerClass);
SerializableClass.registerClassAlias(serializer.__CLASS_NAME__, serializerClass);
serializer.register();
NATIVE_SERIALIZERS.push(serializer);
};
}
public static function IndexOf(arr:Array, val:Object):int{
return (arr.indexOf(val));
}
public static function LastIndexOf(arr:Array, val:Object):int{
return (arr.lastIndexOf(val));
}
public static function getTimeString():String{
return (new Date().toLocaleTimeString());
}
public static function isSerializableClass(o:Object):Boolean{
return ((o is SerializableClass));
}
public static function setVisible(graphics:DisplayObject, isVisible:Boolean):void{
graphics.visible = isVisible;
}
private static function addKeyboardListener2(is_key_down:Boolean, graphics:DisplayObjectContainer, func:Function):void{
var is_key_down = is_key_down;
var graphics = graphics;
var func = func;
myAddEventListener(graphics.stage, (is_key_down) ? KeyboardEvent.KEY_DOWN : KeyboardEvent.KEY_UP, function (event:KeyboardEvent):void{
var charCode:int = event.charCode;
var keyCode:int = event.keyCode;
var keyLocation:int = event.keyLocation;
var altKey:Boolean = event.altKey;
var ctrlKey:Boolean = event.ctrlKey;
var shiftKey:Boolean = event.shiftKey;
func(is_key_down, charCode, keyCode, keyLocation, altKey, ctrlKey, shiftKey);
});
}
public static function asSerializableClass(o:Object):SerializableClass{
return ((o as SerializableClass));
}
public static function getMovieChild(graphics:MovieClip, childName:String):MovieClip{
return ((getChild(graphics, childName) as MovieClip));
}
public static function addOnPress(movie:IEventDispatcher, func:Function, isActive:Boolean):void{
assertNotFramework();
movie.removeEventListener(MouseEvent.CLICK, func);
if (isActive){
movie.addEventListener(MouseEvent.CLICK, func);
};
}
public static function specialToString(o:Object):String{
var serializer:NativeSerializable;
var nativeSerializer:NativeSerializable;
for each (serializer in NATIVE_SERIALIZERS) {
nativeSerializer = serializer.fromNative(o);
if (nativeSerializer != null){
break;
};
};
if (nativeSerializer != null){
return (nativeSerializer.toString());
};
return (o.toString());
}
private static function localConnectionFailed(event:Event, client:Object, handlerFunc:Function=null):void{
if (DO_TRACE){
StaticFunctions.storeTrace([" localConnectionFailed ", event]);
};
if ((event is StatusEvent)){
if ((event as StatusEvent).level == "error"){
if (handlerFunc != null){
handlerFunc(false);
} else {
StaticFunctions.showError((((((("LocalConnection.onStatus error=" + event) + " client=") + client) + " client's class=") + getClassName(client)) + ". Are you sure you are running this game inside the emulator?)"));
};
} else {
if (handlerFunc != null){
handlerFunc(true);
};
};
} else {
if ((event is SecurityErrorEvent)){
StaticFunctions.showError((((((("LocalConnection.onStatus error=" + event) + " client=") + client) + " client's class=") + getClassName(client)) + ". Are you sure you are running this game inside the emulator?)"));
};
};
}
public static function asArray(o:Object):Array{
return ((o as Array));
}
public static function createMovieInstance(graphics:MovieClip, linkageName:String, name:String):MovieClip{
var _Class:Class = getClassByName(linkageName);
var dup:MovieClip = (new (_Class) as MovieClip);
dup.name = name;
graphics.addChild(dup);
return (dup);
}
public static function waitForStage(graphics:MovieClip, gameConsructor:Function):void{
var stageTimer:Timer;
var graphics = graphics;
var gameConsructor = gameConsructor;
stageTimer = new Timer(100, 0);
stageTimer.start();
trace("waitForStage...");
myAddEventListener(stageTimer, TimerEvent.TIMER, function ():void{
if (graphics.stage){
trace("stage loaded!");
stageTimer.stop();
gameConsructor();
};
});
}
public static function xml_getChildren(xml:XML):Array{
var child:XML;
var list:XMLList = xml.children();
var res:Array = [];
for each (child in list) {
res.push(child);
};
return (res);
}
public static function addStatusListener(conn:LocalConnection, client:Object, functions:Array, handlerFunc:Function=null):void{
var conn = conn;
var client = client;
var functions = functions;
var handlerFunc = handlerFunc;
conn.client = client;
myAddEventListener(conn, StatusEvent.STATUS, function (ev:Event):void{
localConnectionFailed(ev, client, handlerFunc);
});
myAddEventListener(conn, SecurityErrorEvent.SECURITY_ERROR, function (ev:Event):void{
localConnectionFailed(ev, client, handlerFunc);
});
}
public static function isArray(o:Object):Boolean{
return ((o is Array));
}
private static function assertNotFramework():void{
StaticFunctions.assert((myAddEventListenerFunc == null), ["You cannot call this method in framework"]);
}
public static function checkConstructorHasNoArgs(obj:SerializableClass):void{
var constructor:XML;
var parameter:XML;
var className:String = obj.__CLASS_NAME__;
if (checkedClasses[className] != null){
return;
};
checkedClasses[className] = true;
var descriptionXML:XML = describeType(obj);
var constructorList:XMLList = descriptionXML.constructor;
if (constructorList.length() > 0){
constructor = constructorList[0];
for each (parameter in constructor.children()) {
if (parameter.attribute("optional").toString() != "true"){
StaticFunctions.throwError(((("The constructor of class " + className) + " that extends SerializableClass has arguments that are not optional! These are the parameters of the constructor=") + constructor.toXMLString()));
};
};
};
}
public static function byteArr2Str(byteArr:ByteArray):String{
return (JSON.stringify(ByteArraySerializable.byteArr2Arr(byteArr)));
}
public static function isString(o:Object):Boolean{
return ((o is String));
}
public static function asString(o:Object):String{
return ((o as String));
}
public static function getClassByName(className:String):Class{
var className = className;
return ((getDefinitionByName(className) as Class));
//unresolved jump
var _slot1 = err;
throw (new Error((("The class named '" + className) + "' was not found!")));
return (null);
}
public static function getChild(graphics:MovieClip, childName:String):DisplayObject{
var res:DisplayObject = graphics.getChildByName(childName);
if (res == null){
StaticFunctions.throwError(((("Missing child=" + childName) + " in movieclip=") + graphics.name));
};
return (res);
}
private static function addKeyboardListenerStageReady(graphics:DisplayObjectContainer, func:Function):void{
addKeyboardListener2(true, graphics, func);
addKeyboardListener2(false, graphics, func);
}
public static function as_int(o:Object):int{
return ((o as int));
}
public static function error2String(e:Error):String{
return (((e == null)) ? "null" : ((e.toString() + " stacktraces=") + e.getStackTrace()));
}
public static function getFieldNames(instance:Object):Array{
var fieldsList:XMLList;
var fieldInfo:XML;
var className:String = getClassName(instance);
var fieldNames:Array = name2classFields[className];
if (fieldNames == null){
fieldNames = [];
fieldsList = describeType(instance).variable;
for each (fieldInfo in fieldsList) {
fieldNames.push(fieldInfo.attribute("name"));
};
name2classFields[className] = fieldNames;
};
return (fieldNames);
}
public static function loadMovieIntoNewChild(graphics:MovieClip, url:String, onLoaded:Function):DisplayObject{
var loader:Loader;
var newMovie:DisplayObjectContainer;
var graphics = graphics;
var url = url;
var onLoaded = onLoaded;
loader = new Loader();
prevent_garbage_collection.push(loader);
newMovie = new Sprite();
var contentLoaderInfo:LoaderInfo = loader.contentLoaderInfo;
myAddEventListener(contentLoaderInfo, Event.COMPLETE, function (event:Event):void{
if (TRACE_LOADING){
StaticFunctions.storeTrace(["Done loading url=", url]);
};
newMovie.addChild(loader.content);
if (onLoaded != null){
onLoaded(true);
};
});
var handler:Function = function (event:Event):void{
if (TRACE_LOADING){
StaticFunctions.storeTrace(["Error in loading movie from url=", url, " event=", event]);
};
if (onLoaded != null){
onLoaded(false);
};
};
myAddEventListener(contentLoaderInfo, IOErrorEvent.IO_ERROR, handler);
myAddEventListener(contentLoaderInfo, SecurityErrorEvent.SECURITY_ERROR, handler);
graphics.addChild(newMovie);
if (TRACE_LOADING){
StaticFunctions.storeTrace(["Loading url=", url, " into a newly created child of=", graphics.name]);
};
loader.load(new URLRequest(url));
return (newMovie);
}
public static function getClassOfInstance(instance:Object):Class{
var className:String = getClassName(instance);
var res:Class = getClassByName(className);
StaticFunctions.assert(!((res == null)), ["Missing class for instance=", instance, " className=", className]);
return (res);
}
public static function setMovieXY(target:DisplayObject, x:int, y:int):void{
target.x = x;
target.y = y;
}
public static function getClassName(o:Object):String{
return (getQualifiedClassName(o));
}
public static function createEmptyMovieClip(graphics:MovieClip, name:String):MovieClip{
var child:MovieClip = new MovieClip();
child.name = name;
graphics.addChild(child);
return (child);
}
public static function checkAllFieldsDeserialized(obj:Object, newInstance:Object):void{
var fieldName:String;
var fieldNames:Array = getFieldNames(newInstance);
for each (fieldName in fieldNames) {
if (StaticFunctions.startsWith(fieldName, "__")){
} else {
if (!obj.hasOwnProperty(fieldName)){
throw (new Error(((("When deserializing, we didn't find fieldName=" + fieldName) + " in object=") + JSON.stringify(obj))));
};
};
};
}
public static function stringIndexOf(str:String, val:String, startIndex:int=0):int{
return (str.indexOf(val, startIndex));
}
public static function xml_getName(xml:XML):String{
return (xml.name().toString());
}
public static function addKeyboardListener(graphics:DisplayObjectContainer, func:Function):void{
var intervalId:int;
var graphics = graphics;
var func = func;
var isStageReady = !((graphics.stage == null));
if (isStageReady){
addKeyboardListenerStageReady(graphics, func);
} else {
trace("Called addKeyboardListener, but stage is still null, so we set an interval until stage is ready");
assertNotFramework();
intervalId = setInterval(function ():void{
if (graphics.stage != null){
trace("stage is ready, so we now call addKeyboardListener");
clearInterval(intervalId);
addKeyboardListenerStageReady(graphics, func);
};
}, 200);
};
}
}
}//package come2play_as3.api.auto_copied
import flash.utils.*;
class ErrorSerializable extends NativeSerializable {
public var message:String;
public var errorId:int;
private function ErrorSerializable(err:Error=null){
super("Error");
message = ((err == null)) ? null : err.message;
errorId = ((err == null)) ? 0 : err.errorID;
}
override public function fromNative(obj:Object):NativeSerializable{
return (((obj is Error)) ? new ErrorSerializable((obj as Error)) : null);
}
override public function postDeserialize():Object{
return (new Error(message, errorId));
}
}
class XMLSerializable extends NativeSerializable {
public var xmlStr:String;
private function XMLSerializable(xml:XML=null){
super("XML");
xmlStr = ((xml == null)) ? null : xml.toXMLString();
}
override public function fromNative(obj:Object):NativeSerializable{
return (((obj is XML)) ? new XMLSerializable((obj as XML)) : null);
}
override public function postDeserialize():Object{
return (new XML(xmlStr));
}
}
class ByteArraySerializable extends NativeSerializable {
public var arr:Array;
private function ByteArraySerializable(byteArr:ByteArray=null){
super("ByteArray");
arr = ((byteArr == null)) ? null : byteArr2Arr(byteArr);
}
override public function fromNative(obj:Object):NativeSerializable{
return (((obj is ByteArray)) ? new ByteArraySerializable((obj as ByteArray)) : null);
}
override public function postDeserialize():Object{
var i:int;
var res:ByteArray = new ByteArray();
for each (i in arr) {
res.writeByte(i);
};
res.position = 0;
return (res);
}
public static function byteArr2Arr(byteArr:ByteArray):Array{
var bytes:Array = [];
var oldPosition:int = byteArr.position;
byteArr.position = 0;
var i:int;
while (i < byteArr.length) {
bytes.push(byteArr.readByte());
i++;
};
byteArr.position = oldPosition;
return (bytes);
}
}
class DictionarySerializable extends NativeSerializable {
public var keyValArr:Array;
private function DictionarySerializable(dic:Dictionary=null){
var k:Object;
keyValArr = [];
super("Dictionary");
if (dic != null){
for (k in dic) {
keyValArr.push([k, dic[k]]);
};
};
}
override public function fromNative(obj:Object):NativeSerializable{
return (((obj is Dictionary)) ? new DictionarySerializable((obj as Dictionary)) : null);
}
override public function postDeserialize():Object{
var keyVal:Array;
var res:Dictionary = new Dictionary();
for each (keyVal in keyValArr) {
res[keyVal[0]] = keyVal[1];
};
return (res);
}
}
class NativeSerializable extends SerializableClass {
private function NativeSerializable(shortName:String=null){
super(shortName);
}
public function fromNative(obj:Object):NativeSerializable{
throw (new Error("Must override fromNative"));
}
override public function postDeserialize():Object{
throw (new Error("Must override postDeserialize"));
}
}
class DateSerializable extends NativeSerializable {
public var millis:Number;
private function DateSerializable(date:Date=null){
super("Date");
millis = ((date == null)) ? null : date.valueOf();
}
override public function fromNative(obj:Object):NativeSerializable{
return (((obj is Date)) ? new DateSerializable((obj as Date)) : null);
}
override public function postDeserialize():Object{
return (new Date(millis));
}
}
Section 17
//JSON (come2play_as3.api.auto_copied.JSON)
package come2play_as3.api.auto_copied {
public final class JSON {
private var ch:String;// = ""
private var text:String;
private var at:int;// = 0
public static var isDoingTesting:Boolean = false;
public function JSON(){
super();
}
private function arr():Array{
var a:Array = [];
if (ch == "["){
this.next();
this.white();
if (ch == "]"){
this.next();
return (a);
};
while (ch) {
a.push(this.value());
this.white();
if (ch == "]"){
this.next();
return (a);
};
if (ch != ","){
break;
};
this.next();
this.white();
};
};
throwError("Bad array");
return ([]);
}
private function throwError(m:String):void{
StaticFunctions.throwError((((((((((((((("Error converting a string to a flash object: " + m) + "\nError in position=") + (at - 1)) + " containing character=' ") + text.charAt((at - 1))) + " '\nThe entire string:\n'") + text) + "'\nThe successfully parsed string:\n'") + text.substring(0, (at - 1))) + "'\n") + "The string should be in a format that is a legal ActionScript3 literal (including Boolean, String, Array, int, or Object). For example, the following are legal strings:\n") + "'I\\'m a legal, string!\\n'\n") + "['an','array',42, null, true, false, -42, 'unicode=\\u05D0']\n") + "{ an : 'object field', 'foo bar' : 'other field' }\n"));
}
public function p_parse(_text:String):Object{
text = _text;
at = 0;
ch = " ";
var res:Object = value();
this.white();
if (at != (_text.length + 1)){
throwError(((("Could not parse the entire string, string length=" + _text.length) + " and the parsing reached position=") + (at - 1)));
};
return (res);
}
private function white():void{
while (ch) {
if (ch <= " "){
this.next();
} else {
if (ch == "/"){
switch (this.next()){
case "/":
do {
} while (((((this.next()) && (!((ch == "\n"))))) && (!((ch == "\r")))));
break;
case "*":
this.next();
while (true) {
if (ch){
if (ch == "*"){
if (this.next() == "/"){
next();
break;
};
} else {
this.next();
};
} else {
throwError("Unterminated comment");
};
};
break;
default:
throwError("Syntax error");
};
} else {
break;
};
};
};
}
private function next():String{
ch = text.charAt(at);
at = (at + 1);
return (ch);
}
private function str():String{
var i:int;
var t:int;
var u:int;
var firstApos:String;
var s:String = "";
var outer:Boolean;
if ((((ch == "\"")) || ((ch == "'")))){
firstApos = ch;
while (this.next()) {
if (ch == firstApos){
this.next();
return (s);
};
if (ch == "\\"){
switch (this.next()){
case "b":
s = (s + "\b");
break;
case "f":
s = (s + "\f");
break;
case "n":
s = (s + "\n");
break;
case "r":
s = (s + "\r");
break;
case "t":
s = (s + "\t");
break;
case "u":
u = 0;
i = 0;
while (i < 4) {
t = parseInt(this.next(), 16);
if (!isFinite(t)){
outer = true;
break;
};
u = ((u * 16) + t);
i = (i + 1);
};
if (outer){
outer = false;
break;
};
s = (s + String.fromCharCode(u));
break;
default:
s = (s + ch);
};
} else {
s = (s + ch);
};
};
} else {
do {
if ((((((((((((((((((((((((((((ch == ",")) || ((ch == "\"")))) || ((ch == "'")))) || ((ch == "[")))) || ((ch == "]")))) || ((ch == "{")))) || ((ch == "}")))) || ((ch == ":")))) || ((ch == " ")))) || ((ch == "\b")))) || ((ch == "\f")))) || ((ch == "\n")))) || ((ch == "\r")))) || ((ch == "\t")))){
break;
} else {
s = (s + ch);
};
} while (this.next());
if (s == ""){
throwError("Bad string: a string without \"...\" must be only alpha-numeric");
};
return (s);
};
throwError("Bad string");
return ("");
}
private function num():Number{
var v:Number;
var n:String = "";
if (ch == "-"){
n = "-";
this.next();
};
while ((((ch >= "0")) && ((ch <= "9")))) {
n = (n + ch);
this.next();
};
if (ch == "."){
n = (n + ".");
this.next();
while ((((ch >= "0")) && ((ch <= "9")))) {
n = (n + ch);
this.next();
};
};
if ((((ch == "e")) || ((ch == "E")))){
n = (n + ch);
this.next();
if ((((ch == "-")) || ((ch == "+")))){
n = (n + ch);
this.next();
};
while ((((ch >= "0")) && ((ch <= "9")))) {
n = (n + ch);
this.next();
};
};
v = Number(n);
if (!isFinite(v)){
throwError("Bad number");
};
return (v);
}
private function obj():Object{
var k:String;
var classNameArr:Array;
var className:String;
var o:Object = {};
if (ch == "{"){
this.next();
this.white();
if (ch == "$"){
this.next();
classNameArr = [];
while (ch != "$") {
classNameArr.push(ch);
this.next();
};
className = classNameArr.join("");
this.next();
this.white();
o[SerializableClass.CLASS_NAME_FIELD] = className;
};
if (ch == "}"){
this.next();
return (o);
};
while (ch) {
k = this.str();
this.white();
if (ch != ":"){
break;
};
this.next();
o[k] = this.value();
this.white();
if (ch == "}"){
this.next();
return (o);
};
if (ch != ","){
break;
};
this.next();
this.white();
};
};
throwError("Bad object");
return ({});
}
private function value():Object{
this.white();
switch (ch){
case "{":
return (this.obj());
case "[":
return (this.arr());
case "\"":
case "'":
return (this.str());
case "-":
return (this.num());
default:
return (((((ch >= "0")) && ((ch <= "9")))) ? this.num() : this.word());
};
}
private function word():Object{
var oldAt:int = at;
switch (ch){
case "t":
if ((((((this.next() == "r")) && ((this.next() == "u")))) && ((this.next() == "e")))){
this.next();
return (true);
};
break;
case "f":
if ((((((((this.next() == "a")) && ((this.next() == "l")))) && ((this.next() == "s")))) && ((this.next() == "e")))){
this.next();
return (false);
};
break;
case "n":
if ((((((this.next() == "u")) && ((this.next() == "l")))) && ((this.next() == "l")))){
this.next();
return (null);
};
break;
};
at = oldAt;
return (str());
}
public static function instanceToString(className:String, values:Object):String{
return ((((("{ $" + className) + "$ ") + object2JSON(values)) + "}"));
}
public static function parse(_text:String):Object{
var json:JSON = new (JSON);
return (json.p_parse(_text));
}
public static function getSortedKeys(arg:Object):Array{
var key:String;
var keys:Array = [];
for (key in arg) {
keys.push(key);
};
keys.sort();
return (keys);
}
public static function stringify(arg:Object):String{
var c:String;
var i:int;
var l:int;
var res:Array;
var v:String;
var charCode:int;
var arg = arg;
if (arg == null){
return ("null");
};
if (((AS3_vs_AS2.isNumber(arg)) || (AS3_vs_AS2.isBoolean(arg)))){
return (("" + arg));
};
if (AS3_vs_AS2.isArray(arg)){
res = [];
i = 0;
while (i < arg.length) {
v = stringify(arg[i]);
res.push(v);
i = (i + 1);
};
return ((("[" + res.join(",")) + "]"));
};
if (AS3_vs_AS2.isString(arg)){
res = [];
l = arg.length;
i = 0;
while (i < l) {
c = arg.charAt(i);
if (c >= " "){
if ((((c == "\\")) || ((c == "\"")))){
res.push("\\");
};
res.push(c);
} else {
switch (c){
case "\b":
res.push("\\b");
break;
case "\f":
res.push("\\f");
break;
case "\n":
res.push("\\n");
break;
case "\r":
res.push("\\r");
break;
case "\t":
res.push("\\t");
break;
default:
charCode = c.charCodeAt();
res.push((("\\u00" + Math.floor((charCode / 16)).toString(16)) + (charCode % 16).toString(16)));
};
};
i = (i + 1);
};
return ((("\"" + res.join("")) + "\""));
};
var argToString = "";
argToString = AS3_vs_AS2.specialToString(arg);
//unresolved jump
var _slot1 = e;
if (isDoingTesting){
throw (_slot1);
};
argToString = ((("ERROR in toString() method of " + AS3_vs_AS2.getClassName(arg)) + " err=") + AS3_vs_AS2.error2String(_slot1));
if (SerializableClass.isToStringObject(argToString)){
return ((("{" + object2JSON(arg)) + "}"));
};
return (argToString);
}
private static function object2JSON(arg:Object):String{
var z:String;
var res:Array = [];
var keys:Array = getSortedKeys(arg);
for each (z in keys) {
res.push(((stringify(z) + ":") + stringify(arg[z])));
};
return (res.join(" , "));
}
}
}//package come2play_as3.api.auto_copied
Section 18
//LocalConnectionUser (come2play_as3.api.auto_copied.LocalConnectionUser)
package come2play_as3.api.auto_copied {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_generated.*;
import flash.net.*;
import flash.external.*;
public class LocalConnectionUser {
private var isServer:Boolean;
public var verifier:ProtocolVerifier;
private var sendPrefixIntervalId:uint;
private var lcUser:LocalConnection;
private var lcInit:LocalConnection;
public var _shouldVerify:Boolean;
private var sSendChanel:String;
private var randomPrefix:String;
private var sInitChanel:String;
public static var DEFAULT_LOCALCONNECTION_PREFIX:String = ("" + StaticFunctions.random(1, 10000));
public static var VERSION_FOR_TRACE:int = 7;
public static var MILL_AFTER_ALLOW_DOMAINS:int = 500;
public static var MILL_WAIT_BEFORE_DO_REGISTER:int = 100;
public static var ALLOW_DOMAIN:String = "*";
public static var REVIEW_USER_ID:int = -1;
public static var DO_TRACE:Boolean = true;
public static var IS_LOCAL_CONNECTION_UDERSCORE:Boolean = false;
public static var AGREE_ON_PREFIX:Boolean = true;
public function LocalConnectionUser(_someMovieClip:DisplayObjectContainer, isServer:Boolean, sPrefix:String, shouldVerify:Boolean){
super();
if (!isServer){
StaticFunctions.performReflectionFromFlashVars(_someMovieClip);
};
StaticFunctions.allowDomains();
StaticFunctions.storeTrace(["VERSION_FOR_TRACE=", VERSION_FOR_TRACE]);
_shouldVerify = shouldVerify;
AS3_vs_AS2.registerNativeSerializers();
API_LoadMessages.useAll();
verifier = new ProtocolVerifier();
this.isServer = isServer;
StaticFunctions.storeTrace(["ProtocolVerifier=", verifier]);
StaticFunctions.someMovieClip = _someMovieClip;
if (sPrefix == null){
myTrace(["WARNING: didn't find 'prefix' in the loader info parameters. Probably because you are doing testing locally."]);
sPrefix = DEFAULT_LOCALCONNECTION_PREFIX;
};
sInitChanel = getInitChanelString(sPrefix);
if (MILL_AFTER_ALLOW_DOMAINS == 0){
buildConnection();
} else {
AS3_vs_AS2.myTimeout(AS3_vs_AS2.delegate(this, this.buildConnection), MILL_AFTER_ALLOW_DOMAINS);
};
}
private function verify(msg:API_Message, isSend:Boolean):void{
if (!_shouldVerify){
return;
};
if (isServer != isSend){
verifier.msgFromGame(msg);
} else {
verifier.msgToGame(msg);
};
}
public function localconnection_callback(msgObj:Object):void{
var msg:API_Message;
var deserializedMsg:Object;
var msgObj = msgObj;
if (StaticFunctions.DID_SHOW_ERROR){
return;
};
msg = null;
deserializedMsg = SerializableClass.deserialize(msgObj);
msg = (deserializedMsg as API_Message);
if (msg == null){
throwError((("msgObj=" + JSON.stringify(msgObj)) + " is not an API_Message"));
};
myTrace(["gotMessage: ", msg]);
verify(msg, false);
gotMessage(msg);
//unresolved jump
var _slot1 = err;
passError(((msg == null)) ? msgObj : msg, _slot1);
}
public function localconnection_init(sRandomPrefix:String):void{
var sDoChanel:String;
var sGotChanel:String;
var sListenChannel:String;
var sRandomPrefix = sRandomPrefix;
if (StaticFunctions.DID_SHOW_ERROR){
return;
};
myTrace(["got sRandomPrefix", sRandomPrefix, isServer]);
if (!isServer){
lcInit.close();
};
lcUser = createLocalConnection();
AS3_vs_AS2.addStatusListener(lcUser, this, ["localconnection_callback"]);
sDoChanel = getDoChanelString(sRandomPrefix);
sGotChanel = getGotChanelString(sRandomPrefix);
sListenChannel = (isServer) ? sDoChanel : sGotChanel;
sSendChanel = (isServer) ? sGotChanel : sDoChanel;
myTrace(["LocalConnection listens on channel=", sListenChannel, " and sends on ", sSendChanel]);
lcUser.connect(sListenChannel);
//unresolved jump
var _slot1 = err;
passError("local connection init", _slot1);
}
private function connectionHandler(isSuccess:Boolean):void{
myTrace([("connectionHandler sending random prefix isSuccess: " + isSuccess)]);
if (isSuccess){
clearInterval(sendPrefixIntervalId);
};
}
private function createLocalConnection():LocalConnection{
var lc:LocalConnection = new LocalConnection();
if (StaticFunctions.ALLOW_DOMAINS != null){
lc.allowDomain(StaticFunctions.ALLOW_DOMAINS);
};
myTrace(["locoal connection Domain", lc.domain]);
return (lc);
}
protected function getErrorMessage(withObj:Object, err:Error):String{
return (((("Error occurred when passing " + JSON.stringify(withObj)) + ", the error is=\n\t\t") + AS3_vs_AS2.error2String(err)));
}
public function gotMessage(msg:API_Message):void{
}
public function sendMessage(msg:API_Message):void{
if ((msg is API_DoRegisterOnServer)){
if (lcUser != null){
reallySendMessage(msg);
} else {
AS3_vs_AS2.myTimeout(AS3_vs_AS2.delegate(this, this.sendMessage, msg), MILL_WAIT_BEFORE_DO_REGISTER);
};
} else {
reallySendMessage(msg);
};
}
private function reallySendMessage(msg:API_Message):void{
var msg = msg;
myTrace(["sendMessage: ", msg]);
AS3_vs_AS2.checkObjectIsSerializable(msg);
verify(msg, true);
lcUser.send(sSendChanel, "localconnection_callback", msg.toObject());
//unresolved jump
var _slot1 = err;
passError(msg, _slot1);
}
private function passError(withObj:Object, err:Error):void{
showError(getErrorMessage(withObj, err));
}
public function myTrace(msg:Array):void{
if (DO_TRACE){
StaticFunctions.storeTrace([AS3_vs_AS2.getClassName(this), ": ", msg]);
};
}
private function sendPrefix():void{
myTrace(["sent randomPrefix on ", sInitChanel, " randomPrefix sent is:", randomPrefix, " Is server: ", isServer]);
lcInit.send(sInitChanel, "localconnection_init", randomPrefix);
//unresolved jump
var _slot1 = err;
passError(("prefix error,prefix :" + randomPrefix), _slot1);
}
private function buildConnection():void{
if (AGREE_ON_PREFIX){
lcInit = createLocalConnection();
AS3_vs_AS2.addStatusListener(lcInit, this, ["localconnection_init"], AS3_vs_AS2.delegate(this, this.connectionHandler));
if (isServer){
randomPrefix = String(StaticFunctions.random(1, 1000000));
myTrace(["Attempting to send the randomPrefix with which LocalConnections will communicate... randomPrefix=", randomPrefix]);
localconnection_init(randomPrefix);
sendPrefixIntervalId = setInterval(AS3_vs_AS2.delegate(this, this.sendPrefix), MILL_WAIT_BEFORE_DO_REGISTER);
} else {
myTrace(["started listening to stuff on ", sInitChanel]);
lcInit.connect(sInitChanel);
};
} else {
localconnection_init(sInitChanel);
};
//unresolved jump
var _slot1 = err;
passError("Constructor", _slot1);
}
public static function throwError(msg:String):void{
StaticFunctions.throwError(msg);
}
public static function getPrefixFromFlashVars(_someMovieClip:DisplayObjectContainer):String{
var parameters:Object = AS3_vs_AS2.getLoaderInfoParameters(_someMovieClip);
var sPrefix:String = parameters["prefix"];
if (sPrefix == null){
sPrefix = parameters["?prefix"];
};
return (getPrefixFromString(sPrefix));
}
public static function showError(msg:String):void{
StaticFunctions.showError(msg);
}
public static function assert(val:Boolean, args:Array):void{
if (!val){
StaticFunctions.assert(false, args);
};
}
public static function getDoChanelString(sRandomPrefix:String):String{
if (IS_LOCAL_CONNECTION_UDERSCORE){
return (("_DO_CHANEL_" + sRandomPrefix));
};
return (("DO_CHANEL_" + sRandomPrefix));
}
public static function getPrefixFromString(sPrefix:String):String{
return (sPrefix);
}
public static function getInitChanelString(sPrefix:String):String{
if (IS_LOCAL_CONNECTION_UDERSCORE){
return (("_INIT_CHANEL_" + sPrefix));
};
return (("INIT_CHANEL_" + sPrefix));
}
public static function getGotChanelString(sRandomPrefix:String):String{
if (IS_LOCAL_CONNECTION_UDERSCORE){
return (("_GOT_CHANEL_" + sRandomPrefix));
};
return (("GOT_CHANEL_" + sRandomPrefix));
}
}
}//package come2play_as3.api.auto_copied
Section 19
//ObjectDictionary (come2play_as3.api.auto_copied.ObjectDictionary)
package come2play_as3.api.auto_copied {
import come2play_as3.api.auto_generated.*;
public final class ObjectDictionary extends SerializableClass {
public var allValues:Array;
public var hashMap:Object;
public var pSize:int;
public var allKeys:Array;
public function ObjectDictionary(){
super();
hashMap = new Object();
pSize = 0;
allKeys = [];
allValues = [];
}
public function addEntry(entry:ServerEntry):void{
if ((((entry.visibleToUserIds == null)) && ((entry.value == null)))){
remove(entry.key);
} else {
put(entry.key, entry);
};
}
public function size():int{
return (pSize);
}
public function remove(key:Object):Object{
var entry:Array;
var oldKey:Object;
var indexInAll:int;
var hash:int = hashObject(key);
if (hashMap[hash] == null){
return (null);
};
var entries:Array = hashMap[hash];
var i:int;
while (i < entries.length) {
entry = entries[i];
oldKey = entry[0];
if (areEqual(oldKey, key)){
entries.splice(i, 1);
if (entries.length == 0){
delete hashMap[hash];
};
pSize--;
indexInAll = AS3_vs_AS2.IndexOf(allKeys, oldKey);
if (indexInAll == -1){
throw (new Error("Internal error in ObjectDictionary"));
};
allKeys.splice(indexInAll, 1);
allValues.splice(indexInAll, 1);
return (entry[1]);
};
i++;
};
return (null);
}
public function hasKey(key:Object):Boolean{
return (!((getEntry(key) == null)));
}
public function put(key:Object, value:Object):void{
remove(key);
var hash:int = hashObject(key);
if (hashMap[hash] == null){
hashMap[hash] = [];
};
var entries:Object = hashMap[hash];
entries.push([key, value]);
pSize++;
allKeys.push(key);
allValues.push(value);
}
public function getValues():Array{
return (allValues);
}
public function getKeys():Array{
return (allKeys);
}
public function getValue(key:Object):Object{
var entry:Array = getEntry(key);
return (((entry == null)) ? null : entry[1]);
}
private function getEntry(key:Object):Array{
var entry:Array;
var entryKey:Object;
var hash:int = hashObject(key);
if (hashMap[hash] == null){
return (null);
};
var entries:Array = hashMap[hash];
for each (entry in entries) {
entryKey = entry[0];
if (areEqual(entryKey, key)){
return (entry);
};
};
return (null);
}
public static function areEqual(o1:Object, o2:Object):Boolean{
return (StaticFunctions.areEqual(o1, o2));
}
public static function hashObject(o:Object):int{
var res:int;
var z:String;
var str:String;
var len:int;
var i:int;
if (o == null){
return (541);
};
if (AS3_vs_AS2.isBoolean(o)){
return ((o) ? 523 : 521);
};
if (AS3_vs_AS2.isNumber(o)){
return (AS3_vs_AS2.convertToInt(o));
};
if (AS3_vs_AS2.isString(o)){
str = o.toString();
len = str.length;
res = 509;
i = 0;
while (i < len) {
res = (res << 1);
res = (res ^ str.charCodeAt(i));
i++;
};
return (res);
};
if (AS3_vs_AS2.isArray(o)){
res = 503;
i = 0;
while (i < o.length) {
res = (res << 1);
res = (res ^ hashObject(o[i]));
i++;
};
return (res);
};
res = 499;
for (z in o) {
res = (res ^ (hashObject(z) ^ hashObject(o[z])));
};
return (res);
}
}
}//package come2play_as3.api.auto_copied
Section 20
//ProtocolVerifier (come2play_as3.api.auto_copied.ProtocolVerifier)
package come2play_as3.api.auto_copied {
import flash.utils.*;
import come2play_as3.api.auto_generated.*;
public class ProtocolVerifier {
private var transactionStartedOn:int;// = -1
private var myUserId:int;// = -1
private var currentCallback:API_Message;// = null
private var nextPlayerIds:Array;
private var currentPlayerIds:Array;
private var didRegisterOnServer:Boolean;// = false
private var allPlayerIds:Array;
public static var MAX_ANIMATION_MILLISECONDS:int = 10000;
public function ProtocolVerifier(){
super();
setInterval(AS3_vs_AS2.delegate(this, this.checkAnimationInterval), MAX_ANIMATION_MILLISECONDS);
currentPlayerIds = [];
nextPlayerIds = [];
}
private function isNullKeyExistUserEntry(userEntries:Array):void{
var userEntry:UserEntry;
check((userEntries.length >= 1), ["userEntries must have at least one UserEntry!"]);
for each (userEntry in userEntries) {
check(!((userEntry.key == null)), ["UserEntry.key cannot be null !"]);
};
}
private function checkAnimationInterval():void{
if (transactionStartedOn == -1){
return;
};
var now:int = getTimer();
if ((now - transactionStartedOn) < MAX_ANIMATION_MILLISECONDS){
return;
};
StaticFunctions.throwError((((((("An transaction is running for more than MAX_ANIMATION_MILLISECONDS=" + MAX_ANIMATION_MILLISECONDS) + ". It started ") + transactionStartedOn) + " milliseconds after the script started, and now=") + now) + "."));
}
public function isInPlayers(playerId:int):Boolean{
return (!((AS3_vs_AS2.IndexOf(currentPlayerIds, playerId) == -1)));
}
private function isNullKeyExist(keys:Array):void{
var key:String;
check((keys.length >= 1), ["keys must have at leasy one key!"]);
for each (key in keys) {
check(!((key == null)), ["key cannot be null !"]);
};
}
public function isDoAll(doMsg:API_Message):Boolean{
return (StaticFunctions.startsWith(doMsg.getMethodName(), "doAll"));
}
public function toString():String{
return (((((((((((("ProtocolVerifier:" + " transactionStartedOn=") + transactionStartedOn) + " currentCallback=") + currentCallback) + " didRegisterOnServer=") + didRegisterOnServer) + " currentPlayerIds=") + currentPlayerIds) + " currentCallback=") + currentCallback) + ""));
}
public function getFinishedPlayerIds():Array{
var playerId:int;
var spliceIndex:int;
if (allPlayerIds == null){
return (new Array());
};
var finishedPlayerids:Array = allPlayerIds.concat();
for each (playerId in currentPlayerIds) {
spliceIndex = AS3_vs_AS2.IndexOf(finishedPlayerids, playerId);
finishedPlayerids.splice(spliceIndex, 1);
};
return (finishedPlayerids);
}
private function isDeleteLegal(userEntries:Array):void{
var userEntry:UserEntry;
for each (userEntry in userEntries) {
if (userEntry.value == null){
check(!(userEntry.isSecret), ["key deletion must be public! userEntry=", userEntry]);
};
};
}
private function checkInProgress(inProgress:Boolean, msg:API_Message):void{
StaticFunctions.assert((inProgress == (currentPlayerIds.length > 0)), ["The game must ", (inProgress) ? "" : "not", " be in progress when passing msg=", msg]);
}
private function isNullKeyExistRevealEntry(revealEntries:Array):void{
var revealEntry:RevealEntry;
for each (revealEntry in revealEntries) {
check(!((revealEntry == null)), ["RevealEntry cannot be null !"]);
check(!((revealEntry.key == null)), ["RevealEntry.key cannot be null !"]);
check((((revealEntry.userIds == null)) || (isAllInPlayers(revealEntry.userIds))), ["RevealEntry.userIds must either be null or contain only players"]);
};
}
public function msgFromGame(doMsg:API_Message):void{
var doStoreStateMessage:API_DoStoreState;
var transaction:API_Transaction;
var wasStoreStateCalculation:Boolean;
var isRequestStateCalculation:Boolean;
var doAllMsg:API_Message;
check(!((doMsg == null)), ["Send a null message!"]);
if ((doMsg is API_DoRegisterOnServer)){
check(!(didRegisterOnServer), ["Call DoRegisterOnServer only once!"]);
didRegisterOnServer = true;
return;
};
check(didRegisterOnServer, ["The first call must be DoRegisterOnServer!"]);
if (isPassThrough(doMsg)){
return;
};
if ((doMsg is API_DoStoreState)){
check(isPlayer(), ["Only a player can send DoStoreState"]);
doStoreStateMessage = (doMsg as API_DoStoreState);
isNullKeyExistUserEntry(doStoreStateMessage.userEntries);
isNullKeyExistRevealEntry(doStoreStateMessage.revealEntries);
isDeleteLegal(doStoreStateMessage.userEntries);
} else {
if ((doMsg is API_Transaction)){
transaction = (doMsg as API_Transaction);
check((currentCallback.getMethodName() == transaction.callback.callbackName), ["Illegal callbackName!"]);
currentPlayerIds = nextPlayerIds;
wasStoreStateCalculation = false;
isRequestStateCalculation = (currentCallback is API_GotRequestStateCalculation);
for each (doAllMsg in transaction.messages) {
checkDoAll(doAllMsg);
if (isRequestStateCalculation){
if ((doAllMsg is API_DoAllStoreStateCalculation)){
wasStoreStateCalculation = true;
} else {
check((doAllMsg is API_DoAllFoundHacker), ["Illegal msg=", doAllMsg, " when processing ", currentCallback]);
};
};
};
if (transaction.messages.length > 0){
check(((((((isRequestStateCalculation) || ((currentCallback is API_GotMatchStarted)))) || ((currentCallback is API_GotMatchEnded)))) || ((currentCallback is API_GotStateChanged))), ["You can change the state with a doAll message only in a transaction that corresponds to GotMatchStarted, GotMatchEnded or GotStateChanged. doAllMsg=", doAllMsg, " currentCallback=", currentCallback]);
};
if (isRequestStateCalculation){
check(wasStoreStateCalculation, ["When the server calls gotRequestStateCalculation, you must call doAllStoreStateCalculation"]);
};
currentCallback = null;
transactionStartedOn = -1;
} else {
check(false, ["Forgot to verify message type=", AS3_vs_AS2.getClassName(doMsg), " doMsg=", doMsg]);
};
};
}
private function check(cond:Boolean, arr:Array):void{
if (cond){
return;
};
StaticFunctions.assert(false, ["ProtocolVerifier found an error: ", arr]);
}
private function checkServerEntries(serverEntries:Array):void{
var entry:ServerEntry;
for each (entry in serverEntries) {
check(!((entry.key == null)), ["Found a null key in serverEntry=", entry]);
};
}
public function msgToGame(gotMsg:API_Message):void{
var stateChanged:API_GotStateChanged;
var matchStarted:API_GotMatchStarted;
var matchEnded:API_GotMatchEnded;
var customInfo:API_GotCustomInfo;
var infoEntry:InfoEntry;
check(!((gotMsg == null)), ["Got a null message!"]);
check((currentCallback == null), ["Container sent two messages without waiting! oldCallback=", currentCallback, " newCallback=", gotMsg]);
check(didRegisterOnServer, [T.i18n("Container sent a message before getting doRegisterOnServer")]);
currentCallback = gotMsg;
transactionStartedOn = getTimer();
if (isOldBoard(gotMsg)){
} else {
if ((gotMsg is API_GotStateChanged)){
checkInProgress(true, gotMsg);
stateChanged = (gotMsg as API_GotStateChanged);
checkServerEntries(stateChanged.serverEntries);
} else {
if ((gotMsg is API_GotMatchStarted)){
checkInProgress(false, gotMsg);
matchStarted = (gotMsg as API_GotMatchStarted);
checkServerEntries(matchStarted.serverEntries);
allPlayerIds = matchStarted.allPlayerIds.concat();
nextPlayerIds = StaticFunctions.subtractArray(matchStarted.allPlayerIds, matchStarted.finishedPlayerIds);
} else {
if ((gotMsg is API_GotMatchEnded)){
checkInProgress(true, gotMsg);
matchEnded = (gotMsg as API_GotMatchEnded);
nextPlayerIds = StaticFunctions.subtractArray(currentPlayerIds, matchEnded.finishedPlayerIds);
} else {
if ((gotMsg is API_GotCustomInfo)){
customInfo = (gotMsg as API_GotCustomInfo);
for each (infoEntry in customInfo.infoEntries) {
if (infoEntry.key == API_Message.CUSTOM_INFO_KEY_myUserId){
myUserId = AS3_vs_AS2.as_int(infoEntry.value);
};
};
} else {
if ((gotMsg is API_GotKeyboardEvent)){
checkInProgress(true, gotMsg);
} else {
if ((gotMsg is API_GotUserInfo)){
} else {
if ((gotMsg is API_GotUserDisconnected)){
} else {
if ((gotMsg is API_GotRequestStateCalculation)){
} else {
check(false, ["Illegal gotMsg=", gotMsg]);
};
};
};
};
};
};
};
};
};
}
public function isPlayer():Boolean{
return (isInPlayers(myUserId));
}
private function checkDoAll(msg:API_Message):void{
var doAllStoreStateCalculations:API_DoAllStoreStateCalculation;
var doAllStoreStateMessage:API_DoAllStoreState;
var doAllEndMatchMessage:API_DoAllEndMatch;
var doAllRevealState:API_DoAllRevealState;
var doAllRequestStateCalculation:API_DoAllRequestStateCalculation;
var doAllRequestRandomState:API_DoAllRequestRandomState;
var doAllSetTurn:API_DoAllSetTurn;
var doAllShuffleState:API_DoAllShuffleState;
if ((msg is API_DoAllFoundHacker)){
} else {
if ((msg is API_DoAllStoreStateCalculation)){
doAllStoreStateCalculations = (msg as API_DoAllStoreStateCalculation);
isNullKeyExistUserEntry(doAllStoreStateCalculations.userEntries);
isDeleteLegal(doAllStoreStateCalculations.userEntries);
} else {
if ((msg is API_DoAllStoreState)){
doAllStoreStateMessage = (msg as API_DoAllStoreState);
isNullKeyExistUserEntry(doAllStoreStateMessage.userEntries);
isDeleteLegal(doAllStoreStateMessage.userEntries);
} else {
if ((msg is API_DoAllEndMatch)){
doAllEndMatchMessage = (msg as API_DoAllEndMatch);
isAllInPlayers(doAllEndMatchMessage.finishedPlayers);
} else {
if ((msg is API_DoAllRevealState)){
doAllRevealState = (msg as API_DoAllRevealState);
isNullKeyExistRevealEntry(doAllRevealState.revealEntries);
} else {
if ((msg is API_DoAllRequestStateCalculation)){
doAllRequestStateCalculation = (msg as API_DoAllRequestStateCalculation);
isNullKeyExist(doAllRequestStateCalculation.keys);
} else {
if ((msg is API_DoAllRequestRandomState)){
doAllRequestRandomState = (msg as API_DoAllRequestRandomState);
check(!((doAllRequestRandomState.key == null)), ["You have to call doAllRequestRandomState with a non null key !"]);
} else {
if ((msg is API_DoAllSetTurn)){
doAllSetTurn = (msg as API_DoAllSetTurn);
check(isInPlayers(doAllSetTurn.userId), ["You have to call doAllSetTurn with a playerId!"]);
} else {
if ((msg is API_DoAllSetMove)){
} else {
if ((msg is API_DoAllShuffleState)){
doAllShuffleState = (msg as API_DoAllShuffleState);
isNullKeyExist(doAllShuffleState.keys);
} else {
check(false, ["Unknown doAll message=", msg]);
};
};
};
};
};
};
};
};
};
};
}
public function getAllPlayerIds():Array{
return (currentPlayerIds);
}
public function isAllInPlayers(playerIds:Array):Boolean{
var playerId:int;
check((playerIds.length >= 1), ["isAllInPlayers was called with an empty playerIds array"]);
for each (playerId in playerIds) {
if (!isInPlayers(playerId)){
return (false);
};
};
return (true);
}
public static function isOldBoard(msg:API_Message):Boolean{
var name:String = msg.getMethodName();
return (((StaticFunctions.startsWith(name, "do_")) || (StaticFunctions.startsWith(name, "got_"))));
}
public static function isPassThrough(doMsg:API_Message):Boolean{
return ((((((((doMsg is API_DoAllFoundHacker)) || ((doMsg is API_DoRegisterOnServer)))) || ((doMsg is API_DoTrace)))) || (isOldBoard(doMsg))));
}
}
}//package come2play_as3.api.auto_copied
Section 21
//SerializableClass (come2play_as3.api.auto_copied.SerializableClass)
package come2play_as3.api.auto_copied {
import flash.events.*;
public class SerializableClass extends Event {
public var __CLASS_NAME__:String;
public static const CLASS_NAME_FIELD:String = "__CLASS_NAME__";
private static var SHORTNAME_TO_INSTANCE:Object = {};
public static var IS_TRACE_REGISTER:Boolean = false;
public static var IS_THROWING_EXCEPTIONS:Boolean = true;
public static var EVENT_FIELDS:Array = ["type", "bubbles", "cancelable", "currentTarget", "eventPhase", "target"];
private static var SHORTNAME_TO_CLASS:Object = {};
public static var IS_TESTING_SAME_REGISTER:Boolean = true;
public static var IS_IN_FRAMEWORK:Boolean = ("come2play_as3.api" == "come2play_as3");
public static var IS_IN_GAME:Boolean = ("come2play_as3.api" == ("come2play_as3" + ".api"));
public function SerializableClass(shortName:String=null, bubbles:Boolean=false, cancelable:Boolean=false){
__CLASS_NAME__ = ((shortName == null)) ? StaticFunctions.getShortClassName(this) : shortName;
super(__CLASS_NAME__, bubbles, cancelable);
StaticFunctions.assert(!(XMLSerializer.isReserved(__CLASS_NAME__)), ["The shortName=", __CLASS_NAME__, " is a reserved word, please use another shortName."]);
StaticFunctions.assert((AS3_vs_AS2.stringIndexOf(__CLASS_NAME__, "$") == -1), ["Illegal shortName in SerializableClass! shortName=", shortName]);
register();
}
public function isEqual(other:SerializableClass):Boolean{
return (StaticFunctions.areEqual(this, other));
}
public function register():void{
var newXlass:String;
var oldXlass:String;
var shortName:String = __CLASS_NAME__;
var oldInstance:Object = SHORTNAME_TO_INSTANCE[shortName];
if (oldInstance != null){
if (IS_TESTING_SAME_REGISTER){
newXlass = AS3_vs_AS2.getClassName(this);
oldXlass = AS3_vs_AS2.getClassName(oldInstance);
StaticFunctions.assert((oldXlass == newXlass), ["Previously added shortName=", shortName, " with oldXlass=", oldXlass, " and now with newXlass=", newXlass]);
};
return;
};
SHORTNAME_TO_INSTANCE[shortName] = this;
AS3_vs_AS2.checkConstructorHasNoArgs(this);
if (IS_TRACE_REGISTER){
StaticFunctions.storeTrace(["SerializableClass.register: Registered class with shortName=", shortName, " with exampleInstance=", this]);
};
testCreateInstance(shortName);
}
public function eventToString():String{
return (super.toString());
}
public function toObject():Object{
var key:String;
var values:Object = {};
values[CLASS_NAME_FIELD] = __CLASS_NAME__;
for each (key in getFieldNames()) {
values[key] = serializable2Object(this[key]);
};
return (values);
}
public function getFieldNames():Array{
var key:String;
var res:Array = [];
var fieldNames:Array = AS3_vs_AS2.getFieldNames(this);
for each (key in fieldNames) {
if (StaticFunctions.startsWith(key, "__")){
} else {
if (((!((EVENT_FIELDS == null))) && (!((AS3_vs_AS2.IndexOf(EVENT_FIELDS, key) == -1))))){
} else {
res.push(key);
};
};
};
return (res);
}
override public function toString():String{
var key:String;
var values:Object = {};
for each (key in getFieldNames()) {
values[key] = this[key];
};
return (JSON.instanceToString(__CLASS_NAME__, values));
}
public function postDeserialize():Object{
return (this);
}
public static function isObject(o:Object):Boolean{
return (isToStringObject(o.toString()));
}
public static function shallowDeserialize(object:Object):Object{
var newObject:SerializableClass;
var key:String;
var shortName:String = (object.hasOwnProperty(CLASS_NAME_FIELD)) ? object[CLASS_NAME_FIELD] : null;
if (((!((shortName == null))) && (((IS_IN_GAME) || (!((SHORTNAME_TO_INSTANCE[shortName] == null))))))){
newObject = createInstance(shortName);
if (newObject != null){
for (key in object) {
newObject[key] = object[key];
};
AS3_vs_AS2.checkAllFieldsDeserialized(object, newObject);
object = newObject.postDeserialize();
};
};
return (object);
}
public static function serializable2Object(object:Object):Object{
var key:String;
if (object == null){
return (null);
};
if (AS3_vs_AS2.isSerializableClass(object)){
return (AS3_vs_AS2.asSerializableClass(object).toObject());
};
var isArray:Boolean = AS3_vs_AS2.isArray(object);
var isObj:Boolean = isObject(object);
var res:Object = object;
if (((isArray) || (isObj))){
res = (isArray) ? [] : {};
for (key in object) {
res[key] = serializable2Object(object[key]);
};
};
return (res);
}
public static function isToStringObject(str:String):Boolean{
return ((str == "[object Object]"));
}
private static function testCreateInstance(shortName:String):void{
if (((!((SHORTNAME_TO_CLASS[shortName] == null))) && (!((SHORTNAME_TO_INSTANCE[shortName] == null))))){
createInstance(shortName).register();
};
}
private static function createInstance(shortName:String):SerializableClass{
var xlass:Class = getClassOfShortName(shortName);
return (((xlass == null)) ? null : new (xlass));
}
private static function getClassOfInstance(instance:SerializableClass):Class{
return (AS3_vs_AS2.getClassOfInstance(instance));
}
public static function deserializeString(str:String):Object{
return (deserialize(JSON.parse(str)));
}
public static function registerClassAlias(shortName:String, classObject:Class):void{
var oldClass:Class = SHORTNAME_TO_CLASS[shortName];
if (oldClass != null){
StaticFunctions.assert((oldClass == classObject), ["You called registerClassAlias twice with shortName=", shortName, " with two different classObjects! classObject1=", oldClass, " classObject2=", classObject]);
return;
};
if (IS_TRACE_REGISTER){
StaticFunctions.storeTrace(["SerializableClass.registerClassAlias: Registered classObject=", classObject, " with shortName=", shortName]);
};
SHORTNAME_TO_CLASS[shortName] = classObject;
testCreateInstance(shortName);
}
private static function getClassOfShortName(shortName:String):Class{
var classObject:Class = SHORTNAME_TO_CLASS[shortName];
if (classObject != null){
return (classObject);
};
var instance:SerializableClass = SHORTNAME_TO_INSTANCE[shortName];
StaticFunctions.assert(!((instance == null)), ["You forgot to call SerializableClass.register for shortName=", shortName]);
return (getClassOfInstance(instance));
}
public static function deserialize(object:Object):Object{
var isArray:Boolean;
var isObj:Boolean;
var res:Object;
var key:String;
var object = object;
if (object == null){
return (null);
};
isArray = AS3_vs_AS2.isArray(object);
isObj = isObject(object);
res = object;
if (((isArray) || (isObj))){
res = (isArray) ? [] : {};
for (key in object) {
res[key] = deserialize(object[key]);
};
res = shallowDeserialize(res);
};
return (res);
//unresolved jump
var _slot1 = err;
StaticFunctions.storeTrace(("Exception thrown in deserialize:" + AS3_vs_AS2.error2String(_slot1)));
if (IS_THROWING_EXCEPTIONS){
throw (_slot1);
};
return (object);
}
}
}//package come2play_as3.api.auto_copied
Section 22
//StaticFunctions (come2play_as3.api.auto_copied.StaticFunctions)
package come2play_as3.api.auto_copied {
import flash.display.*;
import flash.utils.*;
import flash.system.*;
public final class StaticFunctions {
private static const REFLECTION_PREFIX:String = "REFLECTION_";
private static var cacheShortName:Object = {};
public static var DID_SHOW_ERROR:Boolean = false;
public static var ALLOW_DOMAINS:String = "*";
public static var someMovieClip:DisplayObjectContainer;
public static var allTraces:Array = [];
public static var SHOULD_CALL_TRACE:Boolean = true;
public static var MAX_TRACES_NUM:int = 50;
public static var SHOULD_SHOW_ERRORS:Boolean = true;
public function StaticFunctions(){
super();
}
public static function areEqual(o1:Object, o2:Object):Boolean{
var x:String;
var allFields:Object;
var c:int;
var fieldsArr:Array;
var field:String;
if (o1 === o2){
return (true);
};
if ((((o1 == null)) || ((o2 == null)))){
return (false);
};
var t = typeof(o1);
if (t != typeof(o2)){
return (false);
};
if (AS3_vs_AS2.getClassName(o1) != AS3_vs_AS2.getClassName(o2)){
return (false);
};
if (t == "object"){
allFields = {};
c = 0;
for (x in o1) {
allFields[x] = true;
c++;
};
for (x in o2) {
if (allFields[x] == null){
return (false);
};
c--;
};
if (c != 0){
return (false);
};
if (AS3_vs_AS2.isAS3){
fieldsArr = AS3_vs_AS2.getFieldNames(o1);
for each (field in fieldsArr) {
allFields[field] = true;
};
};
for (x in allFields) {
if (((((!(o1.hasOwnProperty(x))) || (!(o2.hasOwnProperty(x))))) || (!(areEqual(o1[x], o2[x]))))){
return (false);
};
};
return (true);
//unresolved jump
};
return ((o1 == o2));
}
public static function random(fromInclusive:int, toExclusive:int):int{
var delta:int = (toExclusive - fromInclusive);
return ((Math.floor((delta * Math.random())) + fromInclusive));
}
public static function getTraces():String{
return (((allTraces.length == 0)) ? "" : ((((allTraces.length < MAX_TRACES_NUM)) ? "All" : ("The last " + MAX_TRACES_NUM) + " stored traces are:\n") + allTraces.join("\n")));
}
public static function throwError(msg:String):void{
var err:Error = new Error(msg);
showError(("Throwing the following error=" + AS3_vs_AS2.error2String(err)));
throw (err);
}
public static function showError(msg:String):void{
if (DID_SHOW_ERROR){
return;
};
DID_SHOW_ERROR = true;
msg = ((((("An ERRRRRRRRRRROR occurred on time " + getTimer()) + ":\n") + msg) + "\n") + getTraces());
setClipboard(msg);
if (SHOULD_SHOW_ERRORS){
AS3_vs_AS2.showError(someMovieClip, msg);
};
if (SHOULD_CALL_TRACE){
trace((("\n\n\n" + msg) + "\n\n\n"));
};
}
public static function assert(val:Boolean, args:Array):void{
if (!val){
throwError(("An assertion failed with the following arguments=" + JSON.stringify(args)));
};
}
public static function performReflectionObject(fullClassName:String, valObj:Object):void{
var fieldName:String;
if (SHOULD_CALL_TRACE){
trace(((("Perform reflection for: " + fullClassName) + "=") + JSON.stringify(valObj)));
};
var package2:Array = splitInTwo(fullClassName, "::", false);
var fields2:Array = splitInTwo(package2[1], ".", false);
var clzName:String = ((trim(package2[0]) + "::") + trim(fields2[0]));
var fieldsName:String = trim(fields2[1]);
var classReference:Object = AS3_vs_AS2.getClassByName(clzName);
storeTrace(((((("Setting field " + fieldsName) + " in class ") + clzName) + " to val=") + valObj));
var fieldsArr:Array = fieldsName.split(".");
var i:int;
while (i < fieldsArr.length) {
fieldName = fieldsArr[i];
if (i < (fieldsArr.length - 1)){
classReference = classReference[fieldName];
} else {
classReference[fieldName] = valObj;
};
i++;
};
}
public static function setClipboard(msg:String):void{
var msg = msg;
System.setClipboard(msg);
//unresolved jump
var _slot1 = err;
}
public static function replaceAll(str:String, searchFor:String, replaceWith:String):String{
var index:int;
var lastIndex:int;
var res:Array = [];
while ((index = AS3_vs_AS2.stringIndexOf(str, searchFor, index)) != -1) {
res.push(str.substring(lastIndex, index));
res.push(replaceWith);
index = (index + searchFor.length);
lastIndex = index;
};
res.push(str.substring(lastIndex));
return (res.join(""));
}
public static function performReflectionString(fullClassName:String, valStr:String):void{
performReflectionObject(fullClassName, SerializableClass.deserializeString(valStr));
}
public static function instance2Object(instance:Object, fields:Array):Object{
var field:String;
var res:Object = {};
for each (field in fields) {
res[field] = instance[field];
};
return (res);
}
public static function storeTrace(obj:Object):void{
if (allTraces.length >= MAX_TRACES_NUM){
allTraces.shift();
};
var arr:Array = ["Time: ", getTimer(), " Trace: ", obj];
if (SHOULD_CALL_TRACE){
trace(arr.join(""));
};
allTraces.push(arr);
}
public static function subtractArray(arr:Array, minus:Array):Array{
var o:Object;
var indexOf:int;
var res:Array = arr.concat();
for each (o in minus) {
indexOf = AS3_vs_AS2.IndexOf(res, o);
StaticFunctions.assert(!((indexOf == -1)), ["When subtracting minus=", minus, " from array=", arr, " we did not find element ", o]);
res.splice(indexOf, 1);
};
return (res);
}
public static function allowDomains():void{
if (ALLOW_DOMAINS != null){
storeTrace(((("Allowing all domains access to : " + ALLOW_DOMAINS) + " saמdbox type :") + Security.sandboxType));
Security.allowDomain(ALLOW_DOMAINS);
};
}
public static function trim(str:String):String{
var j:int;
var strlen:int;
var k:int;
strlen = str.length;
j = 0;
while (isEmptyChar(str.charAt(j))) {
j++;
};
if (j > 0){
str = str.substring(j);
if (j == strlen){
return (str);
};
};
k = (str.length - 1);
while (isEmptyChar(str.charAt(k))) {
k--;
};
return (str.substring(0, (k + 1)));
}
public static function performReflection(reflStr:String):void{
var two:Array = splitInTwo(reflStr, "=", false);
performReflectionString(two[0], two[1]);
}
public static function endsWith(str:String, suffix:String):Boolean{
return ((str.substr((str.length - suffix.length), suffix.length) == suffix));
}
public static function replaceLastOccurance(str:String, searchFor:String, replaceWith:String):String{
var two:Array = splitInTwo(str, searchFor, true);
return (((two[0] + replaceWith) + two[1]));
}
public static function splitInTwo(str:String, searchFor:String, isLast:Boolean):Array{
var index:int = (isLast) ? AS3_vs_AS2.stringLastIndexOf(str, searchFor) : AS3_vs_AS2.stringIndexOf(str, searchFor);
if (index == -1){
showError(((("Did not find searchFor=" + searchFor) + " in string=") + str));
};
return ([str.substring(0, index), str.substring((index + searchFor.length))]);
}
public static function startsWith(str:String, start:String):Boolean{
return ((str.substr(0, start.length) == start));
}
public static function isEmptyChar(str:String):Boolean{
return ((((((((str == " ")) || ((str == "\n")))) || ((str == "\t")))) || ((str == "\r"))));
}
public static function getShortClassName(obj:Object):String{
var className:String = AS3_vs_AS2.getClassName(obj);
if (cacheShortName[className] != null){
return (cacheShortName[className]);
};
var res:String = className.substr((AS3_vs_AS2.stringIndexOf(className, "::") + 2));
cacheShortName[className] = res;
return (res);
}
public static function performReflectionFromFlashVars(_someMovieClip:DisplayObjectContainer):void{
var key:String;
var before:String;
var after:String;
var parameters:Object = AS3_vs_AS2.getLoaderInfoParameters(_someMovieClip);
if (SHOULD_CALL_TRACE){
trace(("performReflectionFromFlashVars=" + JSON.stringify(parameters)));
};
for (key in parameters) {
if (startsWith(key, REFLECTION_PREFIX)){
before = key.substr(REFLECTION_PREFIX.length);
after = parameters[key];
performReflectionString(before, after);
};
};
}
}
}//package come2play_as3.api.auto_copied
Section 23
//T (come2play_as3.api.auto_copied.T)
package come2play_as3.api.auto_copied {
public final class T {
private var arr:Array;
public static var isLeftToRight:Boolean = true;
private static var _custom:Object = {};
private static var _dictionary:Object = {};
private static var _usersInfo:Object = {};
public function T(){
super();
arr = [];
}
public function add(str:String):void{
if (isLeftToRight){
arr.push(str);
} else {
arr.unshift(str);
};
}
public function join():String{
return (arr.join(""));
}
public static function getCustom():Object{
return (_custom);
}
public static function isSameType(res:Object, defaultValue:Object):void{
if ((((defaultValue == null)) || ((res == null)))){
return;
};
var typeD:String = AS3_vs_AS2.getClassName(defaultValue);
var typeR:String = AS3_vs_AS2.getClassName(res);
StaticFunctions.assert((typeD == typeR), ["In T.custom and the T.getUserValue the type of defaultValue and the return value must be identical! DefaultValue=", defaultValue, " type of DefaultValue=", typeD, " result=", res, " type of result=", typeR]);
}
public static function initI18n(dictionary:Object, custom:Object):void{
var key:String;
for (key in dictionary) {
_dictionary[key] = dictionary[key];
};
for (key in custom) {
_custom[key] = custom[key];
};
}
public static function updateUser(userId:int, userObject:Object):void{
var str:String;
var currentUser:Object = _usersInfo[userId];
if (currentUser == null){
_usersInfo[userId] = userObject;
} else {
for (str in userObject) {
currentUser[str] = userObject[str];
};
};
}
public static function i18nReplace(str:String, replacement:Object):String{
var key:String;
var res:String = i18n(str);
for (key in replacement) {
res = StaticFunctions.replaceAll(res, (("$" + key) + "$"), ("" + replacement[key]));
};
return (res);
}
public static function custom(key:String, defaultValue:Object):Object{
var res:Object = _custom[key];
if (res == null){
return (defaultValue);
};
isSameType(res, defaultValue);
return (res);
}
public static function i18n(str:String):String{
var res:Object = _dictionary[str];
return (((res == null)) ? str : res.toString());
}
public static function getUserValue(userId:int, key:String, defaultValue:Object):Object{
var userInfo:Object = _usersInfo[userId];
if (userInfo == null){
return (defaultValue);
};
var res:Object = userInfo[key];
if (res == null){
return (defaultValue);
};
isSameType(res, defaultValue);
return (res);
}
}
}//package come2play_as3.api.auto_copied
Section 24
//XMLSerializer (come2play_as3.api.auto_copied.XMLSerializer)
package come2play_as3.api.auto_copied {
public final class XMLSerializer {
private static var RESERVED_NAMES:Object = {nullName:"null", num:"num", bool:"bool", str:"str", arr:"arr", obj:"obj"};
public function XMLSerializer(){
super();
}
public static function isReserved(s:String):Boolean{
var str:String;
for each (str in RESERVED_NAMES) {
if (s == str){
return (true);
};
};
return (false);
}
public static function test():void{
var test:Object = [1, 2, "c", true, null, -4, "<&&boo>", {a:null, x:new SerializableClass(), b:["", "b"]}];
var xml:XML = XMLSerializer.toXML(test);
var test2:Object = SerializableClass.deserialize(XMLSerializer.xml2Object(xml));
trace(((("XMLSerializer xml=\n" + xml) + " test2=") + JSON.stringify(test2)));
StaticFunctions.assert(StaticFunctions.areEqual(test, test2), [test, test2]);
}
public static function toString(arg:Object):String{
var res:Array = [];
p_toString("", res, arg);
return (res.join(""));
}
public static function escapeXML(str:String):String{
return (StaticFunctions.replaceAll(StaticFunctions.replaceAll(StaticFunctions.replaceAll(str, "&", "&"), "<", "<"), ">", ">"));
}
public static function xml2Object(xml:XML):Object{
var simpleContent:String;
var arr:Array;
var child2:XML;
var obj:Object;
var child:XML;
var singleGrandChild:Array;
var name:String = AS3_vs_AS2.xml_getName(xml);
if (name == RESERVED_NAMES.nullName){
return (null);
};
if ((((((name == RESERVED_NAMES.num)) || ((name == RESERVED_NAMES.bool)))) || ((name == RESERVED_NAMES.str)))){
simpleContent = AS3_vs_AS2.xml_getSimpleContent(xml);
if (name == RESERVED_NAMES.num){
return (Number(simpleContent));
};
if (name == RESERVED_NAMES.bool){
return (Boolean(simpleContent));
};
return (simpleContent);
};
var children:Array = AS3_vs_AS2.xml_getChildren(xml);
if (name == RESERVED_NAMES.arr){
arr = [];
for each (child2 in children) {
arr.push(xml2Object(child2));
};
return (arr);
//unresolved jump
};
obj = {};
if (name != RESERVED_NAMES.obj){
obj[SerializableClass.CLASS_NAME_FIELD] = name;
};
for each (child in children) {
singleGrandChild = AS3_vs_AS2.xml_getChildren(child);
StaticFunctions.assert((singleGrandChild.length == 1), ["A field should have a single value! Illegal child=", child]);
obj[AS3_vs_AS2.xml_getName(child)] = xml2Object(singleGrandChild[0]);
};
return (obj);
}
private static function p_toString(indentStr:String, res:Array, arg:Object):void{
var i:int;
var serObj:SerializableClass;
var simpleContent:String;
var childKey:String;
var esc:String;
var elementType:String = ((arg == null)) ? RESERVED_NAMES.nullName : (AS3_vs_AS2.isNumber(arg)) ? RESERVED_NAMES.num : (AS3_vs_AS2.isBoolean(arg)) ? RESERVED_NAMES.bool : (AS3_vs_AS2.isString(arg)) ? RESERVED_NAMES.str : null;
var childrenKeys:Array;
var isArr:Boolean = AS3_vs_AS2.isArray(arg);
if (elementType == null){
if (isArr){
elementType = RESERVED_NAMES.arr;
childrenKeys = [];
i = 0;
while (i < arg.length) {
childrenKeys.push(i);
i++;
};
} else {
serObj = (AS3_vs_AS2.isSerializableClass(arg)) ? AS3_vs_AS2.asSerializableClass(arg) : null;
elementType = ((serObj == null)) ? RESERVED_NAMES.obj : serObj.__CLASS_NAME__;
childrenKeys = ((serObj)!=null) ? serObj.getFieldNames() : JSON.getSortedKeys(arg);
if (serObj != null){
childrenKeys.sort();
};
};
};
StaticFunctions.assert(!((elementType == null)), ["Internal error! missing elementType"]);
if (childrenKeys == null){
simpleContent = ((arg == null)) ? "" : escapeXML(arg.toString());
res.push(((indentStr + ((simpleContent == "")) ? (("<" + elementType) + "/>") : (((((("<" + elementType) + ">") + simpleContent) + "</") + elementType) + ">")) + "\n"));
} else {
res.push((((indentStr + "<") + elementType) + ">\n"));
for each (childKey in childrenKeys) {
if (!isArr){
esc = escapeXML(childKey);
res.push((((indentStr + "\t<") + esc) + ">\n"));
};
p_toString((indentStr + (isArr) ? "\t" : "\t\t"), res, arg[childKey]);
if (!isArr){
res.push((((indentStr + "\t</") + esc) + ">\n"));
};
};
res.push((((indentStr + "</") + elementType) + ">\n"));
};
}
public static function toXML(arg:Object):XML{
return (AS3_vs_AS2.xml_create(toString(arg)));
}
}
}//package come2play_as3.api.auto_copied
Section 25
//API_DoAllEndMatch (come2play_as3.api.auto_generated.API_DoAllEndMatch)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllEndMatch extends API_Message {
public var finishedPlayers:Array;
public function API_DoAllEndMatch(){
super();
}
override public function getMethodParameters():Array{
return ([finishedPlayers]);
}
override public function getMethodName():String{
return ("doAllEndMatch");
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-116);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.finishedPlayers = parameters[_temp1];
}
public static function create(finishedPlayers:Array):API_DoAllEndMatch{
var res:API_DoAllEndMatch = new (API_DoAllEndMatch);
res.finishedPlayers = finishedPlayers;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 26
//API_DoAllFoundHacker (come2play_as3.api.auto_generated.API_DoAllFoundHacker)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllFoundHacker extends API_Message {
public var errorDescription:String;
public var userId:int;
public function API_DoAllFoundHacker(){
super();
}
override public function getMethodParameters():Array{
return ([userId, errorDescription]);
}
override public function getMethodName():String{
return ("doAllFoundHacker");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getFunctionId():int{
return (-111);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.userId = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.errorDescription = parameters[_temp2];
}
public static function create(userId:int, errorDescription:String):API_DoAllFoundHacker{
var res:API_DoAllFoundHacker = new (API_DoAllFoundHacker);
res.userId = userId;
res.errorDescription = errorDescription;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 27
//API_DoAllRequestRandomState (come2play_as3.api.auto_generated.API_DoAllRequestRandomState)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllRequestRandomState extends API_Message {
public var isSecret:Boolean;
public var key:Object;
public function API_DoAllRequestRandomState(){
super();
}
override public function getMethodParameters():Array{
return ([key, isSecret]);
}
override public function getMethodName():String{
return ("doAllRequestRandomState");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getFunctionId():int{
return (-112);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.key = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.isSecret = parameters[_temp2];
}
public static function create(key:Object, isSecret:Boolean=false):API_DoAllRequestRandomState{
var res:API_DoAllRequestRandomState = new (API_DoAllRequestRandomState);
res.key = key;
res.isSecret = isSecret;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 28
//API_DoAllRequestStateCalculation (come2play_as3.api.auto_generated.API_DoAllRequestStateCalculation)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllRequestStateCalculation extends API_Message {
public var keys:Array;
public function API_DoAllRequestStateCalculation(){
super();
}
override public function getMethodParameters():Array{
return ([keys]);
}
override public function getMethodName():String{
return ("doAllRequestStateCalculation");
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-110);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.keys = parameters[_temp1];
}
public static function create(keys:Array):API_DoAllRequestStateCalculation{
var res:API_DoAllRequestStateCalculation = new (API_DoAllRequestStateCalculation);
res.keys = keys;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 29
//API_DoAllRevealState (come2play_as3.api.auto_generated.API_DoAllRevealState)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllRevealState extends API_Message {
public var revealEntries:Array;
public function API_DoAllRevealState(){
super();
}
override public function getMethodParameters():Array{
return ([revealEntries]);
}
override public function getMethodName():String{
return ("doAllRevealState");
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-114);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.revealEntries = parameters[_temp1];
}
public static function create(revealEntries:Array):API_DoAllRevealState{
var res:API_DoAllRevealState = new (API_DoAllRevealState);
res.revealEntries = revealEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 30
//API_DoAllSetMove (come2play_as3.api.auto_generated.API_DoAllSetMove)
package come2play_as3.api.auto_generated {
public class API_DoAllSetMove extends API_Message {
public function API_DoAllSetMove(){
super();
}
override public function getMethodParameters():Array{
return ([]);
}
override public function getMethodName():String{
return ("doAllSetMove");
}
override public function getMethodParametersNum():int{
return (0);
}
override public function getFunctionId():int{
return (8);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
}
public static function create():API_DoAllSetMove{
var res:API_DoAllSetMove = new (API_DoAllSetMove);
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 31
//API_DoAllSetTurn (come2play_as3.api.auto_generated.API_DoAllSetTurn)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllSetTurn extends API_Message {
public var milliSecondsInTurn:int;
public var userId:int;
public function API_DoAllSetTurn(){
super();
}
override public function getMethodParameters():Array{
return ([userId, milliSecondsInTurn]);
}
override public function getMethodName():String{
return ("doAllSetTurn");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getFunctionId():int{
return (-115);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.userId = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.milliSecondsInTurn = parameters[_temp2];
}
public static function create(userId:int, milliSecondsInTurn:int=-1):API_DoAllSetTurn{
var res:API_DoAllSetTurn = new (API_DoAllSetTurn);
res.userId = userId;
res.milliSecondsInTurn = milliSecondsInTurn;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 32
//API_DoAllShuffleState (come2play_as3.api.auto_generated.API_DoAllShuffleState)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllShuffleState extends API_Message {
public var keys:Array;
public function API_DoAllShuffleState(){
super();
}
override public function getMethodParameters():Array{
return ([keys]);
}
override public function getMethodName():String{
return ("doAllShuffleState");
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-113);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.keys = parameters[_temp1];
}
public static function create(keys:Array):API_DoAllShuffleState{
var res:API_DoAllShuffleState = new (API_DoAllShuffleState);
res.keys = keys;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 33
//API_DoAllStoreState (come2play_as3.api.auto_generated.API_DoAllStoreState)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllStoreState extends API_Message {
public var userEntries:Array;
public function API_DoAllStoreState(){
super();
}
override public function getMethodParameters():Array{
return ([userEntries]);
}
override public function getMethodName():String{
return ("doAllStoreState");
}
override public function getFunctionId():int{
return (-117);
}
override public function getMethodParametersNum():int{
return (1);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.userEntries = parameters[_temp1];
}
public static function create(userEntries:Array):API_DoAllStoreState{
var res:API_DoAllStoreState = new (API_DoAllStoreState);
res.userEntries = userEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 34
//API_DoAllStoreStateCalculation (come2play_as3.api.auto_generated.API_DoAllStoreStateCalculation)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoAllStoreStateCalculation extends API_Message {
public var requestId:int;
public var userEntries:Array;
public function API_DoAllStoreStateCalculation(){
super();
}
override public function getMethodName():String{
return ("doAllStoreStateCalculation");
}
override public function getMethodParameters():Array{
return ([requestId, userEntries]);
}
override public function getFunctionId():int{
return (-108);
}
override public function getMethodParametersNum():int{
return (2);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.requestId = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.userEntries = parameters[_temp2];
}
public static function create(requestId:int, userEntries:Array):API_DoAllStoreStateCalculation{
var res:API_DoAllStoreStateCalculation = new (API_DoAllStoreStateCalculation);
res.requestId = requestId;
res.userEntries = userEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 35
//API_DoConnectedEndMatch (come2play_as3.api.auto_generated.API_DoConnectedEndMatch)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoConnectedEndMatch extends API_Message {
public var didWin:Boolean;
public function API_DoConnectedEndMatch(){
super();
}
override public function getMethodParameters():Array{
return ([didWin]);
}
override public function getMethodName():String{
return ("doConnectedEndMatch");
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-106);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.didWin = parameters[_temp1];
}
public static function create(didWin:Boolean):API_DoConnectedEndMatch{
var res:API_DoConnectedEndMatch = new (API_DoConnectedEndMatch);
res.didWin = didWin;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 36
//API_DoConnectedSetScore (come2play_as3.api.auto_generated.API_DoConnectedSetScore)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoConnectedSetScore extends API_Message {
public var score:int;
public function API_DoConnectedSetScore(){
super();
}
override public function getMethodParameters():Array{
return ([score]);
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-107);
}
override public function getMethodName():String{
return ("doConnectedSetScore");
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.score = parameters[_temp1];
}
public static function create(score:int):API_DoConnectedSetScore{
var res:API_DoConnectedSetScore = new (API_DoConnectedSetScore);
res.score = score;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 37
//API_DoFinishedCallback (come2play_as3.api.auto_generated.API_DoFinishedCallback)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoFinishedCallback extends API_Message {
public var callbackName:String;
public var msgNum:int;
public function API_DoFinishedCallback(){
super();
}
override public function getMethodParameters():Array{
return ([callbackName, msgNum]);
}
override public function getMethodName():String{
return ("doFinishedCallback");
}
override public function getFunctionId():int{
return (-128);
}
override public function getMethodParametersNum():int{
return (2);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.callbackName = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.msgNum = parameters[_temp2];
}
public static function create(callbackName:String, msgNum:int):API_DoFinishedCallback{
var res:API_DoFinishedCallback = new (API_DoFinishedCallback);
res.callbackName = callbackName;
res.msgNum = msgNum;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 38
//API_DoRegisterOnServer (come2play_as3.api.auto_generated.API_DoRegisterOnServer)
package come2play_as3.api.auto_generated {
public class API_DoRegisterOnServer extends API_Message {
public function API_DoRegisterOnServer(){
super();
}
override public function getMethodParameters():Array{
return ([]);
}
override public function getMethodName():String{
return ("doRegisterOnServer");
}
override public function getMethodParametersNum():int{
return (0);
}
override public function getFunctionId():int{
return (-127);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
}
public static function create():API_DoRegisterOnServer{
var res:API_DoRegisterOnServer = new (API_DoRegisterOnServer);
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 39
//API_DoStoreState (come2play_as3.api.auto_generated.API_DoStoreState)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoStoreState extends API_Message {
public var revealEntries:Array;
public var userEntries:Array;
public function API_DoStoreState(){
super();
}
override public function getMethodParameters():Array{
return ([userEntries, revealEntries]);
}
override public function getMethodName():String{
return ("doStoreState");
}
override public function getFunctionId():int{
return (-118);
}
override public function getMethodParametersNum():int{
return (2);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.userEntries = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.revealEntries = parameters[_temp2];
}
public static function create(userEntries:Array, revealEntries:Array=null):API_DoStoreState{
var res:API_DoStoreState = new (API_DoStoreState);
res.userEntries = userEntries;
res.revealEntries = revealEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 40
//API_DoTrace (come2play_as3.api.auto_generated.API_DoTrace)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_DoTrace extends API_Message {
public var message:Object;
public var name:String;
public function API_DoTrace(){
super();
}
override public function getMethodParameters():Array{
return ([name, message]);
}
override public function getMethodName():String{
return ("doTrace");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getFunctionId():int{
return (-126);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.name = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.message = parameters[_temp2];
}
public static function create(name:String, message:Object):API_DoTrace{
var res:API_DoTrace = new (API_DoTrace);
res.name = name;
res.message = message;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 41
//API_GotCustomInfo (come2play_as3.api.auto_generated.API_GotCustomInfo)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotCustomInfo extends API_Message {
public var infoEntries:Array;
public function API_GotCustomInfo(){
super();
}
override public function getMethodParameters():Array{
return ([infoEntries]);
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-124);
}
override public function getMethodName():String{
return ("gotCustomInfo");
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.infoEntries = parameters[_temp1];
}
public static function create(infoEntries:Array):API_GotCustomInfo{
var res:API_GotCustomInfo = new (API_GotCustomInfo);
res.infoEntries = infoEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 42
//API_GotKeyboardEvent (come2play_as3.api.auto_generated.API_GotKeyboardEvent)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotKeyboardEvent extends API_Message {
public var charCode:int;
public var keyCode:int;
public var ctrlKey:Boolean;
public var altKey:Boolean;
public var isKeyDown:Boolean;
public var keyLocation:int;
public var shiftKey:Boolean;
public function API_GotKeyboardEvent(){
super();
}
override public function getMethodParameters():Array{
return ([isKeyDown, charCode, keyCode, keyLocation, altKey, ctrlKey, shiftKey]);
}
override public function getMethodName():String{
return ("gotKeyboardEvent");
}
override public function getMethodParametersNum():int{
return (7);
}
override public function getFunctionId():int{
return (-125);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.isKeyDown = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.charCode = parameters[_temp2];
var _temp3 = pos;
pos = (pos + 1);
this.keyCode = parameters[_temp3];
var _temp4 = pos;
pos = (pos + 1);
this.keyLocation = parameters[_temp4];
var _temp5 = pos;
pos = (pos + 1);
this.altKey = parameters[_temp5];
var _temp6 = pos;
pos = (pos + 1);
this.ctrlKey = parameters[_temp6];
var _temp7 = pos;
pos = (pos + 1);
this.shiftKey = parameters[_temp7];
}
public static function create(isKeyDown:Boolean, charCode:int, keyCode:int, keyLocation:int, altKey:Boolean, ctrlKey:Boolean, shiftKey:Boolean):API_GotKeyboardEvent{
var res:API_GotKeyboardEvent = new (API_GotKeyboardEvent);
res.isKeyDown = isKeyDown;
res.charCode = charCode;
res.keyCode = keyCode;
res.keyLocation = keyLocation;
res.altKey = altKey;
res.ctrlKey = ctrlKey;
res.shiftKey = shiftKey;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 43
//API_GotMatchEnded (come2play_as3.api.auto_generated.API_GotMatchEnded)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotMatchEnded extends API_Message {
public var finishedPlayerIds:Array;
public var msgNum:int;
public function API_GotMatchEnded(){
super();
}
override public function getMethodName():String{
return ("gotMatchEnded");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getMethodParameters():Array{
return ([msgNum, finishedPlayerIds]);
}
override public function getFunctionId():int{
return (-120);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.msgNum = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.finishedPlayerIds = parameters[_temp2];
}
public static function create(msgNum:int, finishedPlayerIds:Array):API_GotMatchEnded{
var res:API_GotMatchEnded = new (API_GotMatchEnded);
res.msgNum = msgNum;
res.finishedPlayerIds = finishedPlayerIds;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 44
//API_GotMatchStarted (come2play_as3.api.auto_generated.API_GotMatchStarted)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotMatchStarted extends API_Message {
public var finishedPlayerIds:Array;
public var msgNum:int;
public var serverEntries:Array;
public var allPlayerIds:Array;
public function API_GotMatchStarted(){
super();
}
override public function getMethodParameters():Array{
return ([msgNum, allPlayerIds, finishedPlayerIds, serverEntries]);
}
override public function getMethodName():String{
return ("gotMatchStarted");
}
override public function getFunctionId():int{
return (-121);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.msgNum = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.allPlayerIds = parameters[_temp2];
var _temp3 = pos;
pos = (pos + 1);
this.finishedPlayerIds = parameters[_temp3];
var _temp4 = pos;
pos = (pos + 1);
this.serverEntries = parameters[_temp4];
}
override public function getMethodParametersNum():int{
return (4);
}
public static function create(msgNum:int, allPlayerIds:Array, finishedPlayerIds:Array, serverEntries:Array):API_GotMatchStarted{
var res:API_GotMatchStarted = new (API_GotMatchStarted);
res.msgNum = msgNum;
res.allPlayerIds = allPlayerIds;
res.finishedPlayerIds = finishedPlayerIds;
res.serverEntries = serverEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 45
//API_GotRequestStateCalculation (come2play_as3.api.auto_generated.API_GotRequestStateCalculation)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotRequestStateCalculation extends API_Message {
public var requestId:int;
public var serverEntries:Array;
public function API_GotRequestStateCalculation(){
super();
}
override public function getMethodName():String{
return ("gotRequestStateCalculation");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getMethodParameters():Array{
return ([requestId, serverEntries]);
}
override public function getFunctionId():int{
return (-109);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.requestId = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.serverEntries = parameters[_temp2];
}
public static function create(requestId:int, serverEntries:Array):API_GotRequestStateCalculation{
var res:API_GotRequestStateCalculation = new (API_GotRequestStateCalculation);
res.requestId = requestId;
res.serverEntries = serverEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 46
//API_GotStateChanged (come2play_as3.api.auto_generated.API_GotStateChanged)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotStateChanged extends API_Message {
public var msgNum:int;
public var serverEntries:Array;
public function API_GotStateChanged(){
super();
}
override public function getMethodName():String{
return ("gotStateChanged");
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.msgNum = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.serverEntries = parameters[_temp2];
}
override public function getMethodParameters():Array{
return ([msgNum, serverEntries]);
}
override public function getFunctionId():int{
return (-119);
}
override public function getMethodParametersNum():int{
return (2);
}
public static function create(msgNum:int, serverEntries:Array):API_GotStateChanged{
var res:API_GotStateChanged = new (API_GotStateChanged);
res.msgNum = msgNum;
res.serverEntries = serverEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 47
//API_GotUserDisconnected (come2play_as3.api.auto_generated.API_GotUserDisconnected)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotUserDisconnected extends API_Message {
public var userId:int;
public function API_GotUserDisconnected(){
super();
}
override public function getMethodParameters():Array{
return ([userId]);
}
override public function getMethodName():String{
return ("gotUserDisconnected");
}
override public function getMethodParametersNum():int{
return (1);
}
override public function getFunctionId():int{
return (-122);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.userId = parameters[_temp1];
}
public static function create(userId:int):API_GotUserDisconnected{
var res:API_GotUserDisconnected = new (API_GotUserDisconnected);
res.userId = userId;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 48
//API_GotUserInfo (come2play_as3.api.auto_generated.API_GotUserInfo)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_GotUserInfo extends API_Message {
public var infoEntries:Array;
public var userId:int;
public function API_GotUserInfo(){
super();
}
override public function getMethodName():String{
return ("gotUserInfo");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getMethodParameters():Array{
return ([userId, infoEntries]);
}
override public function getFunctionId():int{
return (-123);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.userId = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.infoEntries = parameters[_temp2];
}
public static function create(userId:int, infoEntries:Array):API_GotUserInfo{
var res:API_GotUserInfo = new (API_GotUserInfo);
res.userId = userId;
res.infoEntries = infoEntries;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 49
//API_LoadMessages (come2play_as3.api.auto_generated.API_LoadMessages)
package come2play_as3.api.auto_generated {
public class API_LoadMessages {
public function API_LoadMessages(){
super();
}
public static function useAll():void{
new API_DoFinishedCallback().register();
new API_DoRegisterOnServer().register();
new API_DoTrace().register();
new API_GotKeyboardEvent().register();
new API_GotCustomInfo().register();
new API_GotUserInfo().register();
new API_GotUserDisconnected().register();
new API_GotMatchStarted().register();
new API_GotMatchEnded().register();
new API_GotStateChanged().register();
new API_DoStoreState().register();
new API_DoAllStoreState().register();
new API_DoAllEndMatch().register();
new API_DoAllSetTurn().register();
new API_DoAllSetMove().register();
new API_DoAllRevealState().register();
new API_DoAllShuffleState().register();
new API_DoAllRequestRandomState().register();
new API_DoAllFoundHacker().register();
new API_DoAllRequestStateCalculation().register();
new API_GotRequestStateCalculation().register();
new API_DoAllStoreStateCalculation().register();
new API_DoConnectedSetScore().register();
new API_DoConnectedEndMatch().register();
new PlayerMatchOver().register();
new InfoEntry().register();
new RevealEntry().register();
new UserEntry().register();
new ServerEntry().register();
new HistoryEntry().register();
new API_Transaction().register();
}
}
}//package come2play_as3.api.auto_generated
Section 50
//API_Message (come2play_as3.api.auto_generated.API_Message)
package come2play_as3.api.auto_generated {
import come2play_as3.api.auto_copied.*;
public class API_Message extends SerializableClass {
public static const CUSTOM_INFO_KEY_isPause:String = "CONTAINER_isPause";
public static const CUSTOM_INFO_KEY_secondsPerMatch:String = "CONTAINER_secondsPerMatch";
public static const USER_INFO_KEY_avatar_url:String = "avatar_url";
public static const USER_INFO_KEY_credibility:String = "credibility";
public static const USER_INFO_KEY_name:String = "name";
public static const CUSTOM_INFO_KEY_isBack:String = "CONTAINER_isBack";
public static const CUSTOM_INFO_KEY_reflection:String = "CONTAINER_reflection";
public static const CUSTOM_INFO_KEY_gameStageX:String = "CONTAINER_gameStageX";
public static const CUSTOM_INFO_KEY_gameStageY:String = "CONTAINER_gameStageY";
public static const CUSTOM_INFO_KEY_gameFrameRate:String = "CONTAINER_gameFrameRate";
public static const CUSTOM_INFO_KEY_i18n:String = "CONTAINER_i18n";
public static const CUSTOM_INFO_KEY_gameHeight:String = "CONTAINER_gameHeight";
public static const USER_INFO_KEY_supervisor:String = "supervisor";
public static const USER_INFO_KEY_game_rating:String = "game_rating";
public static const CUSTOM_INFO_KEY_gameWidth:String = "CONTAINER_gameWidth";
public static const CUSTOM_INFO_KEY_logoFullUrl:String = "CONTAINER_logoFullUrl";
public static const CUSTOM_INFO_KEY_myUserId:String = "CONTAINER_myUserId";
public static const CUSTOM_INFO_KEY_secondsPerMove:String = "CONTAINER_secondsPerMove";
public static const CUSTOM_INFO_KEY_checkThrowingAnError:String = "CONTAINER_checkThrowingAnError";
public static const CUSTOM_INFO_KEY_isFocusInChat:String = "CONTAINER_isFocusInChat";
public function API_Message(){
super();
}
public function getMethodParameters():Array{
throw (new Error("You must subclass API_Message!"));
}
public function getMethodName():String{
throw (new Error("You must subclass API_Message!"));
}
public function getMethodParametersNum():int{
throw (new Error("You must subclass API_Message!"));
}
public function getFunctionId():int{
throw (new Error("You must subclass API_Message!"));
}
public function setMethodParameters(parameters:Array):void{
throw (new Error("You must subclass API_Message!"));
}
}
}//package come2play_as3.api.auto_generated
Section 51
//API_Transaction (come2play_as3.api.auto_generated.API_Transaction)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class API_Transaction extends API_Message {
public var callback:API_DoFinishedCallback;
public var messages:Array;
public function API_Transaction(){
super();
}
override public function getMethodParameters():Array{
return ([callback, messages]);
}
override public function getMethodName():String{
return ("aPI_Transaction");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getFunctionId():int{
return (-84);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.callback = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.messages = parameters[_temp2];
}
public static function create(callback:API_DoFinishedCallback, messages:Array):API_Transaction{
var res:API_Transaction = new (API_Transaction);
res.callback = callback;
res.messages = messages;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 52
//ClientGameAPI (come2play_as3.api.auto_generated.ClientGameAPI)
package come2play_as3.api.auto_generated {
import flash.display.*;
import come2play_as3.api.*;
public class ClientGameAPI extends BaseGameAPI {
public static const CUSTOM_INFO_KEY_isPause:String = "CONTAINER_isPause";
public static const CUSTOM_INFO_KEY_secondsPerMatch:String = "CONTAINER_secondsPerMatch";
public static const USER_INFO_KEY_avatar_url:String = "avatar_url";
public static const USER_INFO_KEY_credibility:String = "credibility";
public static const USER_INFO_KEY_name:String = "name";
public static const CUSTOM_INFO_KEY_isBack:String = "CONTAINER_isBack";
public static const CUSTOM_INFO_KEY_reflection:String = "CONTAINER_reflection";
public static const CUSTOM_INFO_KEY_gameStageX:String = "CONTAINER_gameStageX";
public static const CUSTOM_INFO_KEY_gameStageY:String = "CONTAINER_gameStageY";
public static const CUSTOM_INFO_KEY_gameFrameRate:String = "CONTAINER_gameFrameRate";
public static const CUSTOM_INFO_KEY_i18n:String = "CONTAINER_i18n";
public static const CUSTOM_INFO_KEY_gameHeight:String = "CONTAINER_gameHeight";
public static const USER_INFO_KEY_supervisor:String = "supervisor";
public static const USER_INFO_KEY_game_rating:String = "game_rating";
public static const CUSTOM_INFO_KEY_gameWidth:String = "CONTAINER_gameWidth";
public static const CUSTOM_INFO_KEY_logoFullUrl:String = "CONTAINER_logoFullUrl";
public static const CUSTOM_INFO_KEY_myUserId:String = "CONTAINER_myUserId";
public static const CUSTOM_INFO_KEY_secondsPerMove:String = "CONTAINER_secondsPerMove";
public static const CUSTOM_INFO_KEY_checkThrowingAnError:String = "CONTAINER_checkThrowingAnError";
public static const CUSTOM_INFO_KEY_isFocusInChat:String = "CONTAINER_isFocusInChat";
public function ClientGameAPI(someMovieClip:DisplayObjectContainer){
super(someMovieClip);
}
public function doAllEndMatch(finishedPlayers:Array):void{
sendMessage(API_DoAllEndMatch.create(finishedPlayers));
}
public function gotMatchEnded(finishedPlayerIds:Array):void{
}
public function gotRequestStateCalculation(requestId:int, serverEntries:Array):void{
}
public function doAllStoreStateCalculation(requestId:int, userEntries:Array):void{
sendMessage(API_DoAllStoreStateCalculation.create(requestId, userEntries));
}
public function gotUserInfo(userId:int, infoEntries:Array):void{
}
public function doAllStoreState(userEntries:Array):void{
sendMessage(API_DoAllStoreState.create(userEntries));
}
public function gotKeyboardEvent(isKeyDown:Boolean, charCode:int, keyCode:int, keyLocation:int, altKey:Boolean, ctrlKey:Boolean, shiftKey:Boolean):void{
}
public function gotMatchStarted(allPlayerIds:Array, finishedPlayerIds:Array, serverEntries:Array):void{
}
public function doAllSetTurn(userId:int, milliSecondsInTurn:int=-1):void{
sendMessage(API_DoAllSetTurn.create(userId, milliSecondsInTurn));
}
public function gotCustomInfo(infoEntries:Array):void{
}
public function doAllFoundHacker(userId:int, errorDescription:String):void{
sendMessage(API_DoAllFoundHacker.create(userId, errorDescription));
}
public function doAllRevealState(revealEntries:Array):void{
sendMessage(API_DoAllRevealState.create(revealEntries));
}
public function gotStateChanged(serverEntries:Array):void{
}
public function doRegisterOnServer():void{
sendMessage(API_DoRegisterOnServer.create());
}
public function doAllRequestStateCalculation(keys:Array):void{
sendMessage(API_DoAllRequestStateCalculation.create(keys));
}
public function gotUserDisconnected(userId:int):void{
}
public function doAllShuffleState(keys:Array):void{
sendMessage(API_DoAllShuffleState.create(keys));
}
public function doTrace(name:String, message:Object):void{
sendMessage(API_DoTrace.create(name, message));
}
public function doStoreState(userEntries:Array, revealEntries:Array=null):void{
sendMessage(API_DoStoreState.create(userEntries, revealEntries));
}
public function doAllRequestRandomState(key:Object, isSecret:Boolean=false):void{
sendMessage(API_DoAllRequestRandomState.create(key, isSecret));
}
public function doAllSetMove():void{
sendMessage(API_DoAllSetMove.create());
}
}
}//package come2play_as3.api.auto_generated
Section 53
//HistoryEntry (come2play_as3.api.auto_generated.HistoryEntry)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class HistoryEntry extends API_Message {
public var gotTimeInMilliSeconds:int;
public var message:API_Message;
public function HistoryEntry(){
super();
}
override public function getMethodParameters():Array{
return ([message, gotTimeInMilliSeconds]);
}
override public function getMethodName():String{
return ("historyEntry");
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getFunctionId():int{
return (-85);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.message = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.gotTimeInMilliSeconds = parameters[_temp2];
}
public static function create(message:API_Message, gotTimeInMilliSeconds:int):HistoryEntry{
var res:HistoryEntry = new (HistoryEntry);
res.message = message;
res.gotTimeInMilliSeconds = gotTimeInMilliSeconds;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 54
//InfoEntry (come2play_as3.api.auto_generated.InfoEntry)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class InfoEntry extends API_Message {
public var value:Object;
public var key:String;
public function InfoEntry(){
super();
}
override public function getMethodParametersNum():int{
return (2);
}
override public function getMethodParameters():Array{
return ([key, value]);
}
override public function getFunctionId():int{
return (-89);
}
override public function getMethodName():String{
return ("infoEntry");
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.key = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.value = parameters[_temp2];
}
public static function create(key:String, value:Object):InfoEntry{
var res:InfoEntry = new (InfoEntry);
res.key = key;
res.value = value;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 55
//PlayerMatchOver (come2play_as3.api.auto_generated.PlayerMatchOver)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class PlayerMatchOver extends API_Message {
public var potPercentage:int;
public var score:int;
public var playerId:int;
public function PlayerMatchOver(){
super();
}
override public function getMethodParameters():Array{
return ([playerId, score, potPercentage]);
}
override public function getMethodName():String{
return ("playerMatchOver");
}
override public function getMethodParametersNum():int{
return (3);
}
override public function getFunctionId():int{
return (-90);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.playerId = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.score = parameters[_temp2];
var _temp3 = pos;
pos = (pos + 1);
this.potPercentage = parameters[_temp3];
}
public static function create(playerId:int, score:int, potPercentage:int):PlayerMatchOver{
var res:PlayerMatchOver = new (PlayerMatchOver);
res.playerId = playerId;
res.score = score;
res.potPercentage = potPercentage;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 56
//RevealEntry (come2play_as3.api.auto_generated.RevealEntry)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class RevealEntry extends API_Message {
public var depth:int;
public var userIds:Array;
public var key;
public function RevealEntry(){
super();
}
override public function getMethodParameters():Array{
return ([key, userIds, depth]);
}
override public function getMethodName():String{
return ("revealEntry");
}
override public function getMethodParametersNum():int{
return (3);
}
override public function getFunctionId():int{
return (-88);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.key = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.userIds = parameters[_temp2];
var _temp3 = pos;
pos = (pos + 1);
this.depth = parameters[_temp3];
}
public static function create(key, userIds:Array=null, depth:int=0):RevealEntry{
var res:RevealEntry = new (RevealEntry);
res.key = key;
res.userIds = userIds;
res.depth = depth;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 57
//ServerEntry (come2play_as3.api.auto_generated.ServerEntry)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class ServerEntry extends API_Message {
public var storedByUserId:int;
public var visibleToUserIds:Array;
public var value;
public var changedTimeInMilliSeconds:int;
public var key;
public function ServerEntry(){
super();
}
override public function getMethodParameters():Array{
return ([key, value, storedByUserId, visibleToUserIds, changedTimeInMilliSeconds]);
}
override public function getMethodParametersNum():int{
return (5);
}
override public function getFunctionId():int{
return (-86);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.key = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.value = parameters[_temp2];
var _temp3 = pos;
pos = (pos + 1);
this.storedByUserId = parameters[_temp3];
var _temp4 = pos;
pos = (pos + 1);
this.visibleToUserIds = parameters[_temp4];
var _temp5 = pos;
pos = (pos + 1);
this.changedTimeInMilliSeconds = parameters[_temp5];
}
override public function getMethodName():String{
return ("serverEntry");
}
public static function create(key, value, storedByUserId:int, visibleToUserIds:Array, changedTimeInMilliSeconds:int):ServerEntry{
var res:ServerEntry = new (ServerEntry);
res.key = key;
res.value = value;
res.storedByUserId = storedByUserId;
res.visibleToUserIds = visibleToUserIds;
res.changedTimeInMilliSeconds = changedTimeInMilliSeconds;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 58
//UserEntry (come2play_as3.api.auto_generated.UserEntry)
package come2play_as3.api.auto_generated {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_copied.*;
import come2play_as3.api.*;
public class UserEntry extends API_Message {
public var value;
public var isSecret:Boolean;
public var key;
public function UserEntry(){
super();
}
override public function getMethodParameters():Array{
return ([key, value, isSecret]);
}
override public function getMethodName():String{
return ("userEntry");
}
override public function getMethodParametersNum():int{
return (3);
}
override public function getFunctionId():int{
return (-87);
}
override public function setMethodParameters(parameters:Array):void{
var pos:int;
var _temp1 = pos;
pos = (pos + 1);
this.key = parameters[_temp1];
var _temp2 = pos;
pos = (pos + 1);
this.value = parameters[_temp2];
var _temp3 = pos;
pos = (pos + 1);
this.isSecret = parameters[_temp3];
}
public static function create(key, value, isSecret:Boolean=false):UserEntry{
var res:UserEntry = new (UserEntry);
res.key = key;
res.value = value;
res.isSecret = isSecret;
return (res);
}
}
}//package come2play_as3.api.auto_generated
Section 59
//BaseGameAPI (come2play_as3.api.BaseGameAPI)
package come2play_as3.api {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_generated.*;
import flash.net.*;
import come2play_as3.api.auto_copied.*;
import flash.external.*;
public class BaseGameAPI extends LocalConnectionUser {
private var msgsInTransaction:Array;// = null
private var serverStateMiror:ObjectDictionary;
private var someMovieClip:DisplayObjectContainer;
private var keyboardMessages:Array;
private var doStoreQueue:Array;
private var historyEntries:Array;
private var currentCallback:API_Message;// = null
private var keys:Array;
private var runningAnimationsNumber:int;// = 0
private var hackerUserId:int;// = -1
private var singlePlayerEmulator:SinglePlayerEmulator;
public static var HISTORY_LENGTH:int = 100;
public static var ERROR_DO_ALL:String = "You can only call a doAll* message when the server calls gotStateChanged, gotMatchStarted, gotMatchEnded, or gotRequestStateCalculation.";
public function BaseGameAPI(_someMovieClip:DisplayObjectContainer){
doStoreQueue = new Array();
super(_someMovieClip, false, getPrefixFromFlashVars(_someMovieClip), true);
keyboardMessages = [];
someMovieClip = _someMovieClip;
AS3_vs_AS2.addKeyboardListener(_someMovieClip, keyPressed);
if (getPrefixFromFlashVars(_someMovieClip) == null){
singlePlayerEmulator = new SinglePlayerEmulator(_someMovieClip);
};
if (HISTORY_LENGTH > 0){
historyEntries = new Array();
};
}
public function getServerEntry(key:Object):ServerEntry{
return ((serverStateMiror.getValue(key) as ServerEntry));
}
private function keyPressed(is_key_down:Boolean, charCode:int, keyCode:int, keyLocation:int, altKey:Boolean, ctrlKey:Boolean, shiftKey:Boolean):void{
var serverEntries:Array;
var output:String;
var gotMatchStarted:API_GotMatchStarted;
var serverEntry:ServerEntry;
var keyBoardEvent:API_GotKeyboardEvent;
if (((((((shiftKey) && (ctrlKey))) && (altKey))) && (is_key_down))){
if (String("G").charCodeAt(0) == charCode){
serverEntries = new Array();
output = ((("Traces:\n\n" + StaticFunctions.getTraces()) + "\n\n") + "Server State(client side) : \n\n");
if (serverStateMiror != null){
for each (serverEntry in serverStateMiror.allValues) {
serverEntries.push(serverEntry);
output = (output + (serverEntry.toString() + "\n"));
};
};
if (historyEntries != null){
output = (output + (("History entries :\n\n" + historyEntries.join("\n")) + "\n\n"));
};
output = (output + ("Custom Data:\n\n" + getTAsArray().join("\n")));
gotMatchStarted = API_GotMatchStarted.create(0, verifier.getAllPlayerIds(), verifier.getFinishedPlayerIds(), serverEntries);
AS3_vs_AS2.showError(someMovieClip, ((("gotMatchStarted : \n\n" + JSON.stringify(gotMatchStarted)) + "\n") + output));
};
};
if (((((verifier.isPlayer()) && (!(T.custom(API_Message.CUSTOM_INFO_KEY_isFocusInChat, false))))) && (!(T.custom(API_Message.CUSTOM_INFO_KEY_isPause, false))))){
keyBoardEvent = API_GotKeyboardEvent.create(is_key_down, charCode, keyCode, keyLocation, altKey, ctrlKey, shiftKey);
keyboardMessages.push(keyBoardEvent);
if (!isInTransaction()){
sendKeyboardEvents();
};
};
}
private function updateMirorServerState(serverEntries:Array):void{
var serverEntry:ServerEntry;
for each (serverEntry in serverEntries) {
serverStateMiror.addEntry(serverEntry);
};
}
private function sendKeyboardEvents():void{
while (keyboardMessages.length > 0) {
dispatchMessage((keyboardMessages.shift() as API_Message));
};
}
public function canDoAnimations():Boolean{
return ((((((((((currentCallback is API_GotCustomInfo)) || ((currentCallback is API_GotMatchStarted)))) || ((currentCallback is API_GotMatchEnded)))) || ((currentCallback is API_GotUserInfo)))) || ((currentCallback is API_GotStateChanged))));
}
private function isInTransaction():Boolean{
return (!((msgsInTransaction == null)));
}
private function checkInsideTransaction():void{
if (!isInTransaction()){
throwError("You can start/end an animation only when the server called some 'got' callback");
};
}
public function animationStarted():void{
checkInsideTransaction();
if (!canDoAnimations()){
throwError("You can do animations only when the server calls gotMatchStarted, gotMatchEnded, or gotStateChanged");
};
runningAnimationsNumber++;
}
override public function sendMessage(doMsg:API_Message):void{
if (ProtocolVerifier.isPassThrough(doMsg)){
super.sendMessage(doMsg);
return;
};
if ((doMsg is API_DoStoreState)){
if (isInTransaction()){
trace("push message");
doStoreQueue.push(doMsg);
} else {
trace("send message");
super.sendMessage(doMsg);
};
return;
};
if (!isInTransaction()){
throwError(ERROR_DO_ALL);
};
msgsInTransaction.push(doMsg);
}
override public function gotMessage(msg:API_Message):void{
var stateChanged:API_GotStateChanged;
var serverEntry:ServerEntry;
var matchStarted:API_GotMatchStarted;
var customInfo:API_GotCustomInfo;
var i18nObj:Object;
var customObj:Object;
var entry:InfoEntry;
var key:String;
var value:Object;
var reflectionKey:String;
var infoMessage:API_GotUserInfo;
var userObject:Object;
var infoEntry:InfoEntry;
var msg = msg;
try {
if (isInTransaction()){
throwError("The container sent an API message without waiting for DoFinishedCallback");
};
if (((!((runningAnimationsNumber == 0))) || (!((currentCallback == null))))){
throwError(((((("Internal error! runningAnimationsNumber=" + runningAnimationsNumber) + " msgsInTransaction=") + msgsInTransaction) + " currentCallback=") + currentCallback));
};
msgsInTransaction = [];
currentCallback = msg;
hackerUserId = -1;
if ((msg is API_GotStateChanged)){
stateChanged = (msg as API_GotStateChanged);
if (stateChanged.serverEntries.length >= 1){
updateMirorServerState(stateChanged.serverEntries);
serverEntry = stateChanged.serverEntries[0];
hackerUserId = serverEntry.storedByUserId;
};
} else {
if ((msg is API_GotMatchStarted)){
doStoreQueue = [];
serverStateMiror = new ObjectDictionary();
matchStarted = (msg as API_GotMatchStarted);
updateMirorServerState(matchStarted.serverEntries);
} else {
if ((msg is API_GotCustomInfo)){
customInfo = (msg as API_GotCustomInfo);
i18nObj = {};
customObj = {};
for each (entry in customInfo.infoEntries) {
key = entry.key;
value = entry.value;
if (key == API_Message.CUSTOM_INFO_KEY_i18n){
i18nObj = value;
} else {
if (key == API_Message.CUSTOM_INFO_KEY_reflection){
for (reflectionKey in value) {
StaticFunctions.performReflectionObject(reflectionKey, value[reflectionKey]);
};
} else {
if ((((key == API_Message.CUSTOM_INFO_KEY_checkThrowingAnError)) && ((value == true)))){
throw (new Error("checkThrowingAnError"));
} else {
customObj[key] = value;
};
};
};
};
T.initI18n(i18nObj, customObj);
} else {
if ((msg is API_GotUserInfo)){
infoMessage = (msg as API_GotUserInfo);
userObject = {};
for each (infoEntry in infoMessage.infoEntries) {
trace(((infoEntry.key + "=") + infoEntry.value));
userObject[infoEntry.key] = infoEntry.value;
};
T.updateUser(infoMessage.userId, userObject);
};
};
};
};
if (historyEntries != null){
if (historyEntries.length < HISTORY_LENGTH){
historyEntries.push(HistoryEntry.create((SerializableClass.deserialize(msg.toObject()) as API_Message), getTimer()));
};
};
dispatchMessage(msg);
//unresolved jump
var _slot1 = err;
showError(getErrorMessage(msg, _slot1));
gotError(msg, _slot1);
//unresolved jump
var _slot1 = err2;
showError(("Another error occurred when calling gotError. The new error is=" + AS3_vs_AS2.error2String(msg)));
} finally {
sendFinishedCallback();
};
}
public function gotError(withObj:Object, err:Error):void{
sendMessage(API_DoAllFoundHacker.create(hackerUserId, ((((((((((("Got error withObj=" + JSON.stringify(withObj)) + " err=") + AS3_vs_AS2.error2String(err)) + " runningAnimationsNumber=") + runningAnimationsNumber) + " currentCallback=") + currentCallback) + " msgsInTransaction=") + JSON.stringify(msgsInTransaction)) + " traces=") + StaticFunctions.getTraces())));
}
public function animationEnded():void{
checkInsideTransaction();
if (runningAnimationsNumber <= 0){
throwError("Called animationEnded too many times!");
};
runningAnimationsNumber--;
sendFinishedCallback();
}
private function getTAsArray():Array{
var str:String;
var infoEntries:Array = new Array();
var custom:Object = T.getCustom();
for (str in custom) {
infoEntries.push(InfoEntry.create(str, custom[str]));
};
return (infoEntries);
}
public function dispatchMessage(msg:API_Message):void{
var methodName:String = msg.getMethodName();
if (((AS3_vs_AS2.isAS3) && (!(this.hasOwnProperty(methodName))))){
return;
};
var func:Function = (this[methodName] as Function);
if (func == null){
return;
};
var params:Array = msg.getMethodParameters();
if ((((((msg is API_GotMatchStarted)) || ((msg is API_GotMatchEnded)))) || ((msg is API_GotStateChanged)))){
params.shift();
};
func.apply(this, params);
}
private function sendDoStoreStateEvents():void{
var doStoreMsg:API_DoStoreState;
for each (doStoreMsg in doStoreQueue) {
super.sendMessage(doStoreMsg);
};
doStoreQueue = [];
}
public function cacheImage(imageUrl:String, someMovieClip:MovieClip, onLoaded:Function):void{
var thisObj:BaseGameAPI;
var imageUrl = imageUrl;
var someMovieClip = someMovieClip;
var onLoaded = onLoaded;
animationStarted();
thisObj = this;
var forCaching:DisplayObject = AS3_vs_AS2.loadMovieIntoNewChild(someMovieClip, imageUrl, function (isSucc:Boolean):void{
onLoaded(isSucc);
thisObj.animationEnded();
});
AS3_vs_AS2.setVisible(forCaching, false);
}
public function setMaybeHackerUserId(hackerUserId:int):void{
this.hackerUserId = hackerUserId;
}
private function sendFinishedCallback():void{
checkInsideTransaction();
if (runningAnimationsNumber > 0){
return;
};
var msgNum = -666;
if ((currentCallback is API_GotMatchStarted)){
msgNum = (currentCallback as API_GotMatchStarted).msgNum;
};
if ((currentCallback is API_GotMatchEnded)){
msgNum = (currentCallback as API_GotMatchEnded).msgNum;
};
if ((currentCallback is API_GotStateChanged)){
msgNum = (currentCallback as API_GotStateChanged).msgNum;
};
super.sendMessage(API_Transaction.create(API_DoFinishedCallback.create(currentCallback.getMethodName(), msgNum), msgsInTransaction));
msgsInTransaction = null;
currentCallback = null;
sendKeyboardEvents();
if (verifier.isPlayer()){
sendDoStoreStateEvents();
};
}
}
}//package come2play_as3.api
Section 60
//SinglePlayerEmulator (come2play_as3.api.SinglePlayerEmulator)
package come2play_as3.api {
import flash.display.*;
import flash.utils.*;
import come2play_as3.api.auto_generated.*;
import come2play_as3.api.auto_copied.*;
public final class SinglePlayerEmulator extends LocalConnectionUser {
private var userId:int;
private var serverStateMiror:ObjectDictionary;
private var customInfoEntries:Array;
private var apiMsgsQueue:Array;
private var userStateEntries:Array;
private var userInfoEntries:Array;
public var messageNum:int;
public static var DEFAULT_MATCH_STATE:Array = [];
public static var DEFAULT_USER_ID:int = 42;
public static var DEFAULT_GENERAL_INFO:Array = [InfoEntry.create(API_Message.CUSTOM_INFO_KEY_myUserId, DEFAULT_USER_ID), InfoEntry.create(API_Message.CUSTOM_INFO_KEY_logoFullUrl, "../../Emulator/example_logo.jpg"), InfoEntry.create(API_Message.CUSTOM_INFO_KEY_gameHeight, 400), InfoEntry.create(API_Message.CUSTOM_INFO_KEY_gameWidth, 400), InfoEntry.create("checkThrowingAnError", false), InfoEntry.create("customSymbolsStringArray", [null, "../../Emulator/camel70x70.PNG"])];
public static var DEFAULT_USER_INFO:Array = [InfoEntry.create(API_Message.USER_INFO_KEY_name, "User name"), InfoEntry.create(API_Message.USER_INFO_KEY_avatar_url, "../../Emulator/Avatar_1.gif")];
public function SinglePlayerEmulator(graphics:DisplayObjectContainer){
apiMsgsQueue = [];
super(graphics, true, DEFAULT_LOCALCONNECTION_PREFIX, true);
this.customInfoEntries = DEFAULT_GENERAL_INFO;
this.userId = DEFAULT_USER_ID;
this.userInfoEntries = DEFAULT_USER_INFO;
this.userStateEntries = DEFAULT_MATCH_STATE;
}
private function messageHandler(msg:API_Message, transactionEntries:Array=null):Array{
var serverEntry:ServerEntry;
var transaction:API_Transaction;
var tempServerEntries:Array;
var innerMsg:API_Message;
var doStore:API_DoStoreState;
var doAllStoreMsg:API_DoAllStoreState;
var stateCalculations:API_DoAllStoreStateCalculation;
var shuffleState:API_DoAllShuffleState;
var Key:Object;
var i:int;
var revealStateMsg:API_DoAllRevealState;
var doAllSecretStateMsg:API_DoAllRequestRandomState;
var randomINT:int;
var endMatch:API_DoAllEndMatch;
var finishedPlayerIds:Array;
var matchOver:PlayerMatchOver;
var requestStateCalculationMsg:API_DoAllRequestStateCalculation;
var key:Object;
var entry:ServerEntry;
var serverEntries:Array = [];
if ((msg is API_Transaction)){
transaction = (msg as API_Transaction);
for each (innerMsg in transaction.messages) {
tempServerEntries = messageHandler(innerMsg, serverEntries);
if (tempServerEntries.length > 0){
serverEntries = serverEntries.concat(tempServerEntries);
};
};
if (serverEntries.length > 0){
queueSendMessage(API_GotStateChanged.create(++messageNum, combineServerEntries(serverEntries)));
};
gotMessage(transaction.callback);
} else {
if ((msg is API_DoStoreState)){
doStore = (msg as API_DoStoreState);
serverEntries = extractStoredData(doStore.userEntries, 1);
if (doStore.revealEntries != null){
serverEntries = serverEntries.concat(doRevealEntries(doStore.revealEntries));
};
if (transactionEntries == null){
queueSendMessage(API_GotStateChanged.create(++messageNum, serverEntries));
} else {
return (serverEntries);
};
} else {
if ((msg is API_DoAllStoreState)){
doAllStoreMsg = (msg as API_DoAllStoreState);
serverEntries = extractStoredData(doAllStoreMsg.userEntries, 2);
if (transactionEntries == null){
queueSendMessage(API_GotStateChanged.create(++messageNum, serverEntries));
} else {
return (serverEntries);
};
} else {
if ((msg is API_DoAllStoreStateCalculation)){
stateCalculations = (msg as API_DoAllStoreStateCalculation);
serverEntries = extractStoredData(stateCalculations.userEntries, 3);
queueSendMessage(API_GotStateChanged.create(++messageNum, serverEntries));
} else {
if ((msg is API_DoAllShuffleState)){
shuffleState = (msg as API_DoAllShuffleState);
i = 0;
while (i < shuffleState.keys.length) {
Key = shuffleState.keys[i];
serverEntry = (serverStateMiror.getValue(Key) as ServerEntry);
if (serverEntry != null){
serverEntries.push(serverEntry);
} else {
shuffleState.keys.splice(i, 1);
i--;
};
i++;
};
serverEntries = shuffleEntries(shuffleState.keys, serverEntries);
if (transactionEntries == null){
queueSendMessage(API_GotStateChanged.create(++messageNum, serverEntries));
} else {
return (serverEntries);
};
} else {
if ((msg is API_DoAllRevealState)){
revealStateMsg = (msg as API_DoAllRevealState);
serverEntries = doRevealEntries(revealStateMsg.revealEntries);
if (transactionEntries == null){
queueSendMessage(API_GotStateChanged.create(++messageNum, serverEntries));
} else {
return (serverEntries);
};
} else {
if ((msg is API_DoAllRequestRandomState)){
doAllSecretStateMsg = (msg as API_DoAllRequestRandomState);
randomINT = (Math.random() * int.MAX_VALUE);
serverEntry = ServerEntry.create(doAllSecretStateMsg.key, randomINT, -1, (doAllSecretStateMsg.isSecret) ? [] : null, getTimer());
serverStateMiror.addEntry(serverEntry);
if (transactionEntries == null){
queueSendMessage(API_GotStateChanged.create(++messageNum, [serverEntry]));
} else {
return ([serverEntry]);
};
} else {
if ((msg is API_DoAllEndMatch)){
endMatch = (msg as API_DoAllEndMatch);
finishedPlayerIds = [];
for each (matchOver in endMatch.finishedPlayers) {
finishedPlayerIds.push(matchOver.playerId);
};
queueSendMessage(API_GotMatchEnded.create(++messageNum, finishedPlayerIds));
AS3_vs_AS2.myTimeout(AS3_vs_AS2.delegate(this, this.sendNewMatch), 2000);
} else {
if ((msg is API_DoRegisterOnServer)){
doRegisterOnServer();
} else {
if ((msg is API_DoAllRequestStateCalculation)){
requestStateCalculationMsg = (msg as API_DoAllRequestStateCalculation);
for each (key in requestStateCalculationMsg.keys) {
entry = (serverStateMiror.getValue(key) as ServerEntry);
if (entry != null){
serverEntries.push(entry);
} else {
trace(JSON.stringify(key));
};
};
queueSendMessage(API_GotRequestStateCalculation.create(1, serverEntries));
} else {
if ((msg is API_DoFinishedCallback)){
if (apiMsgsQueue.length == 0){
throwError("Game sent too many DoFinishedCallback");
};
apiMsgsQueue.shift();
if (apiMsgsQueue.length > 0){
sendTopQueue();
};
};
};
};
};
};
};
};
};
};
};
};
return ([]);
}
private function combineServerEntries(serverEntries:Array):Array{
var serverEntry:ServerEntry;
var combinedServerEntries:Array = new Array();
var dicArray:Array = new Array();
var i:int = (serverEntries.length - 1);
while (i >= 0) {
serverEntry = serverEntries[i];
if (dicArray[JSON.stringify(serverEntry.key)] == null){
dicArray[JSON.stringify(serverEntry.key)] = true;
combinedServerEntries.unshift(serverEntry);
};
i--;
};
return (combinedServerEntries);
}
private function extractStoredData(userEntries:Array, storePrefrence:int):Array{
var serverEntry:ServerEntry;
var userEntry:UserEntry;
var serverEntries:Array = [];
for each (userEntry in userEntries) {
switch (storePrefrence){
case 1:
serverEntry = ServerEntry.create(userEntry.key, userEntry.value, userId, (userEntry.isSecret) ? [userId] : null, getTimer());
break;
case 2:
serverEntry = ServerEntry.create(userEntry.key, userEntry.value, -1, (userEntry.isSecret) ? [] : null, getTimer());
break;
case 3:
serverEntry = ServerEntry.create(userEntry.key, userEntry.value, -1, (userEntry.isSecret) ? [] : null, getTimer());
break;
};
serverStateMiror.addEntry(serverEntry);
serverEntries.push(serverEntry);
};
return (serverEntries);
}
private function shuffleEntries(keys:Array, serverEntries:Array):Array{
var randIndex:int;
var serverEntry:ServerEntry;
var currentKey:Object;
var newServerEntries:Array = new Array();
while (serverEntries.length > 0) {
randIndex = (Math.random() * serverEntries.length);
serverEntry = serverEntries[randIndex];
serverEntries.splice(randIndex, 1);
currentKey = keys.pop();
newServerEntries.push(ServerEntry.create(currentKey, null, -1, [], getTimer()));
serverStateMiror.addEntry(ServerEntry.create(currentKey, serverEntry.value, -1, [], getTimer()));
};
return (newServerEntries);
}
private function doRevealEntry(revealEntry:RevealEntry):ServerEntry{
var oldServerEntry:ServerEntry = (serverStateMiror.getValue(revealEntry.key) as ServerEntry);
if (oldServerEntry == null){
return (null);
};
var serverEntry:ServerEntry = ServerEntry.create(oldServerEntry.key, oldServerEntry.value, oldServerEntry.storedByUserId, oldServerEntry.visibleToUserIds, getTimer());
if (serverEntry == null){
return (null);
};
if (serverEntry.visibleToUserIds == null){
return (null);
};
if (revealEntry.userIds == null){
serverEntry.visibleToUserIds = null;
} else {
if (!updateUserIds(serverEntry.visibleToUserIds, revealEntry.userIds)){
return (null);
};
};
serverStateMiror.addEntry(serverEntry);
return (serverEntry);
}
override public function gotMessage(msg:API_Message):void{
messageHandler(msg);
}
private function queueSendMessage(msg:API_Message):void{
apiMsgsQueue.push(msg);
if (apiMsgsQueue.length == 1){
sendTopQueue();
};
}
private function updateUserIds(userIdsToUpdate:Array, uerIdsToAdd:Array):Boolean{
var id:int;
var updated:Boolean;
for each (id in uerIdsToAdd) {
if (AS3_vs_AS2.IndexOf(userIdsToUpdate, id) == -1){
updated = true;
userIdsToUpdate.push(id);
};
};
return (updated);
}
private function sendTopQueue():void{
var msg:API_Message = apiMsgsQueue[0];
sendMessage(msg);
}
private function doRevealPointer(revealEntry:RevealEntry):Object{
var serverEntry:ServerEntry = doRevealEntry(revealEntry);
if (serverEntry == null){
serverEntry = (serverStateMiror.getValue(revealEntry.key) as ServerEntry);
if (serverEntry == null){
return (null);
};
return (serverEntry.value);
//unresolved jump
};
return (serverEntry);
}
private function sendNewMatch():void{
var serverEntry:ServerEntry;
serverStateMiror = new ObjectDictionary();
for each (serverEntry in userStateEntries) {
serverStateMiror.addEntry(serverEntry);
};
messageNum = 0;
queueSendMessage(API_GotMatchStarted.create(messageNum, [userId], [], userStateEntries));
}
private function doRegisterOnServer():void{
queueSendMessage(API_GotCustomInfo.create(customInfoEntries));
queueSendMessage(API_GotUserInfo.create(userId, userInfoEntries));
sendNewMatch();
}
private function doRevealEntries(revealEntries:Array):Array{
var serverEntry:ServerEntry;
var pointerObject:Object;
var revealEntry:RevealEntry;
var i:int;
var serverEntries:Array = new Array();
for each (revealEntry in revealEntries) {
if (revealEntry.depth == 0){
serverEntry = doRevealEntry(revealEntry);
if (serverEntry != null){
serverEntries.push(serverEntry);
};
} else {
if (revealEntry.depth > 0){
i = 0;
while (i <= revealEntry.depth) {
pointerObject = doRevealPointer(revealEntry);
if (pointerObject == null){
} else {
if ((pointerObject is ServerEntry)){
serverEntry = (pointerObject as ServerEntry);
serverEntries.push(serverEntry);
revealEntry.key = serverEntry.value;
} else {
revealEntry.key = pointerObject;
};
};
i++;
};
};
};
};
return (serverEntries);
}
}
}//package come2play_as3.api
Section 61
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var cpmstarLoader:Loader;
private var contentspotid:String;
public function AdLoader(contentspotid:String){
super();
this.contentspotid = contentspotid;
addEventListener(Event.ADDED, addedHandler);
}
private function dispatchHandler(event:Event):void{
dispatchEvent(event);
}
private function addedHandler(event:Event):void{
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
var cpmstarViewSWFUrl:String = "http://server.cpmstar.com/adviewas3.swf";
var container:DisplayObjectContainer = parent;
cpmstarLoader = new Loader();
cpmstarLoader.contentLoaderInfo.addEventListener(Event.INIT, dispatchHandler);
cpmstarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
cpmstarLoader.load(new URLRequest(((cpmstarViewSWFUrl + "?contentspotid=") + contentspotid)));
addChild(cpmstarLoader);
}
}
}//package CPMStar
Section 62
//GameTracker (FGL.GameTracker.GameTracker)
package FGL.GameTracker {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.external.*;
public class GameTracker extends EventDispatcher {
protected var _passphrase:String;// = ""
protected var _responder:Responder;// = null
protected var _timer:Timer;// = null
protected var _serverVersionMajor:int;// = 0
protected var _conn:NetConnection;// = null
protected var _currentGame:int;// = 1
protected var _msg_queue:Array;
protected var _inGame:Boolean;// = false
protected var _inLevel:Boolean;// = false
protected var _serviceName:String;// = ""
protected var _currentLevel:int;// = 0
protected var _hostUrl:String;// = ""
protected var _sessionID:uint;
protected var _isEnabled:Boolean;// = false
protected var _serverVersionMinor:int;// = 0
public static const GAMETRACKER_SERVER_ERROR:String = "gametracker_server_error";
private static const TIMER_DELAY:int = 15000;
public static const GAMETRACKER_CODING_ERROR:String = "gametracker_coding_error";
public function GameTracker(){
_msg_queue = new Array();
super();
setGlobalConfig();
if (_isEnabled){
_responder = new Responder(onSuccess, onNetworkingError);
_conn = new NetConnection();
_conn.connect(_hostUrl);
_timer = new Timer(TIMER_DELAY);
_timer.addEventListener("timer", onTimer);
_timer.start();
_sessionID = Math.floor((new Date().getTime() / 1000));
addToMsgQueue("begin_app", null, 0, null, null);
};
}
public function beginGame(currentScore:Number=0, currentGameState:String=null, customMsg:String=null):void{
if (_inGame){
endGame(currentScore, currentGameState, "AUTO:(this game automatically ended when new game was started)");
};
_currentGame++;
_inGame = true;
addToMsgQueue("begin_game", null, currentScore, currentGameState, customMsg);
}
protected function setGlobalConfig():void{
var ret:Array;
_isEnabled = false;
_serverVersionMajor = 0;
_serverVersionMinor = 0;
_hostUrl = "";
_serviceName = "";
_passphrase = "";
if (ExternalInterface.available){
ret = ExternalInterface.call("get_gametracker_info");
_serverVersionMajor = ret[0];
_serverVersionMinor = ret[1];
_hostUrl = ret[2];
_serviceName = ret[3];
_passphrase = ret[4];
_isEnabled = (_serverVersionMajor == 1);
};
//unresolved jump
var _slot1 = e;
}
public function checkpoint(currentScore:Number=0, currentGameState:String=null, customMsg:String=null):void{
if (!_inGame){
dispatchEvent(new GameTrackerErrorEvent(GAMETRACKER_CODING_ERROR, "checkpoint() called before startGame() was called!"));
} else {
addToMsgQueue("checkpoint", null, currentScore, currentGameState, customMsg);
};
}
protected function onNetworkingError(evt):void{
dispatchEvent(new GameTrackerErrorEvent(GAMETRACKER_SERVER_ERROR, "Networking error"));
}
protected function submitMsgQueue():void{
var obj:Object;
if (((_isEnabled) && ((_msg_queue.length > 0)))){
obj = new Object();
obj["actions"] = _msg_queue;
obj["identifier"] = _passphrase;
_conn.call(_serviceName, _responder, obj);
_msg_queue = new Array();
};
}
public function customMsg(msgType:String, currentScore:Number=0, currentGameState:String=null, customMsg:String=null):void{
addToMsgQueue("custom", msgType, currentScore, currentGameState, customMsg);
}
public function beginLevel(newLevel:int, currentScore:Number=0, currentGameState:String=null, customMsg:String=null):void{
if (!_inGame){
dispatchEvent(new GameTrackerErrorEvent(GAMETRACKER_CODING_ERROR, "beginLevel() called before beginGame() was called!"));
} else {
if (_inLevel){
endLevel(currentScore, currentGameState, "AUTO:(this level automatically ended when new level was started)");
} else {
_currentLevel = newLevel;
_inLevel = true;
addToMsgQueue("begin_level", null, currentScore, currentGameState, customMsg);
};
};
}
public function alert(currentScore:Number=0, currentGameState:String=null, customMsg:String=null):void{
addToMsgQueue("alert", null, currentScore, currentGameState, customMsg);
submitMsgQueue();
}
protected function onTimer(evt:TimerEvent):void{
submitMsgQueue();
}
public function endLevel(currentScore:Number=0, currentGameState:String=null, customMsg:String=null):void{
if (!_inLevel){
dispatchEvent(new GameTrackerErrorEvent(GAMETRACKER_CODING_ERROR, "endLevel() called before beginLevel() was called!"));
} else {
_inLevel = false;
addToMsgQueue("end_level", null, currentScore, currentGameState, customMsg);
};
}
protected function onSuccess(evt):void{
if (evt.toString() != ""){
dispatchEvent(new GameTrackerErrorEvent(GAMETRACKER_SERVER_ERROR, evt.toString()));
};
}
protected function addToMsgQueue(action:String, subaction:String, score:Number, gamestate:String, custom_msg:String):void{
var msg:Object;
if (_isEnabled){
msg = new Object();
msg["action"] = action;
msg["custom_action"] = subaction;
msg["session_id"] = _sessionID;
msg["game_idx"] = _currentGame;
msg["level"] = _currentLevel;
msg["score"] = score;
msg["game_state"] = gamestate;
msg["time"] = Math.floor((new Date().getTime() / 1000));
msg["msg"] = custom_msg;
_msg_queue.push(msg);
};
}
public function endGame(currentScore:Number=0, currentGameState:String=null, customMsg:String=null):void{
if (!_inGame){
dispatchEvent(new GameTrackerErrorEvent(GAMETRACKER_CODING_ERROR, "endGame() called before beginGame() was called!"));
} else {
if (_inLevel){
endLevel(currentScore, currentGameState, "AUTO:(this level automatically ended when game ended)");
};
addToMsgQueue("end_game", null, currentScore, currentGameState, customMsg);
_inGame = false;
submitMsgQueue();
};
}
public function isEnabled():Boolean{
return (_isEnabled);
}
}
}//package FGL.GameTracker
Section 63
//GameTrackerErrorEvent (FGL.GameTracker.GameTrackerErrorEvent)
package FGL.GameTracker {
import flash.events.*;
public class GameTrackerErrorEvent extends Event {
public var _msg:String;
public function GameTrackerErrorEvent(type:String, msg:String){
_msg = msg;
super(type, false, false);
}
}
}//package FGL.GameTracker
Section 64
//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 65
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public function MochiScores(){
super();
}
public static function showLeaderboard(options:Object=null):void{
var n:Number;
var options = options;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.warnID(options.boardID, true);
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(callbackObj:Object, callbackMethod:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, callbackObj, callbackMethod);
}
public static function requestList(callbackObj:Object, callbackMethod:Object=null):void{
MochiServices.send("scores_requestList", null, callbackObj, callbackMethod);
}
public static function scoresArrayToObjects(scores:Object):Object{
var i:Number;
var j:Number;
var o:Object;
var row_obj:Object;
var item:String;
var param:String;
var so:Object = {};
for (item in scores) {
if (typeof(scores[item]) == "object"){
if (((!((scores[item].cols == null))) && (!((scores[item].rows == null))))){
so[item] = [];
o = scores[item];
j = 0;
while (j < o.rows.length) {
row_obj = {};
i = 0;
while (i < o.cols.length) {
row_obj[o.cols[i]] = o.rows[j][i];
i++;
};
so[item].push(row_obj);
j++;
};
} else {
so[item] = {};
for (param in scores[item]) {
so[item][param] = scores[item][param];
};
};
} else {
so[item] = scores[item];
};
};
return (so);
}
public static function submit(score:Number, name:String, callbackObj:Object=null, callbackMethod:Object=null):void{
score = Number(score);
if (isNaN(score)){
trace((("ERROR: Submitted score '" + String(score)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((score == Number.NEGATIVE_INFINITY)) || ((score == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(score)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(score) != score){
trace((("WARNING: Submitted score '" + String(score)) + "' will be truncated"));
};
score = Number(score);
};
};
MochiServices.send("scores_submit", {score:score, name:name}, callbackObj, callbackMethod);
}
public static function onClose(args:Object=null):void{
if (args != null){
if (args.error != null){
if (args.error == true){
if (onErrorHandler != null){
if (args.errorCode == null){
args.errorCode = "IOError";
};
onErrorHandler(args.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(boardID:String):void{
MochiServices.warnID(boardID, true);
MochiScores.boardID = boardID;
MochiServices.send("scores_setBoardID", {boardID:boardID});
}
}
}//package mochi.as3
Section 66
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__ms_";
private static var _servicesURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
public static var netup:Boolean = true;
public function MochiServices(){
super();
}
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(error:Boolean):void{
var request:Object;
var callback:Object;
if (_clip != null){
if (_clip._queue != null){
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 send(methodName:String, args:Object=null, callbackObject:Object=null, callbackMethod:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:methodName, args:args, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
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);
};
}
public static function get childClip():Object{
return (_clip);
}
private static function clickMovie(url:String, cb:Function):MovieClip{
var b:int;
var loader:Loader;
var avm1_bytecode:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var header:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var footer:Array = [0, 64, 0, 0, 0];
var mc:MovieClip = new MovieClip();
var lc:LocalConnection = new LocalConnection();
var lc_name:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().getTime()));
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);
_listenChannel.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.02 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
private static function onStatus(event:StatusEvent):void{
switch (event.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
public static function get id():String{
return (_id);
}
private static function urlOptions(clip:Object):Object{
var pairs:Array;
var i:Number;
var kv:Array;
var opts:Object = {};
var options:String = 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 initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_listenChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (pkg:Object):void{
var methodName:String;
var pkg = pkg;
var cb:String = pkg.callbackID;
var cblst:Object = this.client._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) + "': ") + pkg.toString()));
} else {
if (obj != null){
obj(pkg.args);
//unresolved jump
var _slot1 = error;
trace(("Error invoking method on object: " + pkg.toString()));
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
trace("connected!");
_connecting = false;
_connected = true;
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (args:Object):void{
MochiServices.comChannelName = args.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
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 id = id;
var clip = clip;
var clipname:String = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(clip).servicesURL != undefined){
_servicesURL = urlOptions(clip).servicesURL;
};
MochiServices.allowDomains(_servicesURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
var f:Function = function (ev:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().getTime()) + "_") + Math.floor((Math.random() * 99999))));
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
var req:URLRequest = new URLRequest(_servicesURL);
var vars:URLVariables = new URLVariables();
vars.listenLC = _listenChannelName;
vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options;
if (widget){
vars.widget = true;
};
req.data = vars;
listen();
_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 get clip():Object{
return (_container);
}
public static function bringToTop(e:Event):void{
var e = e;
if (MochiServices.clip != null){
if (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 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 (((!(_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 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 67
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.2.0.3958";
public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
super(bitmapData, pixelSnapping, smoothing);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
}
}//package mx.core
Section 68
//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 69
//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 70
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.2.0.3958";
public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
var bitmapData = bitmapData;
var pixelSnapping = pixelSnapping;
var smoothing = smoothing;
super(bitmapData, pixelSnapping, smoothing);
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 71
//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 72
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 73
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 74
//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 75
//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 76
//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 77
//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 78
//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 79
//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 80
//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 81
//AngleHelper (AngleHelper)
package {
import flash.geom.*;
public class AngleHelper {
public function AngleHelper(){
super();
}
public static function degreeBetween(p1:Point, p2:Point):Number{
var angle:Number;
angle = radianBetween(p1, p2);
angle = Math.round(((angle / Math.PI) * 180));
angle = (-(angle) + 90);
return (angle);
}
public static function radianBetween(p1:Point, p2:Point):Number{
var adjacent:Number;
var opp:Number;
var angleResult:Number;
adjacent = (p2.x - p1.x);
opp = (-1 * (p2.y - p1.y));
angleResult = Math.atan2(opp, adjacent);
return (angleResult);
}
}
}//package
Section 82
//Assets (Assets)
package {
import flash.display.*;
public class Assets {
private var spaceShip1:Class;
private var spaceShip2:Class;
private var victory:Class;
private var realPlanet1:Bitmap;
private var realPlanet2:Bitmap;
private var realPlanet3:Bitmap;
private var realPlanet4:Bitmap;
private var realPlanet5:Bitmap;
private var realPlanet6:Bitmap;
private var realPlanet7:Bitmap;
private var realPlanet8:Bitmap;
private var realPlanet9:Bitmap;
private var ast4Asset:Class;
private var spaceShip1b:Class;
private var cruiser:Class;
private var ast1Asset:Class;
private var sun:Class;
private var realSpaceShip2:Bitmap;
private var greenShield:Class;
private var realSpaceShip1:Bitmap;
private var realBackground2:Bitmap;
private var redShield:Class;
private var realRedShield:Bitmap;
private var planetExplosion:Class;
private var ast6Asset:Class;
private var realBlackHole:Bitmap;
private var defeat:Class;
private var realDefeat:Bitmap;
private var realPlanet10:Bitmap;
private var realPlanet11:Bitmap;
private var realPlanet12:Bitmap;
private var realPlanet13:Bitmap;
private var realExp4:Bitmap;
private var ast3Asset:Class;
private var realExp8:Bitmap;
private var realExp3:Bitmap;
private var realExp6:Bitmap;
private var realExp9:Bitmap;
private var realExp2:Bitmap;
private var realExp5:Bitmap;
private var realExp7:Bitmap;
private var realVictory:Bitmap;
private var planet1:Class;
private var planet2:Class;
private var planet3:Class;
private var planet4:Class;
private var planet5:Class;
private var planet6:Class;
private var planet7:Class;
private var planet8:Class;
private var planet9:Class;
private var realAst1:Bitmap;
private var realAst2:Bitmap;
private var realAst3:Bitmap;
private var realAst4:Bitmap;
private var realAst5:Bitmap;
private var realAst6:Bitmap;
private var realSpaceShip1b:Bitmap;
private var exp3:Class;
private var planet10:Class;
private var planet11:Class;
private var planet12:Class;
private var exp1:Class;
private var exp2:Class;
private var ast5Asset:Class;
private var realCruiser:Bitmap;
private var planet13:Class;
private var exp9:Class;
private var background2:Class;
private var exp4:Class;
private var exp6:Class;
private var exp8:Class;
private var realSun:Bitmap;
private var exp7:Class;
private var realGreenShield:Bitmap;
private var realPlanetExplosion:Bitmap;
private var ast2Asset:Class;
private var exp5:Class;
private var deathStar:Class;
private var realDeathStar:Bitmap;
private var blackholeAsset:Class;
private var realExp1:Bitmap;
public function Assets(){
planet1 = Assets_planet1;
planet2 = Assets_planet2;
planet3 = Assets_planet3;
planet4 = Assets_planet4;
planet5 = Assets_planet5;
planet6 = Assets_planet6;
planet7 = Assets_planet7;
planet8 = Assets_planet8;
planet9 = Assets_planet9;
planet10 = Assets_planet10;
planet11 = Assets_planet11;
planet12 = Assets_planet12;
planet13 = Assets_planet13;
planetExplosion = Assets_planetExplosion;
sun = Assets_sun;
background2 = Assets_background2;
greenShield = Assets_greenShield;
redShield = Assets_redShield;
spaceShip1 = Assets_spaceShip1;
spaceShip1b = Assets_spaceShip1b;
spaceShip2 = Assets_spaceShip2;
cruiser = Assets_cruiser;
deathStar = Assets_deathStar;
ast1Asset = Assets_ast1Asset;
ast2Asset = Assets_ast2Asset;
ast3Asset = Assets_ast3Asset;
ast4Asset = Assets_ast4Asset;
ast5Asset = Assets_ast5Asset;
ast6Asset = Assets_ast6Asset;
blackholeAsset = Assets_blackholeAsset;
victory = Assets_victory;
defeat = Assets_defeat;
exp1 = Assets_exp1;
exp2 = Assets_exp2;
exp3 = Assets_exp3;
exp4 = Assets_exp4;
exp5 = Assets_exp5;
exp6 = Assets_exp6;
exp7 = Assets_exp7;
exp8 = Assets_exp8;
exp9 = Assets_exp9;
super();
realPlanet1 = new planet1();
realPlanet2 = new planet2();
realPlanet3 = new planet3();
realPlanet4 = new planet4();
realPlanet5 = new planet5();
realPlanet6 = new planet6();
realPlanet7 = new planet7();
realPlanet8 = new planet8();
realPlanet9 = new planet9();
realPlanet10 = new planet10();
realPlanet11 = new planet11();
realPlanet12 = new planet12();
realPlanet13 = new planet13();
realPlanetExplosion = new planetExplosion();
realSun = new sun();
realBackground2 = new background2();
realSpaceShip1 = new spaceShip1();
realSpaceShip1b = new spaceShip1b();
realSpaceShip2 = new spaceShip2();
realCruiser = new cruiser();
realGreenShield = new greenShield();
realRedShield = new redShield();
realDeathStar = new deathStar();
realAst1 = new ast1Asset();
realAst2 = new ast2Asset();
realAst3 = new ast3Asset();
realAst4 = new ast4Asset();
realAst5 = new ast5Asset();
realAst6 = new ast6Asset();
realBlackHole = new blackholeAsset();
realDefeat = new defeat();
realVictory = new victory();
realExp1 = new exp1();
realExp2 = new exp2();
realExp3 = new exp3();
realExp4 = new exp4();
realExp5 = new exp5();
realExp6 = new exp6();
realExp7 = new exp7();
realExp8 = new exp8();
realExp9 = new exp9();
}
public function getAsset(name:String=""):Bitmap{
if (name == "p1"){
return (realPlanet1);
};
if (name == "p2"){
return (realPlanet2);
};
if (name == "p3"){
return (realPlanet3);
};
if (name == "p4"){
return (realPlanet4);
};
if (name == "p5"){
return (realPlanet5);
};
if (name == "p6"){
return (realPlanet6);
};
if (name == "p7"){
return (realPlanet7);
};
if (name == "p8"){
return (realPlanet8);
};
if (name == "p9"){
return (realPlanet9);
};
if (name == "p10"){
return (realPlanet10);
};
if (name == "p11"){
return (realPlanet11);
};
if (name == "p12"){
return (realPlanet12);
};
if (name == "p13"){
return (realPlanet13);
};
if (name == "planetExplosion"){
return (realPlanetExplosion);
};
if (name == "sun"){
return (realSun);
};
if (name == "bg1"){
return (realBackground2);
};
if (name == "bg2"){
return (realBackground2);
};
if (name == "bg3"){
return (realBackground2);
};
if (name == "sh1"){
return (realSpaceShip1);
};
if (name == "sh1b"){
return (realSpaceShip1b);
};
if (name == "sh2"){
return (realSpaceShip2);
};
if (name == "cruiser"){
return (realCruiser);
};
if (name == "greenShield"){
return (realGreenShield);
};
if (name == "redShield"){
return (realRedShield);
};
if (name == "deathStar"){
return (realDeathStar);
};
if (name == "a1"){
return (realAst1);
};
if (name == "a2"){
return (realAst2);
};
if (name == "a3"){
return (realAst3);
};
if (name == "a4"){
return (realAst4);
};
if (name == "a5"){
return (realAst5);
};
if (name == "a6"){
return (realAst6);
};
if (name == "bh"){
return (realBlackHole);
};
if (name == "victory"){
return (realVictory);
};
if (name == "defeat"){
return (realDefeat);
};
if (name == "exp1"){
return (realExp1);
};
if (name == "exp2"){
return (realExp2);
};
if (name == "exp3"){
return (realExp3);
};
if (name == "exp4"){
return (realExp4);
};
if (name == "exp5"){
return (realExp5);
};
if (name == "exp6"){
return (realExp6);
};
if (name == "exp7"){
return (realExp7);
};
if (name == "exp8"){
return (realExp8);
};
if (name == "exp9"){
return (realExp9);
};
return (null);
}
}
}//package
Section 83
//Assets_ast1Asset (Assets_ast1Asset)
package {
import mx.core.*;
public class Assets_ast1Asset extends BitmapAsset {
}
}//package
Section 84
//Assets_ast2Asset (Assets_ast2Asset)
package {
import mx.core.*;
public class Assets_ast2Asset extends BitmapAsset {
}
}//package
Section 85
//Assets_ast3Asset (Assets_ast3Asset)
package {
import mx.core.*;
public class Assets_ast3Asset extends BitmapAsset {
}
}//package
Section 86
//Assets_ast4Asset (Assets_ast4Asset)
package {
import mx.core.*;
public class Assets_ast4Asset extends BitmapAsset {
}
}//package
Section 87
//Assets_ast5Asset (Assets_ast5Asset)
package {
import mx.core.*;
public class Assets_ast5Asset extends BitmapAsset {
}
}//package
Section 88
//Assets_ast6Asset (Assets_ast6Asset)
package {
import mx.core.*;
public class Assets_ast6Asset extends BitmapAsset {
}
}//package
Section 89
//Assets_background2 (Assets_background2)
package {
import mx.core.*;
public class Assets_background2 extends BitmapAsset {
}
}//package
Section 90
//Assets_blackholeAsset (Assets_blackholeAsset)
package {
import mx.core.*;
public class Assets_blackholeAsset extends BitmapAsset {
}
}//package
Section 91
//Assets_cruiser (Assets_cruiser)
package {
import mx.core.*;
public class Assets_cruiser extends BitmapAsset {
}
}//package
Section 92
//Assets_deathStar (Assets_deathStar)
package {
import mx.core.*;
public class Assets_deathStar extends BitmapAsset {
}
}//package
Section 93
//Assets_defeat (Assets_defeat)
package {
import mx.core.*;
public class Assets_defeat extends BitmapAsset {
}
}//package
Section 94
//Assets_exp1 (Assets_exp1)
package {
import mx.core.*;
public class Assets_exp1 extends BitmapAsset {
}
}//package
Section 95
//Assets_exp2 (Assets_exp2)
package {
import mx.core.*;
public class Assets_exp2 extends BitmapAsset {
}
}//package
Section 96
//Assets_exp3 (Assets_exp3)
package {
import mx.core.*;
public class Assets_exp3 extends BitmapAsset {
}
}//package
Section 97
//Assets_exp4 (Assets_exp4)
package {
import mx.core.*;
public class Assets_exp4 extends BitmapAsset {
}
}//package
Section 98
//Assets_exp5 (Assets_exp5)
package {
import mx.core.*;
public class Assets_exp5 extends BitmapAsset {
}
}//package
Section 99
//Assets_exp6 (Assets_exp6)
package {
import mx.core.*;
public class Assets_exp6 extends BitmapAsset {
}
}//package
Section 100
//Assets_exp7 (Assets_exp7)
package {
import mx.core.*;
public class Assets_exp7 extends BitmapAsset {
}
}//package
Section 101
//Assets_exp8 (Assets_exp8)
package {
import mx.core.*;
public class Assets_exp8 extends BitmapAsset {
}
}//package
Section 102
//Assets_exp9 (Assets_exp9)
package {
import mx.core.*;
public class Assets_exp9 extends BitmapAsset {
}
}//package
Section 103
//Assets_greenShield (Assets_greenShield)
package {
import mx.core.*;
public class Assets_greenShield extends BitmapAsset {
}
}//package
Section 104
//Assets_planet1 (Assets_planet1)
package {
import mx.core.*;
public class Assets_planet1 extends BitmapAsset {
}
}//package
Section 105
//Assets_planet10 (Assets_planet10)
package {
import mx.core.*;
public class Assets_planet10 extends BitmapAsset {
}
}//package
Section 106
//Assets_planet11 (Assets_planet11)
package {
import mx.core.*;
public class Assets_planet11 extends BitmapAsset {
}
}//package
Section 107
//Assets_planet12 (Assets_planet12)
package {
import mx.core.*;
public class Assets_planet12 extends BitmapAsset {
}
}//package
Section 108
//Assets_planet13 (Assets_planet13)
package {
import mx.core.*;
public class Assets_planet13 extends BitmapAsset {
}
}//package
Section 109
//Assets_planet2 (Assets_planet2)
package {
import mx.core.*;
public class Assets_planet2 extends BitmapAsset {
}
}//package
Section 110
//Assets_planet3 (Assets_planet3)
package {
import mx.core.*;
public class Assets_planet3 extends BitmapAsset {
}
}//package
Section 111
//Assets_planet4 (Assets_planet4)
package {
import mx.core.*;
public class Assets_planet4 extends BitmapAsset {
}
}//package
Section 112
//Assets_planet5 (Assets_planet5)
package {
import mx.core.*;
public class Assets_planet5 extends BitmapAsset {
}
}//package
Section 113
//Assets_planet6 (Assets_planet6)
package {
import mx.core.*;
public class Assets_planet6 extends BitmapAsset {
}
}//package
Section 114
//Assets_planet7 (Assets_planet7)
package {
import mx.core.*;
public class Assets_planet7 extends BitmapAsset {
}
}//package
Section 115
//Assets_planet8 (Assets_planet8)
package {
import mx.core.*;
public class Assets_planet8 extends BitmapAsset {
}
}//package
Section 116
//Assets_planet9 (Assets_planet9)
package {
import mx.core.*;
public class Assets_planet9 extends BitmapAsset {
}
}//package
Section 117
//Assets_planetExplosion (Assets_planetExplosion)
package {
import mx.core.*;
public class Assets_planetExplosion extends BitmapAsset {
}
}//package
Section 118
//Assets_redShield (Assets_redShield)
package {
import mx.core.*;
public class Assets_redShield extends BitmapAsset {
}
}//package
Section 119
//Assets_spaceShip1 (Assets_spaceShip1)
package {
import mx.core.*;
public class Assets_spaceShip1 extends BitmapAsset {
}
}//package
Section 120
//Assets_spaceShip1b (Assets_spaceShip1b)
package {
import mx.core.*;
public class Assets_spaceShip1b extends BitmapAsset {
}
}//package
Section 121
//Assets_spaceShip2 (Assets_spaceShip2)
package {
import mx.core.*;
public class Assets_spaceShip2 extends BitmapAsset {
}
}//package
Section 122
//Assets_sun (Assets_sun)
package {
import mx.core.*;
public class Assets_sun extends BitmapAsset {
}
}//package
Section 123
//Assets_victory (Assets_victory)
package {
import mx.core.*;
public class Assets_victory extends BitmapAsset {
}
}//package
Section 124
//AsteroidField (AsteroidField)
package {
import flash.display.*;
public class AsteroidField extends MovieClip {
private var w:Number;
private var h:Number;
private var myGame:Game;
public function AsteroidField(game:Game, xI:Number, yI:Number, w:Number, h:Number){
super();
myGame = game;
this.w = w;
this.h = h;
this.x = xI;
this.y = yI;
generate();
}
private function generate():void{
var newAsteroid:Bitmap;
var asteroidType:int;
var numAsteroids:int = ((w * h) / 100);
var i:int;
while (i < numAsteroids) {
newAsteroid = new Bitmap();
asteroidType = RandomNumber.generate(1, 4);
if ((((asteroidType >= 5)) && ((asteroidType < 15)))){
asteroidType = RandomNumber.generate(1, 5);
};
newAsteroid.rotation = RandomNumber.generate(0, 360);
newAsteroid.scaleX = (newAsteroid.scaleY = (RandomNumber.generate(1, 4) * 0.25));
newAsteroid.bitmapData = myGame.myAssets.getAsset(("a" + asteroidType)).bitmapData;
newAsteroid.x = (20 * RandomNumber.generate(0, (w / 20)));
newAsteroid.y = (20 * RandomNumber.generate(0, (h / 20)));
newAsteroid.smoothing = true;
this.addChild(newAsteroid);
i++;
};
}
}
}//package
Section 125
//Background (Background)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import Collision.*;
public class Background extends MovieClip {
private var clickBlocked:Boolean;// = false
private var noClickTimer:Timer;
public var mouseDown:Boolean;// = false
private var mouseDownPoint:Point;
private var animTimer:Timer;
public var noRectangle:Boolean;// = false
private var myGame:Game;
public function Background(parentGame:Game, backID:int=0){
var myContent:Bitmap;
animTimer = new Timer(50);
noClickTimer = new Timer(50);
super();
myGame = parentGame;
myContent = parentGame.myAssets.getAsset(("bg" + backID.toString()));
animTimer.addEventListener(TimerEvent.TIMER, move, false, 0, true);
this.addChild(myContent);
myContent.smoothing = true;
this.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
this.addEventListener(Event.ADDED_TO_STAGE, onAdded, false, 0, true);
this.addEventListener(Event.REMOVED_FROM_STAGE, onRemove, false, 0, true);
this.noClickTimer.addEventListener(TimerEvent.TIMER, blockClick, false, 0, true);
}
private function onAdded(e:Event):void{
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove, false, 0, true);
}
private function onMouseMove(e:MouseEvent):void{
var width:Number;
var height:Number;
if ((((((this.mouseDown == true)) && ((Math.abs((this.myGame.lineMC.mouseX - mouseDownPoint.x)) > 10)))) && ((Math.abs((this.myGame.lineMC.mouseY - mouseDownPoint.y)) > 10)))){
this.myGame.lineMC.graphics.clear();
this.myGame.lineMC.graphics.lineStyle(1, 0);
this.myGame.lineMC.graphics.beginFill(0xFFFFFF, 0.2);
width = (this.myGame.lineMC.mouseX - mouseDownPoint.x);
height = (this.myGame.lineMC.mouseY - mouseDownPoint.y);
this.myGame.lineMC.graphics.drawRect(mouseDownPoint.x, mouseDownPoint.y, width, height);
this.myGame.lineMC.graphics.endFill();
};
}
private function onRemove(e:Event):void{
stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
stage.removeEventListener(Event.ADDED_TO_STAGE, onAdded);
}
private function onMouseUp(e:MouseEvent):void{
var y:int;
if (mouseDownPoint == null){
return;
};
if (noRectangle){
return;
};
this.mouseDown = false;
if ((((Math.abs((this.myGame.lineMC.mouseX - mouseDownPoint.x)) < 10)) && ((Math.abs((this.myGame.lineMC.mouseY - mouseDownPoint.y)) < 10)))){
return;
};
var colliList:CollisionList = new CollisionList(this.myGame.lineMC);
var i:int;
while (i < myGame.mySpace.myPlanets.length) {
if (Planet(myGame.mySpace.myPlanets[i]).myOwner == 1){
colliList.addItem(myGame.mySpace.myPlanets[i]);
};
i++;
};
var result:Array = colliList.checkCollisions();
if (result.length > 0){
this.myGame.planetSelected = new Array();
y = 0;
while (y < result.length) {
if ((result[y].object1 is Planet)){
this.myGame.planetSelected.push(result[y].object1);
};
if ((result[y].object2 is Planet)){
this.myGame.planetSelected.push(result[y].object2);
};
y++;
};
} else {
this.myGame.planetSelected = new Array();
this.myGame.lineMC.graphics.clear();
};
this.myGame.lineMC.graphics.clear();
clickBlocked = true;
noClickTimer.start();
}
private function move(e:TimerEvent):void{
this.x = (this.x + 0.01);
}
private function onMouseDown(e:MouseEvent):void{
if (noRectangle){
return;
};
this.mouseDown = true;
this.mouseDownPoint = new Point(this.myGame.lineMC.mouseX, this.myGame.lineMC.mouseY);
}
private function onClick(e:MouseEvent=null):void{
clickBlocked = false;
if (clickBlocked){
return;
};
this.myGame.planetSelected = new Array();
this.myGame.lineMC.graphics.clear();
}
private function blockClick(e:TimerEvent):void{
clickBlocked = false;
noClickTimer.stop();
}
}
}//package
Section 126
//Comet (Comet)
package {
import flash.display.*;
import caurina.transitions.*;
public class Comet extends MovieClip {
private var comet:Class;
private var myGame:Game;
public function Comet(game:Game=null){
comet = Comet_comet;
super();
myGame = game;
this.y = -30;
var startX:Number = RandomNumber.generate(100, 700);
this.x = startX;
this.scaleX = (this.scaleY = 0.6);
this.addChild(new comet());
var finalX:Number = (startX + (40 * (RandomNumber.generate(0, 2) - 1)));
Tweener.addTween(this, {y:480, x:(startX - 410), time:1.4, onComplete:destroy, transition:"linear", onUpdate:checkCollision});
}
private function destroy():void{
if (this.parent != null){
};
this.parent.removeChild(this);
}
private function checkCollision():void{
if (myGame == null){
return;
};
var i:int;
while (i < myGame.mySpace.myFleets.length) {
if (Fleet(myGame.mySpace.myFleets[i]).hitTestObject(this)){
if (Fleet(myGame.mySpace.myFleets[i]) != null){
Fleet(myGame.mySpace.myFleets[i]).explode();
};
};
i++;
};
}
}
}//package
Section 127
//Comet_comet (Comet_comet)
package {
import mx.core.*;
import flash.utils.*;
public class Comet_comet extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function Comet_comet(){
dataClass = Comet_comet_dataClass;
super();
initialWidth = (2000 / 20);
initialHeight = (2000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 128
//Comet_comet_dataClass (Comet_comet_dataClass)
package {
import mx.core.*;
public class Comet_comet_dataClass extends ByteArrayAsset {
}
}//package
Section 129
//Explosion (Explosion)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Explosion extends MovieClip {
private var animationTimer:Timer;
private var myContent:Bitmap;
private var myGame:Game;
public function Explosion(game:Game, initX:Number, initY:Number, size:Number=0.25){
animationTimer = new Timer(20);
super();
myGame = game;
this.x = initX;
this.y = initY;
this.scaleX = (this.scaleY = size);
myContent = new Bitmap();
this.addChild(myContent);
this.animationTimer.addEventListener(TimerEvent.TIMER, anim, false, 0, true);
this.animationTimer.start();
SoundManager.playSound("explosion");
}
private function anim(e:TimerEvent):void{
if ((((animationTimer.currentCount > 0)) && ((animationTimer.currentCount < 10)))){
myContent.bitmapData = myGame.myAssets.getAsset(("exp" + animationTimer.currentCount)).bitmapData;
myContent.x = (-(myContent.width) / 2);
myContent.y = (-(myContent.height) / 2);
};
if (animationTimer.currentCount >= 10){
animationTimer.stop();
animationTimer.removeEventListener(TimerEvent.TIMER, anim);
if (this.parent != null){
this.parent.removeChild(this);
};
this.animationTimer = null;
this.myGame = null;
};
}
}
}//package
Section 130
//Fleet (Fleet)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import Collision.*;
import flash.filters.*;
public class Fleet extends MovieClip {
private var mySpeed:Number;// = 3
private var life:int;// = 1
private var power:int;// = 1
private var myType:int;// = 1
private var impulseDrive:Boolean;// = false
private var animationStatus:Boolean;// = false
private var laserFiring:Boolean;// = false
private var myContent:Bitmap;
public var luck:int;
private var laserEraser:Timer;
private var myDirection:Number;
private var laserTarget:Planet;
private var deathLaser:Timer;
private var laserTimer:Timer;
public var myDestination:Planet;
private var myGame:Game;
private var isDeathStar:Boolean;// = false
private var laserFired:Boolean;// = false
public var myOwner:int;
private var shield:Boolean;// = false
public var myOrigin:Planet;
private var moveTimer:Timer;
private var alreadyFired:Boolean;// = false
public function Fleet(parentGame:Game, from:Planet, destination:Planet, owner:int, type:int){
var myGlow:GlowFilter;
var shieldBitmap:Bitmap;
moveTimer = new Timer(50);
luck = RandomNumber.generate(1, 4);
deathLaser = new Timer(250);
laserTimer = new Timer(500);
laserEraser = new Timer(100);
super();
myType = type;
if ((((destination == null)) || ((from == null)))){
return;
};
if (((parentGame.myMenu.impulseDrive) && ((owner == 1)))){
impulseDrive = true;
};
if ((((owner == 2)) && (parentGame.myAI.impulseDrive))){
impulseDrive = true;
};
if ((((owner == 1)) && ((parentGame.myMenu.shields == true)))){
shield = true;
};
if ((((owner == 2)) && ((parentGame.myAI.shields == true)))){
shield = true;
};
if (type == 4){
isDeathStar = true;
};
var orientation:Number = AngleHelper.degreeBetween(new Point(from.x, from.y), new Point(destination.x, destination.y));
orientation = (orientation + (90 + 180));
myDestination = destination;
myOrigin = from;
var xI:Number = from.x;
var yI:Number = from.y;
myGame = parentGame;
myOwner = owner;
this.x = ((xI + RandomNumber.generate(0, 25)) - 12.5);
this.y = ((yI + RandomNumber.generate(0, 25)) - 12.5);
myDirection = orientation;
myContent = new Bitmap();
if (impulseDrive){
mySpeed = 6;
};
if (type == 1){
if (impulseDrive){
myContent.bitmapData = parentGame.myAssets.getAsset("sh1").bitmapData;
};
if (impulseDrive == false){
myContent.bitmapData = parentGame.myAssets.getAsset("sh1").bitmapData;
};
};
if (type == 2){
myContent.bitmapData = parentGame.myAssets.getAsset("sh2").bitmapData;
this.mySpeed = (this.mySpeed * 0.7);
power = 2;
life = 3;
};
if (type == 3){
myContent.bitmapData = parentGame.myAssets.getAsset("cruiser").bitmapData;
this.mySpeed = (this.mySpeed * 0.8);
if (impulseDrive){
(mySpeed * 0.9);
};
power = 35;
life = 50;
laserTimer.addEventListener(TimerEvent.TIMER, laserCreator, false, 0, true);
laserEraser.addEventListener(TimerEvent.TIMER, clearGraphics, false, 0, true);
laserTimer.start();
};
if (type == 4){
myContent.bitmapData = parentGame.myAssets.getAsset("deathStar").bitmapData;
this.mySpeed = (this.mySpeed * 0.3);
if (impulseDrive){
(mySpeed * 0.3);
};
life = 200;
power = 100;
};
this.addChild(myContent);
this.scaleX = (this.scaleY = 1);
myContent.x = (-(myContent.width) / 2);
myContent.y = (-(myContent.height) / 2);
this.rotation = orientation;
moveTimer.addEventListener(TimerEvent.TIMER, move, false, 0, true);
moveTimer.start();
if (shield){
life++;
shieldBitmap = new Bitmap();
if (myOwner == 1){
shieldBitmap.bitmapData = parentGame.myAssets.getAsset("greenShield").bitmapData;
};
if (myOwner == 2){
shieldBitmap.bitmapData = parentGame.myAssets.getAsset("redShield").bitmapData;
};
if (type == 2){
shieldBitmap.scaleX = (shieldBitmap.scaleY = 1.5);
};
shieldBitmap.x = (-(shieldBitmap.width) / 2);
shieldBitmap.y = (-(shieldBitmap.height) / 2);
this.addChild(shieldBitmap);
};
if (this.myOwner == 1){
myGlow = new GlowFilter(0xFFFFFF, 0.5, 6, 6);
} else {
myGlow = new GlowFilter(0xFF0000, 0.5, 6, 6);
};
this.filters = [myGlow];
}
private function clearGraphics(e:TimerEvent):void{
this.graphics.clear();
if (isDeathStar){
laserFiring = false;
laserEraser.stop();
deathLaser.stop();
myDestination = myOrigin;
};
}
private function deathLaserDrawer(e:TimerEvent):void{
this.graphics.clear();
this.graphics.lineStyle(2, 0xFF0000, 0.9);
var planet:Planet = laserTarget;
var planetPos:Point = new Point(planet.x, planet.y);
planetPos = this.globalToLocal(planetPos);
this.graphics.lineStyle(4, 0xFF0000, 0.5);
this.graphics.lineTo(planetPos.x, planetPos.y);
}
private function checkCollision():Planet{
var i:int;
if (myDestination == null){
this.explode();
return (null);
};
if (myDestination.parent == null){
this.explode();
return (null);
};
i = 0;
while (i < myGame.mySpace.myFleets.length) {
if (Fleet(myGame.mySpace.myFleets[i]).myOwner != this.myOwner){
if (Fleet(myGame.mySpace.myFleets[i]).hitTestObject(this)){
if (this.myOwner == 1){
return (null);
};
if (myType == 1){
if (alreadyFired){
return (null);
};
alreadyFired = true;
};
if (Fleet(myGame.mySpace.myFleets[i]) != null){
Fleet(myGame.mySpace.myFleets[i]).explode();
};
this.explode();
return (null);
};
};
i++;
};
var colList:CollisionList = new CollisionList(this);
colList.addItem(myDestination);
var result:Array = colList.checkCollisions();
if (result.length > 0){
if (isDeathStar == false){
explode(true);
if ((result[0].object2 is Planet)){
Planet(result[0].object2).hit(power, this.myOwner);
};
if ((result[0].object1 is Planet)){
Planet(result[0].object1).hit(power, this.myOwner);
};
return (null);
};
if (isDeathStar){
if (myDestination.myOwner != this.myOwner){
if ((result[0].object2 is Planet)){
deathStarLaser(Planet(result[0].object2));
};
if ((result[0].object1 is Planet)){
deathStarLaser(Planet(result[0].object1));
};
} else {
if ((result[0].object2 is Planet)){
Planet(result[0].object2).hit(100, this.myOwner);
};
if ((result[0].object1 is Planet)){
Planet(result[0].object1).hit(100, this.myOwner);
};
this.moveTimer.stop();
explode(false, true);
return (null);
};
};
};
colList = new CollisionList(this);
i = 0;
while (i < myGame.mySpace.myAsteroidFields.length) {
colList.addItem(myGame.mySpace.myAsteroidFields[i]);
i++;
};
result = colList.checkCollisions();
if (result.length > 0){
if (this.parent != null){
this.explode();
};
return (null);
};
return (null);
}
private function deathStarLaser(planet:Planet):void{
if (laserFired){
return;
};
laserFiring = true;
laserFired = true;
planet.explode();
laserTarget = planet;
SoundManager.playSound("laser");
deathLaser.addEventListener(TimerEvent.TIMER, deathLaserDrawer);
deathLaser.start();
laserEraser.delay = 3000;
laserEraser.addEventListener(TimerEvent.TIMER, this.clearGraphics);
laserEraser.start();
}
private function move(e:TimerEvent):void{
if ((((getPlanetsOf(myOwner).length == 0)) && (this.isDeathStar))){
this.explode(false, true);
};
if ((((getPlanetsOf(myOwner).length == 0)) && ((myDestination == null)))){
this.explode(false, true);
};
if (((this.isDeathStar) && (this.laserFiring))){
return;
};
if (myDestination.isDestroyed){
if (getPlanetsOf(myOwner).length == 0){
return;
};
myDestination = getPlanetsOf(myOwner)[RandomNumber.generate(0, (getPlanetsOf(myOwner).length - 1))];
};
if (this.stage == null){
this.moveTimer.stop();
return;
};
if (myGame.isPaused){
return;
};
var orientation:Number = AngleHelper.degreeBetween(new Point(this.x, this.y), new Point(myDestination.x, myDestination.y));
orientation = (orientation + (90 + 180));
myDirection = orientation;
this.rotation = myDirection;
var xSpeedVector:Number = (Math.cos(((Math.PI / 180) * myDirection)) * mySpeed);
var ySpeedVector:Number = (Math.sin(((Math.PI / 180) * myDirection)) * mySpeed);
this.x = (this.x + xSpeedVector);
this.y = (this.y + ySpeedVector);
checkCollision();
}
private function distanceBetween(p1:Point, p2:Point):Number{
var dist:*;
var dx:*;
var dy:Number;
dx = (p2.x - p1.x);
dy = (p2.y - p1.y);
dist = Math.sqrt(((dx * dx) + (dy * dy)));
return (dist);
}
private function laserCreator(e:TimerEvent):void{
var distance:Number;
var spaceShipPos:Point;
var i:int;
while (i < myGame.mySpace.myFleets.length) {
if (Fleet(myGame.mySpace.myFleets[i]).myOwner != this.myOwner){
spaceShipPos = new Point(Fleet(myGame.mySpace.myFleets[i]).x, Fleet(myGame.mySpace.myFleets[i]).y);
distance = distanceBetween(new Point(this.x, this.y), spaceShipPos);
if (distance < 75){
SoundManager.playSound("laser");
this.graphics.lineStyle(2, 0xFF0000, 0.8);
spaceShipPos = this.globalToLocal(spaceShipPos);
this.graphics.lineTo(spaceShipPos.x, spaceShipPos.y);
laserEraser.start();
if (Fleet(myGame.mySpace.myFleets[i]) != null){
Fleet(myGame.mySpace.myFleets[i]).explode();
};
return;
};
};
i++;
};
}
protected function getPlanetsOf(thisowner:int):Array{
var result:Array = new Array();
var i:int;
while (i < myGame.mySpace.myPlanets.length) {
if (Planet(myGame.mySpace.myPlanets[i]).myOwner == thisowner){
result.push(myGame.mySpace.myPlanets[i]);
};
i++;
};
return (result);
}
public function explode(fromPlanet:Boolean=false, forceRemove:Boolean=false):void{
var temp:Array;
var i:int;
if (forceRemove){
if (this.parent != null){
this.parent.removeChild(this);
};
this.moveTimer.stop();
this.laserEraser.stop();
this.laserTimer.stop();
temp = new Array();
i = 0;
while (i < myGame.mySpace.myFleets.length) {
if (myGame.mySpace.myFleets[i] != this){
temp.push(myGame.mySpace.myFleets[i]);
};
i++;
};
myGame.mySpace.myFleets = temp;
return;
};
if (isDeathStar){
return;
};
if ((((fromPlanet == false)) && ((this.power > 1)))){
life--;
if (life > 0){
return;
};
};
if (fromPlanet){
if (((!((this.myOwner == this.myDestination.myOwner))) && (!((this.myDestination.myOwner == 0))))){
this.myGame.mySpace.addChild(new Explosion(myGame, this.x, this.y));
};
} else {
this.myGame.mySpace.addChild(new Explosion(myGame, this.x, this.y));
};
if (this.parent != null){
this.parent.removeChild(this);
};
this.moveTimer.stop();
this.laserEraser.stop();
this.laserTimer.stop();
temp = new Array();
i = 0;
while (i < myGame.mySpace.myFleets.length) {
if (myGame.mySpace.myFleets[i] != this){
temp.push(myGame.mySpace.myFleets[i]);
};
i++;
};
myGame.mySpace.myFleets = temp;
}
}
}//package
Section 131
//GalacticExpansion (GalacticExpansion)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public dynamic class GalacticExpansion extends MovieClip {
private var sponsorLogo:Class;
private var realSponsorLogo:MovieClip;
public function GalacticExpansion(){
sponsorLogo = GalacticExpansion_sponsorLogo;
super();
var _mochiads_game_id:String = "f5af4f0e1a4f9d7c";
this.addEventListener(Event.ADDED_TO_STAGE, ats, false, 0, true);
}
private function ats(e:Event):void{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
realSponsorLogo = new sponsorLogo();
realSponsorLogo.x = 75;
stage.addChild(realSponsorLogo);
var sponsorTimer:Timer = new Timer(7000, 1);
sponsorTimer.addEventListener(TimerEvent.TIMER, sponsorOver);
sponsorTimer.start();
}
public function PL_LOADING(e:ProgressEvent):void{
}
private function sponsorOver(e:TimerEvent):void{
stage.addChild(new Menu());
var myScoreMenu:ScoresMenu = new ScoresMenu();
stage.addChild(myScoreMenu);
Reporter.initialize(myScoreMenu);
}
}
}//package
Section 132
//GalacticExpansion_sponsorLogo (GalacticExpansion_sponsorLogo)
package {
import mx.core.*;
import flash.utils.*;
public class GalacticExpansion_sponsorLogo extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function GalacticExpansion_sponsorLogo(){
dataClass = GalacticExpansion_sponsorLogo_dataClass;
super();
initialWidth = (10400 / 20);
initialHeight = (10400 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 133
//GalacticExpansion_sponsorLogo_dataClass (GalacticExpansion_sponsorLogo_dataClass)
package {
import mx.core.*;
public class GalacticExpansion_sponsorLogo_dataClass extends ByteArrayAsset {
}
}//package
Section 134
//Game (Game)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import caurina.transitions.*;
import AI.*;
import flash.text.*;
import flash.filters.*;
import flash.ui.*;
public class Game extends MovieClip {
private var nanites4:Class;
private var nanites5:Class;
private var nanites7:Class;
private var arrow:Class;
private var nanitesButton:MovieClip;
private var finishTime:Date;
private var nanites6:Class;
private var soundStatusBeforePause:int;
private var pauseScreen:Bitmap;
private var animationTimer:Timer;
private var endScreenContainer:MovieClip;
public var myMenu:Menu;
private var xDecrease:Number;
private var yDecrease:Number;
private var nanitesRed:Class;
public var mySpaceShipSelectioner:SpaceShipSelectioner;
private var startTime:Date;
public var planetSelected:Array;
public var myAssets:Assets;
private var opening:Boolean;// = true
private var myMaps:Maps;
public var lineMC:MovieClip;
private var demoCounter:int;// = 0
public var multiplayerControl:MultiplayerGame;
private var nanitesGreen:Class;
private var scaleXIncrease:Number;
private var isReplay:Boolean;// = false
private var winLoseTimer:Timer;
private var nanitesCounter:int;// = 0
private var scaleYIncrease:Number;
public var mySpace:Space;
private var difficulty:int;
private var cometGenerator:Timer;
public var nanitesStatus:String;// = null
public var myAI:AI_Base;
public var overAttackablePlanet:Boolean;// = false
private var scoreText:Class;
private var rectDemo:Class;
public var levelNumber:int;
private var nanitesTimer:Timer;
private var originX:Number;
private var originY:Number;
public var isPaused:Boolean;// = false
private var rectangleDemo:MovieClip;
public var myBackground:Background;
private var nanites1:Class;
private var nanites2:Class;
private var nanites3:Class;
public function Game(level:int=1, menu:Menu=null, replay:Boolean=false, creationX:Number=0, creationY:Number=0){
var helpArrow:MovieClip;
arrow = Game_arrow;
nanitesGreen = Game_nanitesGreen;
nanites1 = Game_nanites1;
nanites2 = Game_nanites2;
nanites3 = Game_nanites3;
nanites4 = Game_nanites4;
nanites5 = Game_nanites5;
nanites6 = Game_nanites6;
nanites7 = Game_nanites7;
scoreText = Game_scoreText;
nanitesRed = Game_nanitesRed;
rectDemo = Game_rectDemo;
planetSelected = new Array();
nanitesTimer = new Timer(1000);
winLoseTimer = new Timer(2000);
myAssets = new Assets();
lineMC = new MovieClip();
animationTimer = new Timer(10);
cometGenerator = new Timer(5000);
endScreenContainer = new MovieClip();
super();
startTime = new Date();
isReplay = replay;
myMenu = menu;
this.myMenu.gameTracker.beginLevel(level);
isReplay = replay;
var AISpeed = 6000;
levelNumber = level;
if (level == 0){
difficulty = 1;
};
if (level == 1){
difficulty = 1;
AISpeed = 2000;
};
if (level == 2){
difficulty = 2;
};
if (level >= 3){
difficulty = 2;
};
if (level >= 5){
difficulty = 2;
AISpeed = 1000;
};
if (level > 15){
difficulty = 2;
};
mySpace = new Space(this);
myBackground = new Background(this, 2);
pauseScreen = new myMenu.pauseAsset();
pauseScreen.x = 180;
pauseScreen.y = 150;
this.addChild(myBackground);
this.addChild(mySpace);
this.addChild(lineMC);
myMaps = new Maps(this);
var myLevels:Levels = new Levels();
var mapID:int = myLevels.level[level][0];
myAI = new AI_Base(this);
this.mySpace.loadMap(myMaps.map[mapID]);
if (difficulty == 1){
myAI = new AI_Level1(this);
};
if (difficulty == 2){
myAI = new AI_Level2(this);
};
if (difficulty == 3){
myAI = new AI_Level2(this);
};
if (difficulty == 4){
myAI = new AI_Level2(this);
};
myAI.AITimer.delay = AISpeed;
winLoseTimer.addEventListener(TimerEvent.TIMER, checkGameStatus, false, 0, true);
this.addEventListener(Event.ENTER_FRAME, drawLines, false, 0, true);
originX = creationX;
originY = creationY;
this.x = creationX;
this.y = creationY;
this.scaleX = (this.scaleY = 0.01);
xDecrease = (this.x / 100);
yDecrease = (this.y / 100);
animationTimer.addEventListener(TimerEvent.TIMER, animation, false, 0, true);
animationTimer.start();
var closeCross:MovieClip = new MovieClip();
closeCross.graphics.lineStyle(3, 0xFF0000);
closeCross.graphics.moveTo(0, 0);
closeCross.graphics.lineTo(7, 7);
closeCross.graphics.moveTo(7, 0);
closeCross.graphics.lineTo(0, 7);
closeCross.graphics.lineStyle(0.01, 0xFFFFFF, 0.2);
closeCross.graphics.beginFill(0x111111, 0.02);
closeCross.graphics.drawRect(-3, -3, 10, 10);
this.addChild(closeCross);
closeCross.x = 620;
closeCross.y = 5;
closeCross.useHandCursor = true;
closeCross.mouseChildren = false;
closeCross.buttonMode = true;
closeCross.addEventListener(MouseEvent.CLICK, gameover, false, 0, true);
cometGenerator.delay = RandomNumber.generate(4000, 10000);
cometGenerator.addEventListener(TimerEvent.TIMER, generateComet, false, 0, true);
cometGenerator.start();
if (this.levelNumber == 0){
helpArrow = new arrow();
helpArrow.x = -30;
helpArrow.y = -30;
helpArrow.scaleX = (helpArrow.scaleY = 5);
this.mySpace.myPlanets[0].addChild(helpArrow);
};
if (this.levelNumber == 1){
rectangleDemo = new rectDemo();
rectangleDemo.x = 400;
rectangleDemo.y = 100;
this.addChild(rectangleDemo);
rectangleDemo.addEventListener(Event.ENTER_FRAME, removeDemo, false, 0, true);
};
if (myMenu.nanites){
nanitesButton = new MovieClip();
nanitesButton.addChild(new nanitesGreen());
nanitesButton.y = 10;
nanitesButton.x = 5;
nanitesButton.buttonMode = true;
addChild(nanitesButton);
nanitesButton.addEventListener(MouseEvent.CLICK, nanitesClick);
nanitesTimer.addEventListener(TimerEvent.TIMER, nanitesStep, false, 0, true);
};
if (levelNumber >= 4){
myAI.impulseDrive = true;
};
if (levelNumber >= 8){
myAI.defensiveLaser = true;
};
if (levelNumber >= 4){
myAI.destroyers = true;
};
if (levelNumber >= 16){
myAI.deathStar = true;
};
if (levelNumber == 16){
myAI.savingMode = 0;
};
if (levelNumber == 18){
myAI.savingMode = 0;
};
this.addEventListener(Event.ADDED_TO_STAGE, ats, false, 0, true);
this.addEventListener(Event.REMOVED_FROM_STAGE, rfs, false, 0, true);
}
public function victory():void{
var sendScoreMC:MovieClip;
finishTime = new Date();
var i:int;
while (i < endScreenContainer.numChildren) {
endScreenContainer.removeChildAt(i);
i = (i + 1);
};
this.winLoseTimer.stop();
var victoryScreen:Bitmap = new Bitmap();
victoryScreen.bitmapData = myAssets.getAsset("victory").bitmapData;
endScreenContainer.addChild(victoryScreen);
this.addChild(endScreenContainer);
endScreenContainer.useHandCursor = true;
endScreenContainer.buttonMode = true;
endScreenContainer.mouseChildren = false;
endScreenContainer.addEventListener(MouseEvent.CLICK, victoryAndClose, false, 0, true);
var sendScoreBitmap:Bitmap = new scoreText();
sendScoreMC = new MovieClip();
sendScoreMC.x = 120;
sendScoreMC.y = 328;
this.addChild(sendScoreMC);
var score:TextField = new TextField();
score.text = (("Your time : " + Math.round(((finishTime.valueOf() - startTime.valueOf()) / 1000))) + "sec - SUBMIT");
var style:TextFormat = new TextFormat();
style.color = 0xFFFFFF;
style.size = 30;
style.font = "Arial";
style.bold = true;
score.setTextFormat(style);
score.width = 500;
score.height = 70;
sendScoreMC.addChild(score);
sendScoreMC.buttonMode = true;
sendScoreMC.useHandCursor = true;
sendScoreMC.mouseChildren = false;
sendScoreMC.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
sendScoreMC.filters = [new GlowFilter(0xFFFFFF, 1, 3, 3)];
});
sendScoreMC.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
sendScoreMC.filters = null;
});
sendScoreMC.addEventListener(MouseEvent.CLICK, sendScoreClick);
}
public function drawLines(e:Event):void{
var i:int;
var destX:Number;
var destY:Number;
if (myBackground.mouseDown){
return;
};
if (this.planetSelected.length <= 0){
return;
};
this.lineMC.graphics.clear();
i = 0;
while (i < planetSelected.length) {
if (this.overAttackablePlanet){
this.lineMC.graphics.lineStyle(1.3, 0xFFFFFF, 0.5);
} else {
this.lineMC.graphics.lineStyle(1, 0xFFFFFF, 0.5);
};
this.lineMC.graphics.moveTo(planetSelected[i].x, planetSelected[i].y);
destX = this.mouseX;
destY = this.mouseY;
if (destX > planetSelected[i].x){
destX = (destX - 2);
};
if (destX < planetSelected[i].x){
destX = (destX + 2);
};
if (destY > planetSelected[i].y){
destY = (destY - 2);
};
if (destY < planetSelected[i].y){
destY = (destY + 2);
};
this.lineMC.graphics.lineTo(destX, destY);
i++;
};
}
public function onOwnerChange():void{
winLoseTimer.start();
}
private function checkKeyboard(e:KeyboardEvent):void{
var myPlanets:Array;
var i:int;
var newSoundStatus:Number;
if (e.keyCode == Keyboard.ESCAPE){
this.planetSelected = new Array();
this.lineMC.graphics.clear();
};
if (e.keyCode == 65){
this.planetSelected = new Array();
myPlanets = myAI.getEnemyPlanets();
i = 0;
while (i < myPlanets.length) {
this.planetSelected.push(myPlanets[i]);
i++;
};
};
if (e.keyCode == 80){
if (isPaused == false){
this.addChild(pauseScreen);
soundStatusBeforePause = myMenu.soundActive;
myMenu.soundActive = 0;
myMenu.soundButtonClick();
isPaused = true;
return;
};
if (isPaused == true){
this.removeChild(pauseScreen);
newSoundStatus = (soundStatusBeforePause - 1);
if (newSoundStatus < 0){
newSoundStatus = 2;
};
myMenu.soundActive = newSoundStatus;
myMenu.soundButtonClick();
isPaused = false;
};
};
if (e.keyCode == 49){
this.mySpaceShipSelectioner.select(1);
};
if (e.keyCode == 50){
this.mySpaceShipSelectioner.select(2);
};
if (e.keyCode == 51){
this.mySpaceShipSelectioner.select(3);
};
if (e.keyCode == 52){
this.mySpaceShipSelectioner.select(4);
};
}
private function destroy():void{
if (this.parent == null){
return;
};
this.parent.removeChild(this);
}
private function nanitesClick(e:MouseEvent):void{
nanitesStatus = "inUse";
nanitesTimer.delay = 10;
nanitesTimer.start();
}
public function gameoverAndClose(e:MouseEvent=null):void{
if (myMenu == null){
return;
};
this.myMenu.gameTracker.endLevel(0, "defeat");
SoundManager.playSound("close");
this.opening = false;
this.animationTimer.start();
myMenu = null;
}
private function generateComet(e:TimerEvent):void{
if (this.isPaused){
return;
};
if (this.stage == null){
cometGenerator.stop();
cometGenerator.removeEventListener(TimerEvent.TIMER, generateComet);
return;
};
if (RandomNumber.generate(1, 4) <= 3){
mySpace.addChild(new Comet(this));
};
cometGenerator.delay = RandomNumber.generate(8000, 14000);
}
private function animation(e:TimerEvent):void{
if (opening){
Tweener.addTween(this, {x:0, y:0, scaleX:1, scaleY:1, time:1, transition:"easeOutBack", onComplete:createSHSMenu});
} else {
Tweener.addTween(this, {x:originX, y:originY, scaleX:0.01, scaleY:0.01, time:0.6, onComplete:destroy, transition:"easeInCirc"});
this.mySpaceShipSelectioner.visible = false;
};
animationTimer.stop();
}
private function removeDemo(e:Event):void{
demoCounter++;
if (demoCounter >= 100){
rectangleDemo.removeEventListener(Event.ENTER_FRAME, removeDemo);
this.removeChild(rectangleDemo);
};
}
public function victoryAndClose(e:MouseEvent=null):void{
if (myMenu == null){
return;
};
this.myMenu.gameTracker.endLevel(0, "Victory");
SoundManager.playSound("close");
this.opening = false;
this.animationTimer.start();
this.winLoseTimer.stop();
this.myAI.shutDown();
if (this.isReplay == false){
myMenu.levelUp();
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney = (myMenu.myStatsMenu.myMoney + ((this.levelNumber + 1) * 1000))));
myMenu.savedGame.data.level = levelNumber;
myMenu.savedGame.data.money = myMenu.myStatsMenu.myMoney;
};
var myLevels:Levels = new Levels();
var newPercent:Number = (((levelNumber + 1) / (myLevels.level.length + 1)) * 100);
myMenu.myStatsMenu.setPercentControlled(Math.round(newPercent));
if (this.levelNumber == 1){
myMenu.myWindow = new MenuWindow(80, 310, "Taking the control of solar systems makes you earn credits.\nYou can use your credits to research new technologies.\nClick on Research on the left to open the research menu.", 10);
};
myMenu.addChild(myMenu.myWindow);
myMenu = null;
}
private function nanitesStep(e:TimerEvent):void{
nanitesTimer.delay = 750;
if (nanitesStatus == "inUse"){
nanitesCounter++;
};
if (nanitesStatus == "recovering"){
nanitesCounter--;
nanitesTimer.delay = 3000;
if (nanitesCounter == 0){
nanitesButton.removeChildAt(0);
nanitesButton.addChild(nanitesButton.addChild(new nanitesGreen()));
nanitesTimer.stop();
return;
};
};
if (nanitesCounter != 0){
nanitesButton.x = 17;
};
if (nanitesButton.numChildren > 0){
nanitesButton.removeChildAt(0);
};
if (nanitesCounter == 1){
nanitesButton.addChild(new nanites1());
};
if (nanitesCounter == 2){
nanitesButton.addChild(new nanites2());
};
if (nanitesCounter == 3){
nanitesButton.addChild(new nanites3());
};
if (nanitesCounter == 4){
nanitesButton.addChild(new nanites4());
};
if (nanitesCounter == 5){
nanitesButton.addChild(new nanites5());
};
if (nanitesCounter == 6){
nanitesButton.addChild(new nanites6());
};
if (nanitesCounter == 7){
nanitesButton.addChild(new nanites7());
};
if (nanitesCounter == 8){
nanitesButton.addChild(nanitesButton.addChild(new nanitesRed()));
if (nanitesStatus == "inUse"){
nanitesStatus = "recovering";
};
};
}
private function createSHSMenu():void{
mySpaceShipSelectioner = new SpaceShipSelectioner(this, 400, -120);
this.addChild(mySpaceShipSelectioner);
}
private function ats(e:Event):void{
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeyboard);
stage.setChildIndex(myMenu.soundButton, (stage.numChildren - 1));
}
public function checkGameStatus(e:TimerEvent=null):void{
var i:int;
var tempStatus:String;
var incomingFleet:Boolean;
var playerAdvantage:Boolean;
var AIAdvantage:Boolean;
i = 0;
while (i < mySpace.myPlanets.length) {
if (mySpace.myPlanets[i].myOwner == 0){
if (myAI.getFleetGoingTo(mySpace.myPlanets[i], 1).length > 0){
playerAdvantage = true;
};
if (myAI.getFleetGoingTo(mySpace.myPlanets[i], 2).length > 0){
AIAdvantage = true;
};
};
i++;
};
i = 0;
while (i < mySpace.myFleets.length) {
if (Fleet(mySpace.myFleets[i]).myOwner != Fleet(mySpace.myFleets[i]).myDestination.myOwner){
if (Fleet(mySpace.myFleets[i]).myDestination.myOwner != 0){
incomingFleet = true;
};
};
i++;
};
if (incomingFleet == false){
if ((((myAI.getEnemyPlanets().length == 0)) && ((myAI.getMyPlanets().length == 0)))){
tempStatus = "win";
return;
};
if (myAI.getEnemyPlanets().length == 0){
tempStatus = "lose";
};
if (myAI.getMyPlanets().length == 0){
tempStatus = "win";
};
if (tempStatus == "win"){
if (AIAdvantage){
return;
};
this.victory();
winLoseTimer.stop();
return;
};
if (tempStatus == "lose"){
if (playerAdvantage){
return;
};
this.gameover();
winLoseTimer.stop();
return;
};
};
}
private function sendScoreClick(e:MouseEvent):void{
Reporter.sendScore(levelNumber, Number((finishTime.valueOf() - startTime.valueOf())), victoryAndClose, stage);
}
private function rfs(e:Event):void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, checkKeyboard);
}
public function gameover(e:MouseEvent=null):void{
var i:int;
while (i < endScreenContainer.numChildren) {
endScreenContainer.removeChildAt(i);
i++;
};
this.winLoseTimer.stop();
this.myAI.shutDown();
var victoryScreen:Bitmap = new Bitmap();
victoryScreen.bitmapData = myAssets.getAsset("defeat").bitmapData;
endScreenContainer.addChild(victoryScreen);
this.addChild(endScreenContainer);
endScreenContainer.useHandCursor = true;
endScreenContainer.buttonMode = true;
endScreenContainer.mouseChildren = false;
endScreenContainer.addEventListener(MouseEvent.CLICK, gameoverAndClose, false, 0, true);
}
}
}//package
Section 135
//Game_arrow (Game_arrow)
package {
import mx.core.*;
import flash.utils.*;
public class Game_arrow extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function Game_arrow(){
dataClass = Game_arrow_dataClass;
super();
initialWidth = (2000 / 20);
initialHeight = (2000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 136
//Game_arrow_dataClass (Game_arrow_dataClass)
package {
import mx.core.*;
public class Game_arrow_dataClass extends ByteArrayAsset {
}
}//package
Section 137
//Game_nanites1 (Game_nanites1)
package {
import mx.core.*;
public class Game_nanites1 extends BitmapAsset {
}
}//package
Section 138
//Game_nanites2 (Game_nanites2)
package {
import mx.core.*;
public class Game_nanites2 extends BitmapAsset {
}
}//package
Section 139
//Game_nanites3 (Game_nanites3)
package {
import mx.core.*;
public class Game_nanites3 extends BitmapAsset {
}
}//package
Section 140
//Game_nanites4 (Game_nanites4)
package {
import mx.core.*;
public class Game_nanites4 extends BitmapAsset {
}
}//package
Section 141
//Game_nanites5 (Game_nanites5)
package {
import mx.core.*;
public class Game_nanites5 extends BitmapAsset {
}
}//package
Section 142
//Game_nanites6 (Game_nanites6)
package {
import mx.core.*;
public class Game_nanites6 extends BitmapAsset {
}
}//package
Section 143
//Game_nanites7 (Game_nanites7)
package {
import mx.core.*;
public class Game_nanites7 extends BitmapAsset {
}
}//package
Section 144
//Game_nanitesGreen (Game_nanitesGreen)
package {
import mx.core.*;
public class Game_nanitesGreen extends BitmapAsset {
}
}//package
Section 145
//Game_nanitesRed (Game_nanitesRed)
package {
import mx.core.*;
public class Game_nanitesRed extends BitmapAsset {
}
}//package
Section 146
//Game_rectDemo (Game_rectDemo)
package {
import mx.core.*;
import flash.utils.*;
public class Game_rectDemo extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function Game_rectDemo(){
dataClass = Game_rectDemo_dataClass;
super();
initialWidth = (2000 / 20);
initialHeight = (2000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 147
//Game_rectDemo_dataClass (Game_rectDemo_dataClass)
package {
import mx.core.*;
public class Game_rectDemo_dataClass extends ByteArrayAsset {
}
}//package
Section 148
//Game_scoreText (Game_scoreText)
package {
import mx.core.*;
public class Game_scoreText extends BitmapAsset {
}
}//package
Section 149
//Levels (Levels)
package {
public class Levels {
public var level:Array;
public function Levels(){
level = new Array();
super();
level[0] = [0, 300, 211];
level[1] = [1, 378, 205];
level[2] = [2, 399, 271];
level[3] = [3, 357, 311];
level[4] = [5, 316, 303];
level[5] = [4, 259, 267];
level[6] = [6, 260, 187];
level[7] = [7, 300, 122];
level[8] = [8, 400, 136];
level[9] = [9, 472, 210];
level[10] = [10, 497, 224];
level[11] = [11, 0x0200, 291];
level[12] = [12, 485, 366];
level[13] = [13, 431, 429];
level[14] = [14, 388, 379];
level[15] = [15, 246, 408];
level[16] = [16, 203, 358];
level[17] = [17, 78, 323];
level[18] = [18, 200, 240];
}
}
}//package
Section 150
//Maps (Maps)
package {
public class Maps {
public var map:Array;
public function Maps(myGame:Game){
map = new Array();
super();
map.push(new Array());
map[0][0] = new Array();
map[0][0].push(new MenuWindow(115, 330, "The green glowing planets are yours, the red glowing are your ennemy's.\nClick on your planet to select it, and then on the other planet to attack.\nEach planet produces units.\nCapture the enemy's planets to win.\nClick on an empty space to deselect your planet.", 10));
map[0][0].push(new Sun(myGame, 320, 240));
map[0][1] = [300, 150, 13, 1, 1];
map[0][2] = [150, 200, 12, 1, 2];
map.push(new Array());
map[1][0] = new Array();
map[1][0].push(new MenuWindow(115, 330, "White glowing planets are neutral.\nYou can take the control of a neutral planet by sending a ship to it.\nYou can select both of them by drawing a selection rectangle.\nYou can also transfer spaceships between your planets.", 10));
map[1][0].push(new Sun(myGame, 320, 240));
map[1][1] = [300, 150, 13, 1, 1];
map[1][2] = [150, 200, 12, 1, 2];
map[1][3] = [225, 100, 5, 1, 0];
map.push(new Array());
map[2][0] = new Array();
map[2][0].push(new MenuWindow(115, 330, "Bigger planets produce units faster and can contain more units.\nYou can also press Escape to unselect all your planets,\n\"A\" to select all your planets and SHIFT to select more than\n one planet.", 10));
map[2][1] = [121, 78, 13, 1, 2];
map[2][2] = [50, 350, 12, 1, 2];
map[2][3] = [400, 50, 5, 1, 1];
map[2][4] = [460, 330, 2, 1, 1];
map[2][5] = [350, 200, 6, 2, 0];
map.push(new Array());
map[3][0] = new Array();
map[3][0].push(new AsteroidField(myGame, 230, 140, 30, 400));
map[3][0].push(new MenuWindow(115, 330, "Your spaceships can't go through asteroid field.\nYou have to find another way to your enemy.", 10));
map[3][1] = [50, 300, 12, 1, 2];
map[3][2] = [400, 300, 2, 1, 1];
map[3][3] = [250, 40, 9, 1, 0];
map.push(new Array());
map[4][0] = new Array();
map[4][0].push(new AsteroidField(myGame, 230, 150, 40, 50));
map[4][1] = [50, 50, 13, 1, 2];
map[4][2] = [50, 300, 12, 1, 2];
map[4][3] = [400, 50, 5, 1, 1];
map[4][4] = [400, 300, 2, 1, 1];
map.push(new Array());
map[5][0] = new Array();
map[5][0].push(new Sun(myGame, 320, 240));
map[5][0].push(new MenuWindow(115, 330, "Blue glowing planets are rebel planets.\nRebel planets are similar to neutral planets except\n that you have to fight to take their control", 15));
map[5][1] = [128, 216, 12, 1, 2];
map[5][2] = [150, 348, 2, 1, 1];
map[5][3] = [372, 40, 11, 1, 3];
map.push(new Array());
map[6][0] = new Array();
map[6][0].push(new AsteroidField(myGame, 366, 100, 283, 64));
map[6][0].push(new AsteroidField(myGame, 357, 310, 283, 64));
map[6][1] = [108, 156, 12, 1, 2];
map[6][2] = [150, 348, 2, 1, 1];
map[6][3] = [372, 40, 11, 2, 3];
map[6][4] = [356, 422, 9, 1, 0];
map[6][5] = [556, 422, 7, 1, 0];
map.push(new Array());
map[7][0] = new Array();
map[7][0].push(new AsteroidField(myGame, 310, 265, 30, 240));
map[7][0].push(new AsteroidField(myGame, 310, 0, 30, 190));
map[7][0].push(new AsteroidField(myGame, 450, 250, 283, 20));
map[7][1] = [118, 156, 12, 3, 0];
map[7][2] = [50, 240, 2, 1, 0];
map[7][3] = [450, 120, 4, 1, 2];
map[7][4] = [500, 402, 11, 1, 1];
map[7][5] = [355, 230, 7, 1, 3];
map.push(new Array());
map[8][0] = new Array();
map[8][0].push(new Sun(myGame, 320, 240));
map[8][1] = [178, 166, 12, 1, 0];
map[8][2] = [130, 290, 2, 1, 0];
map[8][3] = [450, 120, 4, 1, 2];
map[8][4] = [450, 402, 11, 1, 1];
map[8][5] = [385, 299, 6, 3, 3];
map.push(new Array());
map[9][0] = new Array();
map[9][0].push(new Sun(myGame, 320, 240));
map[9][1] = [178, 166, 12, 1, 0];
map[9][2] = [450, 120, 4, 2, 2];
map[9][3] = [450, 402, 11, 1, 1];
map.push(new Array());
map[10][0] = new Array();
map[10][0].push(new AsteroidField(myGame, 200, 100, 40, 480));
map[10][0].push(new AsteroidField(myGame, 420, 0, 40, 360));
map[10][1] = [105, 400, 9, 1, 1];
map[10][2] = [105, 50, 3, 1, 3];
map[10][3] = [320, 50, 2, 1, 3];
map[10][4] = [320, 400, 1, 1, 3];
map[10][5] = [550, 400, 8, 1, 3];
map[10][6] = [560, 50, 5, 1, 2];
map[10][7] = [50, 200, 7, 1, 0];
map[10][8] = [570, 200, 7, 1, 0];
map.push(new Array());
map[11][0] = new Array();
map[11][0].push(new Sun(myGame, 320, 240));
map[11][1] = [490, 206, 6, 3, 1];
map[11][2] = [290, 130, 4, 1, 2];
map[11][3] = [430, 220, 5, 1, 2];
map[11][4] = [250, 320, 2, 1, 1];
map[11][5] = [150, 202, 11, 1, 2];
map.push(new Array());
map[12][0] = new Array();
map[12][1] = [200, 240, 6, 1, 2];
map[12][2] = [100, 50, 4, 1, 2];
map[12][3] = [100, 350, 5, 1, 2];
map[12][4] = [550, 290, 2, 1, 1];
map[12][5] = [400, 100, 11, 1, 1];
map.push(new Array());
map[13][0] = new Array();
map[13][0].push(new Sun(myGame, 320, 240));
map[13][1] = [490, 206, 6, 4, 2];
map[13][2] = [290, 130, 4, 1, 1];
map[13][3] = [250, 320, 2, 1, 1];
map[13][4] = [150, 202, 11, 1, 1];
map.push(new Array());
map[14][0] = new Array();
map[14][0].push(new AsteroidField(myGame, 200, 300, 40, 480));
map[14][1] = [100, 380, 6, 1, 1];
map[14][2] = [50, 410, 7, 1, 1];
map[14][3] = [210, 220, 13, 1, 3];
map[14][4] = [485, 130, 2, 1, 2];
map[14][5] = [450, 300, 3, 1, 0];
map[14][6] = [450, 400, 11, 1, 0];
map.push(new Array());
map[15][0] = new Array();
map[15][1] = [100, 380, 6, 1, 1];
map[15][2] = [320, 240, 13, 4, 3];
map[15][3] = [530, 80, 2, 1, 2];
map[15][4] = [450, 300, 3, 1, 0];
map[15][5] = [450, 400, 11, 1, 0];
map[15][6] = [160, 200, 13, 1, 0];
map[15][7] = [80, 80, 12, 1, 0];
map.push(new Array());
map[16][0] = new Array();
map[16][1] = [150, 240, 6, 4, 2];
map[16][2] = [50, 130, 5, 2, 2];
map[16][3] = [50, 340, 12, 2, 2];
map[16][4] = [570, 130, 5, 2, 1];
map[16][5] = [570, 340, 12, 2, 1];
map.push(new Array());
map[17][0] = new Array();
map[17][1] = [100, 400, 2, 4, 1];
map[17][2] = [100, 130, 5, 2, 0];
map[17][3] = [200, 340, 12, 2, 0];
map[17][4] = [500, 400, 7, 2, 0];
map[17][5] = [250, 240, 8, 2, 0];
map[17][6] = [420, 100, 9, 2, 0];
map[17][7] = [520, 240, 8, 4, 2];
map[17][8] = [570, 130, 5, 2, 2];
map[17][9] = [570, 340, 12, 2, 2];
map.push(new Array());
map[18][0] = new Array();
map[18][1] = [520, 240, 8, 4, 2];
map[18][2] = [500, 150, 5, 2, 2];
map[18][3] = [570, 340, 12, 2, 2];
map[18][4] = [110, 320, 1, 3, 1];
map[18][5] = [320, 50, 3, 2, 3];
map[18][6] = [400, 430, 11, 2, 3];
map[18][7] = [210, 400, 5, 1, 0];
map[18][8] = [400, 350, 4, 1, 0];
map[18][9] = [240, 100, 8, 1, 0];
map[18][10] = [330, 135, 7, 1, 0];
}
}
}//package
Section 151
//Menu (Menu)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import caurina.transitions.*;
import flash.media.*;
import flash.net.*;
import FGL.GameTracker.*;
import mochi.as3.*;
import flash.filters.*;
import flash.ui.*;
public class Menu extends MovieClip {
public var soundActive:int;// = 0
private var galaxy:Class;
public var myMenuBattles:Array;
public var savedGame:SharedObject;
private var sponsor:MovieClip;
private var soundAsset:Class;
public var lastMouseOver:MovieClip;
private var creditsPageAsset:Class;
public var mouseOver:MovieClip;
public var shields:Boolean;// = false
public var destroyers:Boolean;// = false
private var background:Bitmap;
private var reOpenTimer:Timer;
private var conquestAsset:Class;
public var cruiser:Boolean;
private var creditsPage:MovieClip;
private var myLevels:Levels;
private var BTMMBContainer:MovieClip;
public var myStatsMenu:StatsMenu;
public var shipJustBought:Boolean;// = false
private var inTransition:Boolean;// = false
public var myResearchMenu:ResearchMenu;
public var soundButton:MovieClip;
private var jouerAsset:Class;
private var galacticAsset:Class;
private var buzzState:Boolean;// = true
private var soundsfxAsset:Class;
private var creditsAsset:Class;
private var jouer:MovieClip;
private var statsmenu:Class;
public var impulseDrive:Boolean;// = false
public var defensiveLaser:Boolean;// = false
public var pauseAsset:Class;
private var conquest:Bitmap;
private var galactic:Bitmap;
private var credits:MovieClip;
private var loadAsset:Class;
public var nanites:Boolean;// = false
public var myWindow:MenuWindow;
public var buzzer:Timer;
private var noSoundAsset:Class;
private var isReopen:Boolean;// = false
public var nanitesJustBought:Boolean;// = false
private var myOldMenu:Menu;
private var backToMM:Class;
public var deathStar:Boolean;
public var gameTracker:GameTracker;
private var myCoolShip:MouseFollowerShip;
private var sponsorAsset:Class;
private var loadGame:Boolean;// = false
private var load:MovieClip;
public function Menu(oldMenu:Menu=null){
var oldMenu = oldMenu;
galaxy = Menu_galaxy;
soundAsset = Menu_soundAsset;
soundsfxAsset = Menu_soundsfxAsset;
noSoundAsset = Menu_noSoundAsset;
galacticAsset = Menu_galacticAsset;
conquestAsset = Menu_conquestAsset;
jouerAsset = Menu_jouerAsset;
loadAsset = Menu_loadAsset;
creditsAsset = Menu_creditsAsset;
sponsorAsset = Menu_sponsorAsset;
creditsPageAsset = Menu_creditsPageAsset;
backToMM = Menu_backToMM;
pauseAsset = Menu_pauseAsset;
statsmenu = Menu_statsmenu;
buzzer = new Timer(50);
myMenuBattles = new Array();
myLevels = new Levels();
reOpenTimer = new Timer(10);
soundButton = new MovieClip();
gameTracker = new GameTracker();
super();
background = new galaxy();
background.smoothing = true;
this.addChild(background);
buildMainMenu();
buzzer.addEventListener(TimerEvent.TIMER, buzz, false, 0, true);
if (oldMenu != null){
myOldMenu = oldMenu;
isReopen = true;
this.y = -480;
reOpenTimer.addEventListener(TimerEvent.TIMER, reOpener);
reOpenTimer.start();
};
soundButton.addChild(new noSoundAsset());
Bitmap(soundButton.getChildAt(0)).smoothing = true;
soundButton.y = (480 - 55);
soundButton.x = 0;
soundButton.scaleX = (soundButton.scaleY = 1);
soundButton.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
soundButton.filters = [new GlowFilter(0xFFFFFF)];
});
soundButton.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
soundButton.filters = null;
});
soundButton.addEventListener(MouseEvent.CLICK, soundButtonClick, false, 0, true);
soundButton.buttonMode = true;
}
public function openGalaxyMap():void{
this.gameTracker.beginGame();
stage.addChild(soundButton);
if (isReopen == false){
SoundManager.playSound("music");
};
inTransition = false;
myMenuBattles.push(this.addChild(new MenuBattle(myLevels.level[0][1], myLevels.level[0][2], myMenuBattles, myMenuBattles.length)));
myStatsMenu = new StatsMenu(20, 20, this);
this.addChild(myStatsMenu);
var backToMMButton:Bitmap = new backToMM();
BTMMBContainer = new MovieClip();
BTMMBContainer.addChild(backToMMButton);
BTMMBContainer.buttonMode = true;
BTMMBContainer.y = 0;
BTMMBContainer.x = 430;
BTMMBContainer.addEventListener(MouseEvent.MOUSE_OVER, BTTMBGlow, false, 0, true);
BTMMBContainer.addEventListener(MouseEvent.MOUSE_OUT, BTTMBUnGlow, false, 0, true);
BTMMBContainer.addEventListener(MouseEvent.CLICK, closeGalaxy, false, 0, true);
this.addChild(BTMMBContainer);
loadSave();
this.myWindow = new MenuWindow(80, 310, " After the collapse of the Old Empire, the galaxy fell into Anarchy.\nA multitude of tyrans took over leading the world to a huge chaos.\nRising up from the Old Empire ashes,the New Republic is reconquering\nthe galaxy, one solar system at a time, to reestablish peace and\ndemocracy.", 20);
this.addChild(myWindow);
}
public function levelUp(e:MouseEvent=null):void{
if (myMenuBattles.length >= myLevels.level.length){
MenuBattle(myMenuBattles[(myMenuBattles.length - 2)]).won();
beatTheGame();
return;
};
myMenuBattles.push(this.addChild(new MenuBattle(myLevels.level[myMenuBattles.length][1], myLevels.level[myMenuBattles.length][2], myMenuBattles, myMenuBattles.length)));
MenuBattle(myMenuBattles[(myMenuBattles.length - 2)]).won();
}
private function buildMainMenu():void{
galactic = new galacticAsset();
galactic.x = 50;
galactic.y = 30;
conquest = new conquestAsset();
conquest.x = 200;
conquest.y = 90;
this.addChild(galactic);
this.addChild(conquest);
jouer = new MovieClip();
jouer.addChild(new jouerAsset());
jouer.x = 370;
jouer.y = 230;
jouer.buttonMode = true;
this.addChild(jouer);
jouer.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
SoundManager.playSound("buzz");
mouseOver = jouer;
buzzer.start();
});
jouer.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
buzzer.stop();
mouseOver = null;
});
jouer.addEventListener(MouseEvent.CLICK, closeMenu, false, 0, true);
load = new MovieClip();
load.addChild(new loadAsset());
load.x = 370;
load.y = 280;
this.addChild(load);
load.buttonMode = true;
load.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
SoundManager.playSound("buzz");
mouseOver = load;
buzzer.start();
});
load.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
buzzer.stop();
mouseOver = null;
});
load.addEventListener(MouseEvent.CLICK, function (e:MouseEvent){
closeMenu(null, true);
});
credits = new MovieClip();
credits.addChild(new creditsAsset());
credits.buttonMode = true;
credits.x = 370;
credits.y = 330;
this.addChild(credits);
credits.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
SoundManager.playSound("buzz");
mouseOver = credits;
buzzer.start();
});
credits.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
buzzer.stop();
mouseOver = null;
});
credits.addEventListener(MouseEvent.CLICK, displayCredits, false, 0, true);
sponsor = new MovieClip();
sponsor.addChild(new sponsorAsset());
sponsor.buttonMode = true;
sponsor.x = 50;
sponsor.y = 200;
sponsor.scaleX = (sponsor.scaleY = 0.9);
sponsor.useHandCursor = true;
sponsor.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
Mouse.show();
SoundManager.playSound("buzz");
});
sponsor.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
Mouse.hide();
buzzer.stop();
});
sponsor.addEventListener(MouseEvent.CLICK, sponsorClick, false, 0, true);
this.addChild(sponsor);
myCoolShip = new MouseFollowerShip(this.mouseX, this.mouseY);
this.addChild(myCoolShip);
}
private function closeGalaxy(e:MouseEvent):void{
stage.addChild(new Menu(this));
}
private function beatTheGame():void{
}
private function closeMenu(e:MouseEvent=null, load:Boolean=false):void{
this.loadGame = load;
SoundManager.playSound("research");
if (inTransition){
return;
};
inTransition = true;
myCoolShip.explode();
Tweener.addTween(galactic, {x:643, time:1, transition:"easeInBack"});
Tweener.addTween(conquest, {x:-(conquest.width), time:1, transition:"easeInBack"});
Tweener.addTween(jouer, {y:485, time:1.1, transition:"easeInBack", onComplete:openGalaxyMap});
Tweener.addTween(this.load, {y:485, time:1.05, transition:"easeInBack"});
Tweener.addTween(credits, {y:485, time:1, transition:"easeInBack"});
Tweener.addTween(sponsor, {x:-(sponsor.width), time:1, transition:"easeInBack"});
}
private function displayCredits(e:MouseEvent):void{
if (inTransition){
return;
};
SoundManager.playSound("buttonClick");
inTransition = true;
creditsPage = new MovieClip();
creditsPage.addEventListener(MouseEvent.CLICK, closeCredits, false, 0, true);
var black:MovieClip = new MovieClip();
black.graphics.beginFill(0, 1);
black.graphics.drawRect(0, 0, 640, 480);
black.graphics.endFill();
black.buttonMode = true;
creditsPage.addChild(black);
creditsPage.addChild(new creditsPageAsset());
stage.addChild(creditsPage);
creditsPage.x = -640;
Tweener.addTween(creditsPage, {x:0, time:2, transition:"easeIn"});
Tweener.addTween(this, {x:640, time:2, transition:"easeIn"});
Mouse.show();
}
private function closeCredits(e:MouseEvent):void{
var e = e;
SoundManager.playSound("buttonClick");
Tweener.addTween(creditsPage, {x:-640, time:1, onComplete:function (){
inTransition = false;
creditsPage.parent.removeChild(creditsPage);
}});
Tweener.addTween(this, {x:0, time:1});
Mouse.hide();
}
private function loadSave():void{
var i:int;
this.savedGame = SharedObject.getLocal("SpaceAnarchy");
if (this.loadGame){
if (savedGame.data.level != undefined){
this.impulseDrive = this.savedGame.data.impulseDrive;
this.destroyers = this.savedGame.data.destroyers;
this.defensiveLaser = this.savedGame.data.defensiveLaser;
this.shields = this.savedGame.data.shields;
this.nanites = this.savedGame.data.nanites;
this.cruiser = this.savedGame.data.cruiser;
this.deathStar = this.savedGame.data.deathStar;
myStatsMenu.setMoney(this.savedGame.data.money);
i = 0;
while (i <= this.savedGame.data.level) {
this.levelUp();
i++;
};
};
} else {
this.savedGame.clear();
};
}
private function reOpener(e:TimerEvent):void{
if (this.y < 0){
this.y = (this.y + 16);
myOldMenu.y = (myOldMenu.y + 16);
} else {
this.reOpenTimer.stop();
};
}
private function BTTMBGlow(e:MouseEvent):void{
BTMMBContainer.filters = [new GlowFilter(0xFFFFFF, 0.5)];
}
private function sponsorClick(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.flashgamesnexus.com/flash-games-category/Strategy-War-games.php"), "_blank");
}
public function soundButtonClick(e:MouseEvent=null):void{
if (soundActive == 0){
SoundMixer.soundTransform = new SoundTransform(0);
soundButton.removeChildAt(0);
soundButton.addChild(new soundAsset());
Bitmap(soundButton.getChildAt(0)).smoothing = true;
soundActive = 1;
return;
};
if (soundActive != 0){
soundActive = 0;
SoundMixer.soundTransform = new SoundTransform(1);
soundButton.removeChildAt(0);
soundButton.addChild(new noSoundAsset());
Bitmap(soundButton.getChildAt(0)).smoothing = true;
return;
};
}
private function buzz(e:TimerEvent):void{
if (mouseOver == null){
return;
};
if (!(((((((myCoolShip.x > mouseOver.x)) && ((myCoolShip.y > mouseOver.y)))) && ((myCoolShip.x < (myCoolShip.x + mouseOver.width))))) && ((mouseOver.y < (mouseOver.y + mouseOver.height))))){
return;
};
lastMouseOver = mouseOver;
if (buzzState){
myCoolShip.glow(0xFF00);
buzzState = false;
mouseOver.x = (mouseOver.x + 1);
} else {
myCoolShip.glow(0xFFFFFF);
buzzState = true;
mouseOver.x = (mouseOver.x - 1);
};
}
private function BTTMBUnGlow(e:MouseEvent):void{
BTMMBContainer.filters = null;
}
}
}//package
Section 152
//Menu_backToMM (Menu_backToMM)
package {
import mx.core.*;
public class Menu_backToMM extends BitmapAsset {
}
}//package
Section 153
//Menu_conquestAsset (Menu_conquestAsset)
package {
import mx.core.*;
public class Menu_conquestAsset extends BitmapAsset {
}
}//package
Section 154
//Menu_creditsAsset (Menu_creditsAsset)
package {
import mx.core.*;
public class Menu_creditsAsset extends BitmapAsset {
}
}//package
Section 155
//Menu_creditsPageAsset (Menu_creditsPageAsset)
package {
import mx.core.*;
public class Menu_creditsPageAsset extends BitmapAsset {
}
}//package
Section 156
//Menu_galacticAsset (Menu_galacticAsset)
package {
import mx.core.*;
public class Menu_galacticAsset extends BitmapAsset {
}
}//package
Section 157
//Menu_galaxy (Menu_galaxy)
package {
import mx.core.*;
public class Menu_galaxy extends BitmapAsset {
}
}//package
Section 158
//Menu_jouerAsset (Menu_jouerAsset)
package {
import mx.core.*;
public class Menu_jouerAsset extends BitmapAsset {
}
}//package
Section 159
//Menu_loadAsset (Menu_loadAsset)
package {
import mx.core.*;
public class Menu_loadAsset extends BitmapAsset {
}
}//package
Section 160
//Menu_noSoundAsset (Menu_noSoundAsset)
package {
import mx.core.*;
public class Menu_noSoundAsset extends BitmapAsset {
}
}//package
Section 161
//Menu_pauseAsset (Menu_pauseAsset)
package {
import mx.core.*;
public class Menu_pauseAsset extends BitmapAsset {
}
}//package
Section 162
//Menu_soundAsset (Menu_soundAsset)
package {
import mx.core.*;
public class Menu_soundAsset extends BitmapAsset {
}
}//package
Section 163
//Menu_soundsfxAsset (Menu_soundsfxAsset)
package {
import mx.core.*;
public class Menu_soundsfxAsset extends BitmapAsset {
}
}//package
Section 164
//Menu_sponsorAsset (Menu_sponsorAsset)
package {
import mx.core.*;
public class Menu_sponsorAsset extends BitmapAsset {
}
}//package
Section 165
//Menu_statsmenu (Menu_statsmenu)
package {
import mx.core.*;
public class Menu_statsmenu extends BitmapAsset {
}
}//package
Section 166
//MenuBattle (MenuBattle)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.text.*;
import flash.filters.*;
public class MenuBattle extends MovieClip {
private var lineDrawerTimer:Timer;
private var arrow:Class;
private var displayMenuTimer:Timer;
public var isWon:Boolean;// = false
private var myMenuBattles:Array;
private var myArrow:MovieClip;
private var battleAsset:Class;
private var lineDestX:Number;
private var lineDestY:Number;
private var menu:MovieClip;
private var myContent:MovieClip;
private var noDoubleTimer:Timer;
private var animTimer:Timer;
private var myPosition:int;
private var timerCounter:int;// = 0
private var text:TextField;
private var yFinal:Number;
public function MenuBattle(xI:Number, yI:Number, menuBattles:Array, pos:int){
battleAsset = MenuBattle_battleAsset;
arrow = MenuBattle_arrow;
animTimer = new Timer(10);
lineDrawerTimer = new Timer(10);
displayMenuTimer = new Timer(5);
menu = new MovieClip();
noDoubleTimer = new Timer(2000);
super();
myMenuBattles = menuBattles;
myPosition = pos;
yFinal = yI;
x = xI;
y = -20;
myContent = new MovieClip();
myContent.graphics.lineStyle(2, 0xFFFFFF, 1);
myContent.graphics.beginFill(0xFF0000, 0.35);
myContent.graphics.drawRoundRect(0, 0, 10, 10, 4, 4);
myContent.graphics.endFill();
this.addChild(myContent);
this.buttonMode = true;
myContent.x = (-(myContent.width) / 2);
myContent.y = (-(myContent.height) / 2);
myContent.addEventListener(MouseEvent.MOUSE_OVER, glow, false, 0, true);
myContent.addEventListener(MouseEvent.MOUSE_OUT, unGlow, false, 0, true);
myContent.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
animTimer.addEventListener(TimerEvent.TIMER, anim, false, 0, true);
animTimer.start();
this.addChild(menu);
menu.x = (this.width / 2);
menu.y = -1;
if (myPosition == 0){
myArrow = new arrow();
myArrow.x = -8;
myArrow.y = -8;
this.addChild(myArrow);
};
noDoubleTimer.addEventListener(TimerEvent.TIMER, noDouble, false, 0, true);
}
private function glow(e:MouseEvent):void{
SoundManager.playSound("buzz");
if (this.parent != null){
this.parent.setChildIndex(this, (this.parent.numChildren - 1));
};
this.myContent.filters = [new GlowFilter(0xFFFFFF, 1, 5, 5)];
if (this.displayMenuTimer.running == false){
displayMenuTimer.removeEventListener(TimerEvent.TIMER, hideMenu);
displayMenuTimer = new Timer(10);
displayMenuTimer.addEventListener(TimerEvent.TIMER, displayMenu, false, 0, true);
this.displayMenu();
};
}
private function anim(e:TimerEvent):void{
this.y = (this.y + 5);
if (this.y >= this.yFinal){
animTimer.stop();
if (this.myPosition > 0){
MenuBattle(myMenuBattles[(myPosition - 1)]).drawLineTo(this.x, this.y);
};
return;
};
}
public function won():void{
if (myPosition == 0){
removeChild(myArrow);
myArrow = null;
};
isWon = true;
myContent.graphics.clear();
myContent.graphics.lineStyle(2, 0xFFFFFF, 1);
myContent.graphics.beginFill(0xFF00, 0.5);
myContent.graphics.drawRoundRect(0, 0, 10, 10, 4, 4);
myContent.graphics.endFill();
}
public function displayMenu(e:TimerEvent=null):void{
var style:TextFormat;
timerCounter = (timerCounter + 4);
if (displayMenuTimer.running == false){
displayMenuTimer.start();
};
if (timerCounter < 5){
menu.graphics.clear();
menu.graphics.moveTo(0, 0);
menu.graphics.lineStyle(2, 0xFFFFFF, 1);
menu.graphics.lineTo(timerCounter, 0);
};
if ((((timerCounter >= 5)) && ((timerCounter < 125)))){
menu.graphics.clear();
menu.graphics.lineStyle(2, 0xFFFFFF, 1);
menu.graphics.lineTo(5, 0);
menu.graphics.beginFill(0xFFFFFF, 0.4);
menu.graphics.drawRoundRect(5, 0, (timerCounter - 5), 0, 4, 4);
menu.graphics.endFill();
};
if ((((timerCounter >= 125)) && ((timerCounter < 145)))){
menu.graphics.clear();
menu.graphics.lineStyle(2, 0xFFFFFF, 1);
menu.graphics.lineTo(5, 0);
menu.graphics.beginFill(0xFFFFFF, 0.4);
menu.graphics.drawRoundRect(5, (-((timerCounter - 125)) / 2), 125, (timerCounter - 125), 4, 4);
menu.graphics.endFill();
};
if (timerCounter >= 145){
displayMenuTimer.stop();
timerCounter = 0;
text = new TextField();
text.x = 7;
text.y = -10;
if ((myPosition + 1) < 10){
text.text = (("Solar System:SS0" + (this.myPosition + 1)) + "0");
};
if ((myPosition + 1) >= 10){
text.text = (("Solar System:SS" + (this.myPosition + 1)) + "0");
};
text.width = 100;
text.height = 30;
text.autoSize = TextFieldAutoSize.LEFT;
text.selectable = false;
style = new TextFormat();
style.size = 12;
style.bold = true;
style.font = "Times New Roman";
text.setTextFormat(style);
menu.addChild(text);
};
}
private function unGlow(e:MouseEvent):void{
if (displayMenuTimer.running == false){
displayMenuTimer.removeEventListener(TimerEvent.TIMER, displayMenu);
displayMenuTimer = new Timer(10);
displayMenuTimer.addEventListener(TimerEvent.TIMER, hideMenu, false, 0, true);
displayMenuTimer.start();
} else {
displayMenuTimer.stop();
menu.graphics.clear();
};
this.myContent.filters = null;
}
public function hideMenu(e:TimerEvent=null):void{
timerCounter = (timerCounter + 4);
if (displayMenuTimer.running == false){
displayMenuTimer.start();
};
if ((((timerCounter >= 140)) && ((timerCounter < 146)))){
menu.graphics.clear();
menu.graphics.moveTo(0, 0);
menu.graphics.lineStyle(2, 0xFFFFFF, 1);
menu.graphics.lineTo((-1 * (timerCounter - 145)), 0);
};
if ((((timerCounter >= 20)) && ((timerCounter < 140)))){
menu.graphics.clear();
menu.graphics.lineStyle(2, 0xFFFFFF, 1);
menu.graphics.lineTo(5, 0);
menu.graphics.beginFill(0xFFFFFF, 0.4);
menu.graphics.drawRoundRect(5, 0, (140 - timerCounter), 0, 4, 4);
menu.graphics.endFill();
};
if (timerCounter < 20){
menu.graphics.clear();
menu.graphics.lineStyle(2, 0xFFFFFF, 1);
menu.graphics.lineTo(5, 0);
menu.graphics.beginFill(0xFFFFFF, 0.4);
menu.graphics.drawRoundRect(5, (-((20 - timerCounter)) / 2), 125, (20 - timerCounter), 4, 4);
menu.graphics.endFill();
};
if (timerCounter == 4){
if (((!((text == null))) && (!((text.stage == null))))){
menu.removeChild(text);
};
};
if (timerCounter >= 146){
menu.graphics.clear();
displayMenuTimer.stop();
timerCounter = 0;
};
}
private function drawLine(e:TimerEvent):void{
if (lineDrawerTimer.currentCount >= 20){
lineDrawerTimer.stop();
};
var lineCompletion:Number = (lineDrawerTimer.currentCount / 20);
this.graphics.clear();
this.graphics.lineStyle(4, 0xFFFFFF, 0.5);
this.graphics.moveTo(0, 0);
var myNextPos:Point = new Point(lineDestX, lineDestY);
myNextPos = this.globalToLocal(myNextPos);
this.graphics.lineTo((myNextPos.x * lineCompletion), (myNextPos.y * lineCompletion));
}
private function onClick(e:MouseEvent):void{
var myMenu:Menu = Menu(this.parent);
if (noDoubleTimer.running){
return;
};
noDoubleTimer.start();
SoundManager.playSound("zoomTransition");
var newGame:Game = new Game(this.myPosition, Menu(this.parent), isWon, this.x, this.y);
stage.addChild(newGame);
if (myMenu.shipJustBought){
newGame.addChild(new MenuWindow(115, 330, "When you have more than one ship available, you can choose what\nship you want to use with the menu in the top right hand corner.\nYou can also use 1,2,3 and 4 on your keyboard.", 10));
myMenu.shipJustBought = false;
};
if (myMenu.nanitesJustBought){
newGame.addChild(new MenuWindow(115, 330, "You can activate the nanites using the button in the top left hand corner.\nThe nanites will be working for a short period of time.\nThey will need some time to recharge before you can use them again.", 10));
myMenu.nanitesJustBought = false;
};
}
public function drawLineTo(destX:Number, destY:Number):void{
lineDestX = destX;
lineDestY = destY;
lineDrawerTimer.addEventListener(TimerEvent.TIMER, drawLine, false, 0, true);
lineDrawerTimer.start();
}
private function noDouble(e:TimerEvent):void{
noDoubleTimer.stop();
}
}
}//package
Section 167
//MenuBattle_arrow (MenuBattle_arrow)
package {
import mx.core.*;
import flash.utils.*;
public class MenuBattle_arrow extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function MenuBattle_arrow(){
dataClass = MenuBattle_arrow_dataClass;
super();
initialWidth = (2000 / 20);
initialHeight = (2000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 168
//MenuBattle_arrow_dataClass (MenuBattle_arrow_dataClass)
package {
import mx.core.*;
public class MenuBattle_arrow_dataClass extends ByteArrayAsset {
}
}//package
Section 169
//MenuBattle_battleAsset (MenuBattle_battleAsset)
package {
import mx.core.*;
public class MenuBattle_battleAsset extends BitmapAsset {
}
}//package
Section 170
//MenuWindow (MenuWindow)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import caurina.transitions.*;
import flash.text.*;
import flash.filters.*;
public class MenuWindow extends MovieClip {
private var cross:MovieClip;
private var myTextField:TextField;
private var finalY:Number;
private var isClosing:Boolean;// = false
private var myContent:Bitmap;
private var menuAsset:Class;
private var isTimed:int;// = 0
private var opening:Boolean;// = true
private var myText:String;
public function MenuWindow(xi:Number, yi:Number, text:String, timed:int=0){
var style:TextFormat;
var closeTimer:Timer;
menuAsset = MenuWindow_menuAsset;
cross = new MovieClip();
super();
this.alpha = 0.85;
isTimed = (timed * 1000);
if (isTimed != 0){
closeTimer = new Timer(isTimed);
closeTimer.addEventListener(TimerEvent.TIMER, closeFromTimer, false, 0, true);
closeTimer.start();
};
myText = text;
this.y = 480;
this.x = xi;
this.finalY = yi;
myContent = new menuAsset();
Tweener.addTween(this, {y:yi, time:1, transition:"easeOutBack", delay:0.5});
this.addChild(myContent);
this.addEventListener(MouseEvent.CLICK, this.close, false, 0, true);
style = new TextFormat();
style.color = 8890301;
style.bold = true;
style.font = "Times New Roman";
myTextField = new TextField();
myTextField.alpha = 0.4;
myTextField.selectable = false;
myTextField.x = 60;
myTextField.y = 40;
myTextField.height = 120;
myTextField.text = myText;
myTextField.setTextFormat(style);
this.addChild(myTextField);
myTextField.width = 0;
Tweener.addTween(myTextField, {width:390, time:4, delay:1});
cross.graphics.lineStyle(3, 0xFF0000);
cross.graphics.moveTo(0, 0);
cross.graphics.lineTo(7, 7);
cross.graphics.moveTo(7, 0);
cross.graphics.lineTo(0, 7);
cross.x = (this.width + 5);
cross.y = -5;
cross.filters = [new GlowFilter(16716049, 0.4, 6, 6)];
cross.buttonMode = true;
this.useHandCursor = true;
this.mouseChildren = false;
this.buttonMode = true;
}
private function closeFromTimer(e:TimerEvent):void{
close();
}
private function destroy():void{
if (this.parent != null){
this.parent.removeChild(this);
};
}
public function close(e:MouseEvent=null):void{
if (isClosing){
return;
};
isClosing = true;
Tweener.addTween(this, {y:485, time:0.5, transition:"easeInBack", onComplete:destroy});
}
}
}//package
Section 171
//MenuWindow_menuAsset (MenuWindow_menuAsset)
package {
import mx.core.*;
public class MenuWindow_menuAsset extends BitmapAsset {
}
}//package
Section 172
//MouseFollowerShip (MouseFollowerShip)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.ui.*;
public class MouseFollowerShip extends MovieClip {
private var myContent:Bitmap;
private var moveTimer:Timer;
private var myDirection:Number;
private var mySpeed:Number;// = 5
public function MouseFollowerShip(xi:Number, yi:Number){
moveTimer = new Timer(10);
super();
this.x = xi;
this.y = yi;
this.scaleX = (this.scaleY = 1.5);
var tempAsset:Assets = new Assets();
myContent = new Bitmap();
myContent.bitmapData = tempAsset.getAsset("sh1").bitmapData;
this.addChild(myContent);
myContent.x = ((-(myContent.width) / 2) - 2);
myContent.y = (-(myContent.height) / 2);
myContent.smoothing = true;
Mouse.hide();
moveTimer.addEventListener(TimerEvent.TIMER, move, false, 0, true);
moveTimer.start();
this.addEventListener(MouseEvent.MOUSE_OVER, mouseover, false, 0, true);
}
private function distanceBetween(p1:Point, p2:Point):Number{
var dist:*;
var dx:*;
var dy:Number;
dx = (p2.x - p1.x);
dy = (p2.y - p1.y);
dist = Math.sqrt(((dx * dx) + (dy * dy)));
return (dist);
}
private function mouseout(e:MouseEvent):void{
}
public function explode():void{
if (this.parent != null){
this.parent.removeChild(this);
};
this.moveTimer.stop();
Mouse.show();
}
private function move(e:TimerEvent):void{
var distance:Number = distanceBetween(new Point(this.x, this.y), new Point(stage.mouseX, stage.mouseY));
if (distance < 10){
return;
};
if (this.stage == null){
this.moveTimer.stop();
return;
};
var orientation:Number = AngleHelper.degreeBetween(new Point(this.x, this.y), new Point(stage.mouseX, stage.mouseY));
orientation = (orientation + (90 + 180));
myDirection = orientation;
var speed:Number = mySpeed;
mySpeed = 40;
speed = (mySpeed * (distance / 250));
this.rotation = myDirection;
var xSpeedVector:Number = (Math.cos(((Math.PI / 180) * myDirection)) * speed);
var ySpeedVector:Number = (Math.sin(((Math.PI / 180) * myDirection)) * speed);
glow(0xFFFFFF);
this.x = (this.x + xSpeedVector);
this.y = (this.y + ySpeedVector);
}
private function mouseover(e:MouseEvent):void{
Menu(parent).mouseOver = Menu(parent).lastMouseOver;
Menu(parent).buzzer.start();
}
public function glow(color:uint):void{
this.filters = [new GlowFilter(color, 0.7, 6, 6)];
}
}
}//package
Section 173
//MultiplayerGame (MultiplayerGame)
package {
import flash.display.*;
import come2play_as3.api.auto_generated.*;
import come2play_as3.api.auto_copied.*;
import flash.ui.*;
public class MultiplayerGame extends ClientGameAPI {
public var myID:int;
private var graphics:MovieClip;
private var alreadySwitchOwners:Boolean;// = false
private var myLevel:int;
private var myGame:Game;
public function MultiplayerGame(graphics:MovieClip, level:int){
new OnlineAction().register();
this.graphics = graphics;
myLevel = level;
super(graphics);
AS3_vs_AS2.waitForStage(graphics, constructGame);
}
override public function gotMatchEnded(finishedPlayerIds:Array):void{
}
private function initGame():void{
var myMenu:Menu = new Menu();
graphics.stage.addChild(myMenu);
myMenu.openGalaxyMap();
Mouse.show();
myGame = new Game(myLevel, myMenu);
myGame.multiplayerControl = this;
myGame.myAI.AITimer.stop();
myGame.myAI.defenseTimer.stop();
myGame.isPaused = true;
graphics.stage.addChild(myGame);
myGame.myAI.impulseDrive = false;
myGame.myAI.destroyers = false;
myGame.myAI.deathStar = false;
myGame.myAI.cruiser = false;
}
override public function gotUserInfo(userId:int, infoEntries:Array):void{
}
override public function gotMatchStarted(allPlayerIds:Array, finishedPlayerIds:Array, serverEntries:Array):void{
myGame.isPaused = false;
}
private function constructGame():void{
doRegisterOnServer();
}
override public function gotStateChanged(serverEntries:Array):void{
var serverEntry:ServerEntry = serverEntries[0];
var thisAction:OnlineAction = serverEntry.value;
var destination:Planet = Planet(myGame.mySpace.myPlanets[thisAction.destination]);
var owner:int = thisAction.owner;
var shipType:int = thisAction.shipType;
var i:int;
while (i < myGame.mySpace.myPlanets.length) {
if (i == thisAction.from){
Planet(myGame.mySpace.myPlanets[i]).sendFleet(destination, shipType);
};
i++;
};
}
override public function gotCustomInfo(infoEntries:Array):void{
this.myID = (T.custom(CUSTOM_INFO_KEY_myUserId, null) as int);
this.myLevel = (T.custom("level", 5) as int);
initGame();
if (myID == 1){
inverseOwners();
};
}
override public function gotKeyboardEvent(isKeyDown:Boolean, charCode:int, keyCode:int, keyLocation:int, altKey:Boolean, ctrlKey:Boolean, shiftKey:Boolean):void{
}
private function inverseOwners():void{
var lastChanged:Planet;
var i:int;
if (alreadySwitchOwners == true){
return;
};
alreadySwitchOwners = true;
if (myID == 1){
i = 0;
while (i < myGame.mySpace.myPlanets.length) {
if (myGame.mySpace.myPlanets[i].myOwner == 1){
Planet(myGame.mySpace.myPlanets[i]).changeOwner(2);
lastChanged = myGame.mySpace.myPlanets[i];
};
if ((((myGame.mySpace.myPlanets[i].myOwner == 2)) && (!((myGame.mySpace.myPlanets[i] == lastChanged))))){
Planet(myGame.mySpace.myPlanets[i]).changeOwner(1);
};
i++;
};
};
}
}
}//package
Section 174
//MusicTimer (MusicTimer)
package {
import flash.events.*;
import flash.utils.*;
import caurina.transitions.*;
import flash.media.*;
import caurina.transitions.properties.*;
public class MusicTimer extends Timer {
private var mySoundChannel:SoundChannel;
public function MusicTimer(delay:Number, repeatCount:int=0, soundChannel:SoundChannel=null){
super(delay, repeatCount);
mySoundChannel = soundChannel;
}
public function selfExecute(e:TimerEvent):void{
var mySound:Sound;
var musicChannel:SoundChannel;
var t:MusicTimer;
SoundShortcuts.init();
Tweener.addTween(mySoundChannel, {_sound_volume:0, time:4, transition:"linear"});
var random:Number = RandomNumber.generate(1, 4);
mySound = new SoundManager.music();
musicChannel = mySound.play(200);
musicChannel.soundTransform = new SoundTransform(0);
Tweener.addTween(musicChannel, {_sound_volume:0.5, time:4, transition:"linear"});
t = new MusicTimer(75000, 1, musicChannel);
t.addEventListener(TimerEvent.TIMER, t.selfExecute);
t.start();
this.stop();
}
}
}//package
Section 175
//MyLoader (MyLoader)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import CPMStar.*;
import flash.filters.*;
import flash.utils.*;
import flash.net.*;
public class MyLoader extends MovieClip {
private var loadingBG:Class;
private var ad:DisplayObject;
private var loadingBarTexture:Class;
private var sponsorLogo:MovieClip;
private var sponsorLogoAsset:Class;
private var alreadyClosed:Boolean;// = false
var t:TextField;
private var readyToClose:Boolean;// = false
private var loadingBar:MovieClip;
public function MyLoader(){
sponsorLogoAsset = MyLoader_sponsorLogoAsset;
loadingBarTexture = MyLoader_loadingBarTexture;
loadingBG = MyLoader_loadingBG;
loadingBar = new MovieClip();
super();
stop();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
this.addChild(new loadingBG());
this.addChild(loadingBar);
loadingBar.filters = [new GlowFilter(0xFFFFFF)];
var style:TextFormat = new TextFormat();
style.color = 0xFFFFFF;
style.size = 20;
style.font = "Times New Roman";
style.bold = true;
t = new TextField();
t.x = 280;
t.y = (stage.stageHeight - 60);
t.text = "Loading...";
t.filters = [new GlowFilter(0xFFFFFF, 1, 1, 1)];
t.setTextFormat(style);
this.addChild(t);
var CPMStarContentSpotID:String = "810Q204203CC";
ad = new AdLoader(CPMStarContentSpotID);
this.addChild(ad);
ad.y = 100;
ad.x = 50;
ad.filters = [new GlowFilter(0xFFFFFF, 1, 24, 25)];
var sponsorLogoBitmap:Bitmap = new sponsorLogoAsset();
sponsorLogo = new MovieClip();
sponsorLogo.addChild(sponsorLogoBitmap);
this.addChild(sponsorLogo);
sponsorLogo.x = 400;
sponsorLogo.y = (ad.y + 80);
sponsorLogo.filters = [new GlowFilter(0xFFFFFF, 1, 6, 6)];
sponsorLogo.addEventListener(MouseEvent.CLICK, sponsorClick, false, 0, true);
sponsorLogo.useHandCursor = true;
sponsorLogo.buttonMode = true;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
var displayTimeTimer:Timer = new Timer(10000, 1);
displayTimeTimer.addEventListener(TimerEvent.TIMER, allowExit);
displayTimeTimer.start();
}
private function allowExit(e:TimerEvent):void{
this.readyToClose = true;
onEnterFrame();
}
public function onEnterFrame(event:Event=null):void{
var style:TextFormat;
var percent:Number;
if (framesLoaded == totalFrames){
nextFrame();
loadingBar.graphics.clear();
loadingBar.graphics.beginBitmapFill(Bitmap(new loadingBarTexture()).bitmapData);
loadingBar.graphics.drawRect(7, (stage.stageHeight - 30), (stage.stageWidth - 12), 20);
loadingBar.graphics.endFill();
style = new TextFormat();
t.width = 200;
t.x = 250;
style.color = 0xFFFFFF;
style.size = 20;
style.font = "Times New Roman";
style.bold = true;
t.text = "Please Wait...";
t.setTextFormat(style);
init();
} else {
loadingBar.graphics.clear();
percent = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
loadingBar.graphics.beginBitmapFill(Bitmap(new loadingBarTexture()).bitmapData);
loadingBar.graphics.drawRect(7, (stage.stageHeight - 30), ((stage.stageWidth - 12) * percent), 20);
loadingBar.graphics.endFill();
loadingBar.graphics.lineStyle(1, 0xFFFFFF);
loadingBar.graphics.drawRect(5, (stage.stageHeight - 32), (stage.stageWidth - 10), 22);
};
}
private function init():void{
var app:Object;
if (readyToClose == false){
return;
};
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
alreadyClosed = true;
if (t.parent != null){
t.parent.removeChild(t);
};
if (ad.parent != null){
ad.parent.removeChild(ad);
};
if (sponsorLogo.parent != null){
sponsorLogo.parent.removeChild(sponsorLogo);
};
loadingBar.graphics.clear();
var mainClass:Class = Class(getDefinitionByName("GalacticExpansion"));
if (mainClass){
app = new (mainClass);
addChild((app as DisplayObject));
};
}
public function sponsorClick(e:MouseEvent):void{
trace("Click");
navigateToURL(new URLRequest("http://www.flashgamesnexus.com/"), "_blank");
}
}
}//package
Section 176
//MyLoader_loadingBarTexture (MyLoader_loadingBarTexture)
package {
import mx.core.*;
public class MyLoader_loadingBarTexture extends BitmapAsset {
}
}//package
Section 177
//MyLoader_loadingBG (MyLoader_loadingBG)
package {
import mx.core.*;
public class MyLoader_loadingBG extends BitmapAsset {
}
}//package
Section 178
//MyLoader_sponsorLogoAsset (MyLoader_sponsorLogoAsset)
package {
import mx.core.*;
public class MyLoader_sponsorLogoAsset extends BitmapAsset {
}
}//package
Section 179
//OnlineAction (OnlineAction)
package {
import come2play_as3.api.auto_copied.*;
public class OnlineAction extends SerializableClass {
public var owner:int;
public var from:int;
public var shipType:int;
public var destination:int;
public function OnlineAction(){
super();
}
public static function create(origin:Planet, destination:Planet, shipType:int, owner:int):OnlineAction{
var res:OnlineAction = new (OnlineAction);
res.from = origin.id;
res.destination = destination.id;
res.owner = owner;
res.shipType = shipType;
return (res);
}
}
}//package
Section 180
//Planet (Planet)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import caurina.transitions.*;
import flash.geom.*;
import come2play_as3.api.auto_generated.*;
import flash.text.*;
public class Planet extends PlanetSprite {
public var distanceToSelectedPlanet:Number;
private var arrow:Class;
private var productionTimer:Timer;
public var isDestroyed:Boolean;// = false
public var myMax:int;
public var id:int;// = 0
private var unitDisplay:TextField;
public var myUnits:Number;// = 10
private var defensiveLaser:Boolean;// = false
private var laserEraser:Timer;
private var laserTimer:Timer;
private var explosionLayer:Bitmap;
private var nameDisplay:TextField;
private var soundPlayed:Boolean;// = false
public var mySize:int;// = 0
private var myGame:Game;
private var myName:String;
public var myOwner:Number;// = 0
private var moveTimer:Timer;
public function Planet(parentGame:Game, xI:Number, yI:Number, spriteId:int=1, size:Number=1, owner:Number=0){
arrow = Planet_arrow;
productionTimer = new Timer(1000);
laserTimer = new Timer(1000);
laserEraser = new Timer(100);
moveTimer = new Timer(15);
super(parentGame, spriteId, size);
id = parentGame.mySpace.myPlanets.length;
this.x = xI;
this.y = yI;
myGame = parentGame;
myOwner = owner;
mySize = size;
if (myOwner == 0){
this.glow(0xFFFFFF);
};
if (myOwner == 1){
this.glow(0xFF00);
};
if (myOwner == 2){
this.glow(0xFF0000);
};
if (myOwner == 3){
this.glow(0xFF);
};
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut, false, 0, true);
productionTimer.addEventListener(TimerEvent.TIMER, addUnit, false, 0, true);
productionTimer.start();
if (size == 1){
productionTimer.delay = 2000;
};
if (size == 2){
productionTimer.delay = 1000;
};
if (size == 3){
productionTimer.delay = 500;
};
if (size == 4){
productionTimer.delay = 250;
};
if (myOwner == 0){
myUnits = 0;
};
var style:TextFormat = new TextFormat();
style.color = 0xFFFFFF;
nameDisplay = new TextField();
nameDisplay.x = (this.x + 20);
nameDisplay.y = (this.y - 27);
nameDisplay.height = 18;
nameDisplay.border = false;
if ((myGame.levelNumber + 1) < 10){
nameDisplay.text = (("Name:P0" + (myGame.levelNumber + 1)) + RandomNumber.generate(0, 9));
};
if ((myGame.levelNumber + 1) >= 10){
nameDisplay.text = (("Name:P" + (myGame.levelNumber + 1)) + RandomNumber.generate(0, 9));
};
nameDisplay.selectable = false;
nameDisplay.setTextFormat(style);
unitDisplay = new TextField();
unitDisplay.x = (this.x + 20);
unitDisplay.y = (this.y - 17);
unitDisplay.height = 18;
unitDisplay.border = false;
unitDisplay.selectable = false;
unitDisplay.text = ("Unit:" + myUnits);
unitDisplay.setTextFormat(style);
laserTimer.addEventListener(TimerEvent.TIMER, laserCreator, false, 0, true);
laserEraser.addEventListener(TimerEvent.TIMER, clearGraphics, false, 0, true);
if ((((myOwner == 1)) && ((myGame.myMenu.defensiveLaser == true)))){
defensiveLaser = true;
};
if ((((myOwner == 2)) && ((myGame.myAI.defensiveLaser == true)))){
defensiveLaser = true;
};
if (defensiveLaser){
laserTimer.start();
};
if ((((this.myGame.levelNumber == 0)) && ((this.myOwner == 2)))){
myUnits = 5;
};
this.updateText();
if (this.myGame.mySpace.mySun != null){
moveTimer.addEventListener(TimerEvent.TIMER, mover, false, 0, true);
moveTimer.start();
};
if (size == 1){
myMax = 20;
};
if (size == 2){
myMax = 30;
};
if (size == 3){
myMax = 50;
};
if (size == 4){
myMax = 200;
};
if ((((size == 1)) && ((this.myOwner == 3)))){
myUnits = 10;
};
if ((((size == 2)) && ((this.myOwner == 3)))){
myUnits = 20;
};
if ((((size == 3)) && ((this.myOwner == 3)))){
myUnits = 30;
};
if ((((size == 4)) && ((this.myOwner == 3)))){
myUnits = 40;
};
updateText();
this.addEventListener(Event.ADDED_TO_STAGE, ats, false, 0, true);
}
public function setSize(size:Number):void{
mySize = size;
var fSize:Number = 1;
if (size == 1){
fSize = 0.45;
};
if (size == 2){
fSize = 0.6;
};
if (size == 3){
fSize = 0.8;
};
if (size == 4){
fSize = 0.86;
};
this.scaleX = (this.scaleY = fSize);
}
public function hit(strength:Number, owner):void{
if (owner == this.myOwner){
if ((((((strength == 1)) || ((strength == 2)))) || ((strength == 4)))){
this.myUnits = (this.myUnits + strength);
};
if (strength == 35){
this.myUnits = (this.myUnits + 20);
};
if (strength > 35){
this.myUnits = (this.myUnits + strength);
};
};
if (((!((owner == this.myOwner))) && (!((this.myOwner == 0))))){
this.myUnits = (this.myUnits - strength);
};
if (this.myOwner == 0){
this.changeOwner(owner);
this.myUnits = (this.myUnits + strength);
};
if (this.myUnits == 0){
this.changeOwner(0);
};
if (this.myUnits < 0){
this.myUnits = Math.abs(this.myUnits);
this.changeOwner(owner);
};
this.updateText();
}
public function updateText(destroy:Boolean=false):void{
if (destroy){
unitDisplay.text = "";
nameDisplay.text = "";
if (unitDisplay.parent != null){
unitDisplay.parent.removeChild(unitDisplay);
};
if (nameDisplay.parent != null){
nameDisplay.parent.removeChild(nameDisplay);
};
return;
};
if (myUnits < 0){
myUnits = Math.abs(myUnits);
};
unitDisplay.text = ("Unit:" + myUnits);
var style:TextFormat = new TextFormat();
style.color = 0xFFFFFF;
unitDisplay.setTextFormat(style);
}
private function ats(e:Event):void{
this.myGame.mySpace.addChild(nameDisplay);
this.myGame.mySpace.addChild(unitDisplay);
}
public function sendFleet(destination:Planet, type:int):void{
if (destination == this){
return;
};
var soundfx:String = "";
if (myOwner == 1){
soundfx = "close";
} else {
soundfx = "nothing";
};
if (type == 2){
if ((myUnits - 2) < 0){
SoundManager.playSound(soundfx);
return;
};
};
if (type == 3){
if ((myUnits - 20) < 0){
SoundManager.playSound(soundfx);
return;
};
};
if (type == 4){
if ((myUnits - 100) < 0){
SoundManager.playSound(soundfx);
return;
};
};
this.myUnits--;
if (type == 2){
myUnits--;
};
if (type == 3){
myUnits = (myUnits - 19);
};
if (type == 4){
myUnits = (myUnits - 99);
};
if (myUnits < 0){
myUnits = 0;
return;
};
this.updateText();
this.myGame.mySpace.addFleet(this, destination, type);
}
public function setAISelectedPlanet(planet:Planet):void{
this.distanceToSelectedPlanet = distanceTo(planet);
}
public function centerExplosion():void{
explosionLayer.x = (-(explosionLayer.width) / 2);
explosionLayer.y = (-(explosionLayer.height) / 2);
}
private function mover(e:TimerEvent):void{
if (myGame.isPaused){
return;
};
var speed:Number = 0.5;
var orientation:Number = AngleHelper.degreeBetween(new Point(this.x, this.y), new Point(myGame.mySpace.mySun.x, myGame.mySpace.mySun.y));
var xSpeedVector:Number = (Math.cos(((Math.PI / 180) * orientation)) * speed);
var ySpeedVector:Number = (Math.sin(((Math.PI / 180) * orientation)) * speed);
this.x = (this.x + xSpeedVector);
this.y = (this.y + ySpeedVector);
nameDisplay.x = (this.x + 20);
nameDisplay.y = (this.y - 27);
unitDisplay.x = (this.x + 20);
unitDisplay.y = (this.y - 17);
}
private function addUnit(e:TimerEvent):void{
if (myGame.nanitesStatus == "inUse"){
if (myOwner == 1){
if (mySize == 1){
productionTimer.delay = 700;
};
if (mySize == 2){
productionTimer.delay = 400;
};
if (mySize == 3){
productionTimer.delay = 300;
};
if (mySize == 4){
productionTimer.delay = 190;
};
};
} else {
if (mySize == 1){
productionTimer.delay = 2000;
};
if (mySize == 2){
productionTimer.delay = 1000;
};
if (mySize == 3){
productionTimer.delay = 500;
};
if (mySize == 4){
productionTimer.delay = 250;
};
};
if (myGame.isPaused){
return;
};
if ((((this.myOwner == 0)) || ((this.myOwner == 3)))){
return;
};
if (mySize == 1){
if (myUnits >= 20){
return;
};
};
if (mySize == 2){
if (myUnits >= 30){
return;
};
};
if (mySize == 3){
if (myUnits >= 50){
return;
};
};
if (mySize == 4){
if (myUnits >= 200){
return;
};
};
this.myUnits++;
this.updateText();
}
public function distanceTo(planet:Planet):Number{
return (distanceBetween(new Point(this.x, this.y), new Point(planet.x, planet.y)));
}
private function distanceBetween(p1:Point, p2:Point):Number{
var dist:*;
var dx:*;
var dy:Number;
dx = (p2.x - p1.x);
dy = (p2.y - p1.y);
dist = Math.sqrt(((dx * dx) + (dy * dy)));
return (dist);
}
private function laserCreator(e:TimerEvent):void{
var distance:Number;
var spaceShipPos:Point;
var i:int;
while (i < myGame.mySpace.myFleets.length) {
if ((((Fleet(myGame.mySpace.myFleets[i]).luck == 1)) && (!((Fleet(myGame.mySpace.myFleets[i]).myOwner == this.myOwner))))){
spaceShipPos = new Point(Fleet(myGame.mySpace.myFleets[i]).x, Fleet(myGame.mySpace.myFleets[i]).y);
distance = distanceBetween(new Point(this.x, this.y), spaceShipPos);
if (distance < 75){
SoundManager.playSound("laser");
this.graphics.lineStyle(2, 0xFF0000, 0.9);
spaceShipPos = this.globalToLocal(spaceShipPos);
this.graphics.lineTo(spaceShipPos.x, spaceShipPos.y);
laserEraser.start();
if (Fleet(myGame.mySpace.myFleets[i]) != null){
Fleet(myGame.mySpace.myFleets[i]).explode();
};
return;
};
};
i++;
};
}
public function changeOwner(owner:int):void{
var temp:Array;
var i:int;
this.myOwner = owner;
if (myOwner == 0){
this.glow(0xFFFFFF);
};
if (myOwner == 1){
this.glow(0xFF00);
};
if (myOwner == 2){
this.glow(0xFF0000);
};
if (owner != 1){
temp = new Array();
i = 0;
while (i < myGame.planetSelected.length) {
if (myGame.planetSelected[i] != this){
temp.push(myGame.planetSelected[i]);
};
i++;
};
myGame.planetSelected = temp;
this.myGame.lineMC.graphics.clear();
this.myGame.drawLines(new Event(Event.ENTER_FRAME));
};
if (myGame.myMenu == null){
return;
};
defensiveLaser = false;
if ((((myOwner == 1)) && ((myGame.myMenu.defensiveLaser == true)))){
defensiveLaser = true;
};
if ((((myOwner == 2)) && ((myGame.myAI.defensiveLaser == true)))){
defensiveLaser = true;
};
if (defensiveLaser){
laserTimer.start();
} else {
laserTimer.stop();
};
myGame.onOwnerChange();
}
private function onClick(e:MouseEvent):void{
var helpArrow:MovieClip;
var i:int;
var myAction:OnlineAction;
if (myGame.isPaused){
return;
};
if ((((myGame.levelNumber == 0)) && ((this.numChildren > 1)))){
this.removeChildAt(1);
if (this.myOwner == 1){
helpArrow = new arrow();
helpArrow.x = -30;
helpArrow.y = -30;
helpArrow.scaleX = (helpArrow.scaleY = 5);
this.myGame.mySpace.myPlanets[1].addChild(helpArrow);
};
};
if ((((myOwner == 1)) && ((myGame.planetSelected.length == 0)))){
SoundManager.playSound("buttonClick");
};
if (((e.shiftKey) && ((this.myOwner == 1)))){
myGame.planetSelected.push(this);
return;
};
if ((((this.myOwner == 1)) && ((this.myGame.planetSelected.length == 0)))){
myGame.planetSelected = [this];
} else {
if (myGame.planetSelected.length > 0){
i = 0;
while (i < myGame.planetSelected.length) {
if (myGame.planetSelected[i].myUnits > 0){
if (myGame.multiplayerControl != null){
myAction = OnlineAction.create(myGame.planetSelected[i], this, myGame.mySpaceShipSelectioner.selected, myGame.planetSelected[i].myOwner);
myGame.multiplayerControl.doStoreState([UserEntry.create("F", myAction)]);
} else {
Planet(myGame.planetSelected[i]).sendFleet(this, myGame.mySpaceShipSelectioner.selected);
};
};
i++;
};
};
};
}
private function onMouseOut(e:MouseEvent):void{
this.myGame.overAttackablePlanet = false;
}
public function explode(step:int=0):void{
var z:Timer;
var step = step;
this.isDestroyed = true;
this.updateText(true);
z = new Timer(2800);
z.addEventListener(TimerEvent.TIMER, function (e:TimerEvent){
if (soundPlayed){
return;
};
soundPlayed = true;
SoundManager.playSound("planetExplosion");
z.stop();
});
z.start();
if (step == 0){
explosionLayer = new Bitmap();
explosionLayer.bitmapData = myGame.myAssets.getAsset("planetExplosion").bitmapData;
explosionLayer.alpha = 0;
explosionLayer.scaleX = (explosionLayer.scaleY = 0.8);
explosionLayer.x = (-(explosionLayer.width) / 2);
explosionLayer.y = (-(explosionLayer.height) / 2);
Tweener.addTween(explosionLayer, {transition:"easeInExpo", alpha:1, scaleX:1, scaleY:1, time:3, onUpdate:centerExplosion, onComplete:explode2});
this.addChild(explosionLayer);
};
if (step == 2){
myContent.alpha = 0;
Tweener.addTween(explosionLayer, {scaleX:0.01, scaleY:0.01, time:1, onUpdate:centerExplosion, onComplete:removeSelf});
};
}
public function explode2():void{
explode(2);
}
public function removeSelf():void{
var i:int;
var temp:Array = new Array();
i = 0;
while (i < myGame.planetSelected.length) {
if (myGame.planetSelected[i] != this){
temp.push(myGame.planetSelected[i]);
};
i++;
};
myGame.planetSelected = temp;
myGame.lineMC.graphics.clear();
temp = new Array();
i = 0;
while (i < myGame.mySpace.myPlanets.length) {
if (myGame.mySpace.myPlanets[i] != this){
temp.push(myGame.mySpace.myPlanets[i]);
};
i++;
};
myGame.mySpace.myPlanets = temp;
i = 0;
while (i < myGame.mySpace.myFleets.length) {
if (Fleet(myGame.mySpace.myFleets[i]).myDestination == this){
Fleet(myGame.mySpace.myFleets[i]).myDestination = Fleet(myGame.mySpace.myFleets[i]).myOrigin;
};
i++;
};
if (this.parent != null){
this.parent.removeChild(this);
};
this.moveTimer.stop();
laserTimer.stop();
laserEraser.stop();
myGame.checkGameStatus();
}
private function clearGraphics(e:TimerEvent):void{
this.graphics.clear();
laserEraser.stop();
}
private function onMouseOver(e:MouseEvent):void{
this.myGame.overAttackablePlanet = true;
}
}
}//package
Section 181
//Planet_arrow (Planet_arrow)
package {
import mx.core.*;
import flash.utils.*;
public class Planet_arrow extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function Planet_arrow(){
dataClass = Planet_arrow_dataClass;
super();
initialWidth = (2000 / 20);
initialHeight = (2000 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 182
//Planet_arrow_dataClass (Planet_arrow_dataClass)
package {
import mx.core.*;
public class Planet_arrow_dataClass extends ByteArrayAsset {
}
}//package
Section 183
//PlanetSprite (PlanetSprite)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.filters.*;
public class PlanetSprite extends MovieClip {
private var rotateTimer:Timer;
private var rotateSpeed:Number;// = 0.2
protected var myContent:Bitmap;
public function PlanetSprite(parentGame:Game, spriteId:int=0, size:Number=0.5){
rotateTimer = new Timer(50);
super();
myContent = new Bitmap();
myContent.smoothing = true;
myContent.bitmapData = parentGame.myAssets.getAsset(("p" + spriteId.toString())).bitmapData;
this.addChild(myContent);
myContent.x = (-(myContent.width) / 2);
myContent.y = (-(myContent.height) / 2);
rotateTimer.addEventListener(TimerEvent.TIMER, rotate, false, 0, true);
this.rotateSpeed = (RandomNumber.generate(1, 4) - 2);
if (this.rotateSpeed == 0){
this.rotateSpeed = (0.5 * (RandomNumber.generate(0, 1) - 1));
};
if (this.rotateSpeed == 0){
this.rotateSpeed = 0.25;
};
myContent.smoothing = true;
}
public function glow(color:uint):void{
var myGlow:GlowFilter = new GlowFilter(color, 1, 20, 20, 1);
this.myContent.filters = [myGlow];
}
public function unGlow():void{
this.myContent.filters = null;
}
private function rotate(e:TimerEvent):void{
this.rotation = (this.rotation + rotateSpeed);
}
}
}//package
Section 184
//RandomNumber (RandomNumber)
package {
public class RandomNumber {
public function RandomNumber(){
super();
}
public static function generate(low:int, high:int):int{
return ((Math.round((Math.random() * (high - low))) + low));
}
}
}//package
Section 185
//Reporter (Reporter)
package {
import flash.display.*;
import mochi.as3.*;
public class Reporter {
public function Reporter(){
super();
}
public static function initialize(container:MovieClip):void{
var sm:ScoresMenu = new ScoresMenu();
container.addChild(sm);
MochiServices.connect("f5af4f0e1a4f9d7c", sm);
}
public static function sendScore(level:int, time:Number, closeFn:Function, stage:Stage):void{
var o:Object;
var boardID:String;
var level = level;
var time = time;
var closeFn = closeFn;
var stage = stage;
var i:int;
while (i < stage.numChildren) {
if ((stage.getChildAt(i) is ScoresMenu)){
stage.setChildIndex(stage.getChildAt(i), (stage.numChildren - 1));
};
i = (i + 1);
};
var playerscore:Number = time;
if (level == 0){
o = {n:[2, 8, 11, 0, 11, 4, 4, 10, 11, 12, 3, 7, 11, 8, 15, 8], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 1){
o = {n:[15, 4, 12, 10, 15, 9, 13, 10, 11, 13, 5, 2, 5, 14, 14, 7], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 2){
o = {n:[4, 9, 11, 5, 7, 15, 3, 14, 13, 6, 10, 0, 5, 7, 7, 14], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 3){
o = {n:[3, 10, 4, 5, 1, 4, 1, 13, 14, 0, 0, 7, 0, 4, 0, 10], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 4){
o = {n:[8, 10, 7, 2, 1, 11, 6, 14, 8, 11, 5, 15, 3, 14, 8, 10], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 5){
o = {n:[15, 6, 9, 3, 4, 1, 8, 8, 9, 7, 9, 12, 9, 0, 9, 3], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 6){
o = {n:[10, 7, 8, 12, 5, 8, 11, 4, 6, 12, 3, 5, 14, 3, 8, 0], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 7){
o = {n:[9, 2, 12, 8, 2, 3, 3, 0, 12, 14, 4, 10, 14, 8, 6, 1], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 8){
o = {n:[8, 6, 6, 5, 12, 13, 5, 8, 8, 11, 1, 10, 11, 3, 11, 7], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 9){
o = {n:[3, 2, 0, 10, 11, 2, 5, 15, 15, 0, 13, 3, 14, 11, 14, 3], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 10){
o = {n:[10, 4, 0, 5, 1, 0, 6, 3, 4, 4, 5, 1, 10, 4, 15, 6], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 11){
o = {n:[2, 15, 8, 6, 0, 13, 8, 12, 3, 2, 14, 7, 12, 10, 6, 14], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 12){
o = {n:[2, 8, 6, 1, 14, 14, 14, 4, 1, 3, 10, 0, 6, 2, 15, 4], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 13){
o = {n:[2, 14, 1, 7, 12, 5, 13, 7, 12, 1, 6, 2, 6, 8, 13, 5], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 14){
o = {n:[10, 12, 4, 14, 2, 4, 14, 2, 8, 9, 2, 11, 15, 5, 13, 1], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 15){
o = {n:[1, 6, 0, 5, 3, 5, 10, 4, 14, 10, 0, 9, 1, 9, 2, 11], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 16){
o = {n:[5, 6, 1, 7, 3, 13, 12, 12, 12, 9, 7, 9, 2, 2, 8, 14], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
if (level == 17){
o = {n:[12, 9, 0, 7, 4, 3, 2, 3, 6, 6, 3, 14, 11, 10, 4, 5], f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
boardID = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:playerscore, onClose:closeFn});
};
}
public static function clear(stage:Stage):void{
var scoreMenu:ScoresMenu;
var i:int;
while (i < stage.numChildren) {
if ((stage.getChildAt(i) is ScoresMenu)){
scoreMenu = ScoresMenu(stage.getChildAt(i));
};
i++;
};
if (scoreMenu == null){
return;
};
i = 0;
while (i < scoreMenu.numChildren) {
scoreMenu.removeChildAt(i);
i++;
};
}
}
}//package
Section 186
//ResearchMenu (ResearchMenu)
package {
import flash.events.*;
import flash.display.*;
import caurina.transitions.*;
import flash.text.*;
import flash.filters.*;
public class ResearchMenu extends MovieClip {
private var deathStarPrice:int;// = 100000
private var buyAsset:Class;
private var cruiserPrice:int;// = 25000
private var upgrade1:TextField;
private var upgrade2:TextField;
private var upgrade3:TextField;
private var upgrade4:TextField;
private var upgrade5:TextField;
private var upgrade6:TextField;
private var upgrade7:TextField;
private var defLaserPrice:int;// = 9000
private var finalX:Number;
private var finalY:Number;
private var myMenu:Menu;
private var isClosing:Boolean;// = false
private var impulseDrivePrice:int;// = 3000
private var shieldsPrice:int;// = 23000
private var creditsAvailable:TextField;
private var rmenu:Class;
private var destroyerPrice:int;// = 6000
private var graybuyAsset:Class;
private var bb1:MovieClip;
private var bb2:MovieClip;
private var bb3:MovieClip;
private var bb4:MovieClip;
private var bb5:MovieClip;
private var bb6:MovieClip;
private var bb7:MovieClip;
private var nanitesPrice:int;// = 15000
public function ResearchMenu(menu:Menu){
var menu = menu;
buyAsset = ResearchMenu_buyAsset;
graybuyAsset = ResearchMenu_graybuyAsset;
rmenu = ResearchMenu_rmenu;
creditsAvailable = new TextField();
upgrade1 = new TextField();
upgrade2 = new TextField();
upgrade3 = new TextField();
upgrade4 = new TextField();
upgrade5 = new TextField();
upgrade6 = new TextField();
upgrade7 = new TextField();
bb1 = new MovieClip();
bb2 = new MovieClip();
bb3 = new MovieClip();
bb4 = new MovieClip();
bb5 = new MovieClip();
bb6 = new MovieClip();
bb7 = new MovieClip();
this.alpha = 0.9;
super();
myMenu = menu;
this.y = 100;
this.x = -440;
Tweener.addTween(this, {x:100, time:1, transition:"easeOutBack"});
var researchWindow:Bitmap = new rmenu();
this.addChild(researchWindow);
researchWindow.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
bb1.filters = null;
bb2.filters = null;
bb3.filters = null;
bb4.filters = null;
bb5.filters = null;
});
this.addChild(creditsAvailable);
buildMenu();
this.addEventListener(Event.ADDED_TO_STAGE, ats);
}
private function buyDeathStar(e:MouseEvent):void{
var e = e;
if (myMenu.myStatsMenu.myMoney < this.deathStarPrice){
return;
};
SoundManager.playSound("buttonClick");
Tweener.addTween(bb7, {alpha:0, time:0.5, onComplete:function (){
bb7.visible = false;
}});
if (myMenu.deathStar){
return;
};
myMenu.deathStar = true;
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney - deathStarPrice));
buildMenu();
}
private function buildMenu():void{
var style:TextFormat;
var buyButton:Bitmap;
var cross:MovieClip = new MovieClip();
cross.graphics.lineStyle(3, 0xFF0000);
cross.graphics.moveTo(0, 0);
cross.graphics.lineTo(10, 10);
cross.graphics.moveTo(10, 0);
cross.graphics.lineTo(0, 10);
cross.x = (this.width - 45);
cross.y = 40;
cross.filters = [new GlowFilter(16716049, 1, 3, 3)];
cross.graphics.lineStyle(0.01, 0xFFFFFF, 0.2);
cross.graphics.beginFill(0x111111, 0.02);
cross.graphics.drawRect(-5, -5, 20, 20);
cross.buttonMode = true;
cross.cacheAsBitmap = true;
cross.addEventListener(MouseEvent.CLICK, close);
this.addChild(cross);
if (bb1.stage != null){
this.removeChild(bb1);
};
if (bb2.stage != null){
this.removeChild(bb2);
};
if (bb3.stage != null){
this.removeChild(bb3);
};
if (bb4.stage != null){
this.removeChild(bb4);
};
if (bb5.stage != null){
this.removeChild(bb5);
};
if (bb6.stage != null){
this.removeChild(bb6);
};
if (bb7.stage != null){
this.removeChild(bb7);
};
bb1 = new MovieClip();
bb2 = new MovieClip();
bb3 = new MovieClip();
bb4 = new MovieClip();
bb5 = new MovieClip();
bb6 = new MovieClip();
bb7 = new MovieClip();
style = new TextFormat();
style.color = 8890301;
style.font = "Times New Roman";
style.bold = true;
creditsAvailable.selectable = false;
creditsAvailable.x = 200;
creditsAvailable.y = 45;
creditsAvailable.width = 100;
creditsAvailable.height = 40;
creditsAvailable.text = ("Credits : " + myMenu.myStatsMenu.myMoney);
creditsAvailable.setTextFormat(style);
style = new TextFormat();
style.color = 8890301;
style.font = "Times New Roman";
style.bold = true;
upgrade1.selectable = false;
upgrade1.x = 60;
upgrade1.y = 70;
upgrade1.width = 350;
upgrade1.height = 40;
upgrade1.text = ((" • Impulse Drive : increases spaceships' speed - " + impulseDrivePrice) + " credits");
upgrade1.setTextFormat(style);
this.addChild(upgrade1);
if (myMenu.impulseDrive == false){
if (myMenu.myStatsMenu.myMoney >= impulseDrivePrice){
buyButton = new buyAsset();
bb1.addChild(buyButton);
bb1.x = 380;
bb1.y = 67.5;
bb1.buttonMode = true;
bb1.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
bb1.filters = [new GlowFilter(0xFFFFFF)];
});
bb1.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
bb1.filters = null;
});
bb1.addEventListener(MouseEvent.CLICK, buyImpulseDrive);
} else {
buyButton = new graybuyAsset();
bb1.addChild(buyButton);
bb1.x = 380;
bb1.y = 67.5;
};
this.addChild(bb1);
};
upgrade2.selectable = false;
upgrade2.x = 60;
upgrade2.y = 90;
upgrade2.width = 350;
upgrade2.height = 40;
upgrade2.text = ((" • Destroyer : The destroyer is a powerful, but slower\n spaceship - " + destroyerPrice) + " Credits");
upgrade2.setTextFormat(style);
this.addChild(upgrade2);
if (myMenu.destroyers == false){
if (myMenu.myStatsMenu.myMoney >= destroyerPrice){
buyButton = new buyAsset();
bb2.addChild(buyButton);
bb2.x = 380;
bb2.y = 97.5;
bb2.buttonMode = true;
bb2.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
bb2.filters = [new GlowFilter(0xFFFFFF)];
});
bb2.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
bb2.filters = null;
});
bb2.addEventListener(MouseEvent.CLICK, buyDestroyers);
} else {
buyButton = new graybuyAsset();
bb2.addChild(buyButton);
bb2.x = 380;
bb2.y = 97.5;
};
this.addChild(bb2);
};
upgrade3.selectable = false;
upgrade3.x = 60;
upgrade3.y = 127.5;
upgrade3.width = 350;
upgrade2.height = 40;
upgrade3.text = ((" • Defensive Laser : Equip your planets with a laser\n shooting enemy spaceships - " + defLaserPrice) + " credits");
upgrade3.setTextFormat(style);
this.addChild(upgrade3);
if (myMenu.defensiveLaser == false){
if (myMenu.myStatsMenu.myMoney >= defLaserPrice){
buyButton = new buyAsset();
bb3.addChild(buyButton);
bb3.x = 380;
bb3.y = 127.5;
bb3.buttonMode = true;
bb3.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
bb3.filters = [new GlowFilter(0xFFFFFF)];
});
bb3.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
bb3.filters = null;
});
bb3.addEventListener(MouseEvent.CLICK, buyDefensiveLaser);
} else {
buyButton = new graybuyAsset();
bb3.addChild(buyButton);
bb3.x = 380;
bb3.y = 127.5;
};
this.addChild(bb3);
};
upgrade4.selectable = false;
upgrade4.x = 60;
upgrade4.y = 165;
upgrade4.width = 350;
upgrade2.height = 40;
upgrade4.text = ((" • Shields : Increases your ships resistance - " + shieldsPrice) + " Credits");
upgrade4.setTextFormat(style);
this.addChild(upgrade4);
if (myMenu.shields == false){
if (myMenu.myStatsMenu.myMoney >= shieldsPrice){
buyButton = new buyAsset();
bb4.addChild(buyButton);
bb4.x = 380;
bb4.y = 157.5;
bb4.buttonMode = true;
bb4.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
bb4.filters = [new GlowFilter(0xFFFFFF)];
});
bb4.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
bb4.filters = null;
});
bb4.addEventListener(MouseEvent.CLICK, buyShields);
} else {
buyButton = new graybuyAsset();
bb4.addChild(buyButton);
bb4.x = 380;
bb4.y = 157.5;
};
this.addChild(bb4);
};
upgrade5.selectable = false;
upgrade5.x = 60;
upgrade5.y = 190;
upgrade5.width = 350;
upgrade5.height = 40;
upgrade5.text = ((" • Nanites : Increases your planets production-" + nanitesPrice) + " Credits");
upgrade5.setTextFormat(style);
this.addChild(upgrade5);
if (myMenu.nanites == false){
if (myMenu.myStatsMenu.myMoney >= nanitesPrice){
buyButton = new buyAsset();
bb5.addChild(buyButton);
bb5.x = 380;
bb5.y = 187.5;
bb5.buttonMode = true;
bb5.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
bb5.filters = [new GlowFilter(0xFFFFFF)];
});
bb5.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
bb5.filters = null;
});
bb5.addEventListener(MouseEvent.CLICK, buyNanites);
} else {
buyButton = new graybuyAsset();
bb5.addChild(buyButton);
bb5.x = 380;
bb5.y = 187.5;
};
this.addChild(bb5);
};
upgrade6.selectable = false;
upgrade6.x = 60;
upgrade6.y = 215;
upgrade6.width = 350;
upgrade6.height = 40;
upgrade6.text = ((" • Attack Cruiser : An extremly powerful, but very costly\n to produce ship - " + cruiserPrice) + " Credits");
upgrade6.setTextFormat(style);
this.addChild(upgrade6);
if (myMenu.cruiser == false){
if (myMenu.myStatsMenu.myMoney >= cruiserPrice){
buyButton = new buyAsset();
bb6.addChild(buyButton);
bb6.x = 380;
bb6.y = 217.5;
bb6.buttonMode = true;
bb6.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
bb6.filters = [new GlowFilter(0xFFFFFF)];
});
bb6.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
bb6.filters = null;
});
bb6.addEventListener(MouseEvent.CLICK, buyCruiser);
} else {
buyButton = new graybuyAsset();
bb6.addChild(buyButton);
bb6.x = 380;
bb6.y = 217.5;
};
this.addChild(bb6);
};
upgrade7.selectable = false;
upgrade7.x = 60;
upgrade7.y = 244;
upgrade7.width = 350;
upgrade7.height = 40;
upgrade7.text = ((" • Death Star : The largest spacecraft ever built.\n It can even be used to destroy planets - " + deathStarPrice) + " Credits");
upgrade7.setTextFormat(style);
this.addChild(upgrade7);
if (myMenu.deathStar == false){
if (myMenu.myStatsMenu.myMoney >= deathStarPrice){
buyButton = new buyAsset();
bb7.addChild(buyButton);
bb7.x = 380;
bb7.y = 247.5;
bb7.buttonMode = true;
bb7.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
bb7.filters = [new GlowFilter(0xFFFFFF)];
});
bb7.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
bb7.filters = null;
});
bb7.addEventListener(MouseEvent.CLICK, buyDeathStar);
} else {
buyButton = new graybuyAsset();
bb7.addChild(buyButton);
bb7.x = 380;
bb7.y = 247.5;
};
this.addChild(bb7);
};
}
private function ats(e:Event):void{
if (this.parent != null){
this.parent.setChildIndex(this, (this.parent.numChildren - 1));
};
}
private function buyDefensiveLaser(e:MouseEvent):void{
var e = e;
if (myMenu.myStatsMenu.myMoney < defLaserPrice){
return;
};
SoundManager.playSound("buttonClick");
Tweener.addTween(bb3, {alpha:0, time:0.5, onComplete:function (){
bb3.visible = false;
}});
if (myMenu.defensiveLaser){
return;
};
myMenu.defensiveLaser = true;
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney - defLaserPrice));
buildMenu();
}
private function buyImpulseDrive(e:MouseEvent):void{
var e = e;
if (myMenu.myStatsMenu.myMoney < impulseDrivePrice){
return;
};
SoundManager.playSound("buttonClick");
Tweener.addTween(bb1, {alpha:0, time:0.5, onComplete:function (){
bb1.visible = false;
}});
if (myMenu.impulseDrive){
return;
};
myMenu.impulseDrive = true;
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney - impulseDrivePrice));
buildMenu();
}
private function buyNanites(e:MouseEvent):void{
var e = e;
if (myMenu.myStatsMenu.myMoney < nanitesPrice){
return;
};
SoundManager.playSound("buttonClick");
Tweener.addTween(bb5, {alpha:0, time:0.5, onComplete:function (){
bb5.visible = false;
}});
if (myMenu.nanites){
return;
};
myMenu.nanitesJustBought = true;
myMenu.nanites = true;
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney - nanitesPrice));
buildMenu();
}
private function buyDestroyers(e:MouseEvent):void{
var e = e;
if (myMenu.myStatsMenu.myMoney < destroyerPrice){
return;
};
SoundManager.playSound("buttonClick");
Tweener.addTween(bb2, {alpha:0, time:0.5, onComplete:function (){
bb2.visible = false;
}});
if (myMenu.destroyers){
return;
};
myMenu.shipJustBought = true;
myMenu.destroyers = true;
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney - destroyerPrice));
buildMenu();
}
private function buyShields(e:MouseEvent):void{
var e = e;
if (myMenu.myStatsMenu.myMoney < shieldsPrice){
return;
};
SoundManager.playSound("buttonClick");
Tweener.addTween(bb4, {alpha:0, time:0.5, onComplete:function (){
bb4.visible = false;
}});
if (myMenu.shields){
return;
};
myMenu.shields = true;
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney - shieldsPrice));
buildMenu();
}
private function buyCruiser(e:MouseEvent):void{
var e = e;
if (myMenu.myStatsMenu.myMoney < this.cruiserPrice){
return;
};
SoundManager.playSound("buttonClick");
Tweener.addTween(bb6, {alpha:0, time:0.5, onComplete:function (){
bb6.visible = false;
}});
if (myMenu.cruiser){
return;
};
myMenu.cruiser = true;
myMenu.myStatsMenu.setMoney((myMenu.myStatsMenu.myMoney - cruiserPrice));
buildMenu();
}
private function buzz():void{
SoundManager.playSound("buzz");
}
public function close(e:MouseEvent=null):void{
if (isClosing){
return;
};
SoundManager.playSound("research");
Tweener.addTween(myMenu.myStatsMenu, {y:myMenu.myStatsMenu.finalY, time:1, transition:"easeOutBack"});
isClosing = true;
Tweener.addTween(this, {x:-500, time:1, transition:"easeInBack", onComplete:destroy});
myMenu.savedGame.data.money = myMenu.myStatsMenu.myMoney;
myMenu.savedGame.data.impulseDrive = myMenu.impulseDrive;
myMenu.savedGame.data.destroyers = myMenu.destroyers;
myMenu.savedGame.data.defensiveLaser = myMenu.defensiveLaser;
myMenu.savedGame.data.shields = myMenu.shields;
myMenu.savedGame.data.nanites = myMenu.nanites;
myMenu.savedGame.data.cruiser = myMenu.cruiser;
myMenu.savedGame.data.deathStar = myMenu.deathStar;
}
private function destroy():void{
if (this.parent != null){
this.parent.removeChild(this);
};
myMenu.myResearchMenu = null;
}
}
}//package
Section 187
//ResearchMenu_buyAsset (ResearchMenu_buyAsset)
package {
import mx.core.*;
public class ResearchMenu_buyAsset extends BitmapAsset {
}
}//package
Section 188
//ResearchMenu_graybuyAsset (ResearchMenu_graybuyAsset)
package {
import mx.core.*;
public class ResearchMenu_graybuyAsset extends BitmapAsset {
}
}//package
Section 189
//ResearchMenu_rmenu (ResearchMenu_rmenu)
package {
import mx.core.*;
public class ResearchMenu_rmenu extends BitmapAsset {
}
}//package
Section 190
//ScoresMenu (ScoresMenu)
package {
import flash.display.*;
public dynamic class ScoresMenu extends MovieClip {
public function ScoresMenu(){
super();
}
}
}//package
Section 191
//SoundManager (SoundManager)
package {
import flash.events.*;
import flash.media.*;
public class SoundManager {
private static var buttonClick:Class = SoundManager_buttonClick;
private static var laser2:Class = SoundManager_laser2;
private static var zoomTransition:Class = SoundManager_zoomTransition;
private static var laser1:Class = SoundManager_laser1;
private static var laser3:Class = SoundManager_laser3;
private static var buzz:Class = SoundManager_buzz;
public static var music:Class = SoundManager_music;
private static var explosion:Class = SoundManager_explosion;
private static var close:Class = SoundManager_close;
private static var research:Class = SoundManager_research;
private static var planetExplosion:Class = SoundManager_planetExplosion;
public function SoundManager(){
super();
}
public static function playSound(name:String):void{
var mySound:Sound;
var musicChannel:SoundChannel;
var e:MusicTimer;
var random:int;
if (name == "zoomTransition"){
mySound = new zoomTransition();
mySound.play();
};
if (name == "buzz"){
mySound = new buzz();
mySound.play();
};
if (name == "close"){
mySound = new close();
mySound.play();
};
if (name == "research"){
mySound = new research();
mySound.play();
};
if (name == "buttonClick"){
mySound = new buttonClick();
mySound.play();
};
if (name == "explosion"){
mySound = new explosion();
musicChannel = mySound.play();
musicChannel.soundTransform = new SoundTransform(RandomNumber.generate(1, 2));
};
if (name == "planetExplosion"){
mySound = new planetExplosion();
mySound.play();
};
if (name == "music"){
mySound = new music();
musicChannel = mySound.play(0);
musicChannel.soundTransform = new SoundTransform(0.5);
e = new MusicTimer(75000, 1, musicChannel);
e.addEventListener(TimerEvent.TIMER, e.selfExecute);
e.start();
};
if (name == "laser"){
random = RandomNumber.generate(1, 3);
if (random == 1){
mySound = new laser1();
};
if (random == 2){
mySound = new laser2();
};
if (random == 3){
mySound = new laser3();
};
mySound.play();
};
}
private static function loopMusic(e:ProgressEvent):void{
}
}
}//package
Section 192
//SoundManager_buttonClick (SoundManager_buttonClick)
package {
import mx.core.*;
public class SoundManager_buttonClick extends SoundAsset {
}
}//package
Section 193
//SoundManager_buzz (SoundManager_buzz)
package {
import mx.core.*;
public class SoundManager_buzz extends SoundAsset {
}
}//package
Section 194
//SoundManager_close (SoundManager_close)
package {
import mx.core.*;
public class SoundManager_close extends SoundAsset {
}
}//package
Section 195
//SoundManager_explosion (SoundManager_explosion)
package {
import mx.core.*;
public class SoundManager_explosion extends SoundAsset {
}
}//package
Section 196
//SoundManager_laser1 (SoundManager_laser1)
package {
import mx.core.*;
public class SoundManager_laser1 extends SoundAsset {
}
}//package
Section 197
//SoundManager_laser2 (SoundManager_laser2)
package {
import mx.core.*;
public class SoundManager_laser2 extends SoundAsset {
}
}//package
Section 198
//SoundManager_laser3 (SoundManager_laser3)
package {
import mx.core.*;
public class SoundManager_laser3 extends SoundAsset {
}
}//package
Section 199
//SoundManager_music (SoundManager_music)
package {
import mx.core.*;
public class SoundManager_music extends SoundAsset {
}
}//package
Section 200
//SoundManager_planetExplosion (SoundManager_planetExplosion)
package {
import mx.core.*;
public class SoundManager_planetExplosion extends SoundAsset {
}
}//package
Section 201
//SoundManager_research (SoundManager_research)
package {
import mx.core.*;
public class SoundManager_research extends SoundAsset {
}
}//package
Section 202
//SoundManager_zoomTransition (SoundManager_zoomTransition)
package {
import mx.core.*;
public class SoundManager_zoomTransition extends SoundAsset {
}
}//package
Section 203
//Space (Space)
package {
import flash.display.*;
public class Space extends MovieClip {
public var myAsteroidFields:Array;
public var mySun:Sun;
public var myFleets:Array;
public var myPlanets:Array;
private var myGame:Game;
public function Space(parentGame:Game){
myPlanets = new Array();
myFleets = new Array();
myAsteroidFields = new Array();
super();
myGame = parentGame;
}
public function addFleet(from:Planet, destination:Planet, type:int):void{
var newFleet:Fleet = new Fleet(this.myGame, from, destination, from.myOwner, type);
this.myFleets.push(newFleet);
this.addChild(newFleet);
}
public function addPlanet(x:Number, y:Number, id:int, size:int, owner:Number):void{
var newPlanet:Planet = new Planet(myGame, x, y, id, size, owner);
newPlanet.setSize(size);
this.addChild(newPlanet);
this.myPlanets.push(newPlanet);
}
public function loadMap(map:Array):void{
var y:int;
while (y < map[0].length) {
if ((map[0][y] is MenuWindow)){
this.myGame.addChild(map[0][y]);
} else {
this.addChild(map[0][y]);
if ((map[0][y] is Sun)){
this.mySun = map[0][y];
};
if ((map[0][y] is AsteroidField)){
this.myAsteroidFields.push(AsteroidField(map[0][y]));
};
};
y++;
};
var i = 1;
while (i < map.length) {
this.addPlanet(map[i][0], map[i][1], map[i][2], map[i][3], map[i][4]);
i++;
};
}
}
}//package
Section 204
//SpaceShipSelectioner (SpaceShipSelectioner)
package {
import flash.events.*;
import flash.display.*;
import caurina.transitions.*;
import flash.text.*;
import flash.filters.*;
public class SpaceShipSelectioner extends MovieClip {
private var button2:MovieClip;
private var button3:MovieClip;
private var starfighterAsset:Class;
private var grayStarfighterAsset:Class;
private var destroyerAsset:Class;
private var grayDestroyerAsset:Class;
private var myGame:Game;
private var menuAsset:Class;
public var selected:int;// = 1
private var button4:MovieClip;
public var shipCost:TextField;
private var deathStarAsset:Class;
private var grayDeathStarAsset:Class;
private var cruiserAsset:Class;
private var grayCruiserAsset:Class;
private var button1:MovieClip;
public function SpaceShipSelectioner(game:Game, xi:Number, yi:Number){
menuAsset = SpaceShipSelectioner_menuAsset;
starfighterAsset = SpaceShipSelectioner_starfighterAsset;
grayStarfighterAsset = SpaceShipSelectioner_grayStarfighterAsset;
destroyerAsset = SpaceShipSelectioner_destroyerAsset;
grayDestroyerAsset = SpaceShipSelectioner_grayDestroyerAsset;
cruiserAsset = SpaceShipSelectioner_cruiserAsset;
grayCruiserAsset = SpaceShipSelectioner_grayCruiserAsset;
deathStarAsset = SpaceShipSelectioner_deathStarAsset;
grayDeathStarAsset = SpaceShipSelectioner_grayDeathStarAsset;
button1 = new MovieClip();
button2 = new MovieClip();
button3 = new MovieClip();
button4 = new MovieClip();
shipCost = new TextField();
super();
this.alpha = 0;
Tweener.addTween(this, {alpha:0.5, time:2});
x = xi;
y = yi;
myGame = game;
this.addChild(new menuAsset());
this.addEventListener(MouseEvent.MOUSE_OVER, increaseAlpha, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_OUT, decreaseAlpha, false, 0, true);
this.addChild(shipCost);
buildMenu();
selectedGlow();
}
public function select(num:int):void{
if ((((myGame.myMenu.destroyers == false)) && ((num == 2)))){
return;
};
if ((((myGame.myMenu.cruiser == false)) && ((num == 3)))){
return;
};
if ((((myGame.myMenu.deathStar == false)) && ((num == 4)))){
return;
};
SoundManager.playSound("buttonClick");
this.selected = num;
selectedGlow();
updateText();
}
private function increaseAlpha(e:MouseEvent):void{
Tweener.addTween(this, {alpha:0.9, y:5, time:1});
}
private function selectedGlow():void{
button1.filters = null;
button2.filters = null;
button3.filters = null;
button4.filters = null;
if (selected == 1){
button1.filters = [new GlowFilter(0xFF00)];
};
if (selected == 2){
button2.filters = [new GlowFilter(0xFF00)];
};
if (selected == 3){
button3.filters = [new GlowFilter(0xFF00)];
};
if (selected == 4){
button4.filters = [new GlowFilter(0xFF00)];
};
}
private function buzz():void{
SoundManager.playSound("buzz");
}
private function updateText():void{
var style:TextFormat = new TextFormat();
style.color = 8890301;
style.font = "Times New Roman";
style.bold = true;
shipCost.selectable = false;
shipCost.alpha = 0.8;
shipCost.x = 40;
shipCost.y = 125;
shipCost.width = 155;
shipCost.height = 40;
shipCost.text = "Ship cost: 1 Units";
if (selected == 2){
shipCost.text = "Ship cost: 2 Units";
};
if (selected == 3){
shipCost.text = "Ship cost: 20 Units";
};
if (selected == 4){
shipCost.text = "Ship cost: 100 Units";
};
shipCost.setTextFormat(style);
}
private function mouseUp(e:MouseEvent):void{
myGame.myBackground.noRectangle = false;
this.stopDrag();
}
private function mouseDown(e:MouseEvent):void{
myGame.myBackground.noRectangle = true;
this.startDrag();
}
private function decreaseAlpha(e:MouseEvent):void{
Tweener.addTween(this, {alpha:0.5, y:-120, time:1});
}
private function buildMenu():void{
if (button1.parent != null){
button1.parent.removeChild(button1);
};
if (button2.parent != null){
button2.parent.removeChild(button2);
};
if (button3.parent != null){
button3.parent.removeChild(button3);
};
if (button4.parent != null){
button4.parent.removeChild(button4);
};
button1.addChild(new starfighterAsset());
if (myGame.myMenu.destroyers){
button2.addChild(new destroyerAsset());
} else {
button2.addChild(new grayDestroyerAsset());
};
if (myGame.myMenu.cruiser){
button3.addChild(new cruiserAsset());
} else {
button3.addChild(new grayCruiserAsset());
};
if (myGame.myMenu.deathStar){
button4.addChild(new deathStarAsset());
} else {
button4.addChild(new grayDeathStarAsset());
};
button1.x = 45;
button1.y = 50;
button2.x = 45;
button2.y = 70;
button3.x = 45;
button3.y = 90;
button4.x = 45;
button4.y = 110;
this.addChild(button1);
this.addChild(button2);
this.addChild(button3);
this.addChild(button4);
button1.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
button1.filters = [new GlowFilter(0xFFFFFF)];
});
button1.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
selectedGlow();
});
button1.addEventListener(MouseEvent.CLICK, function (e:MouseEvent){
select(1);
});
button1.buttonMode = true;
if (myGame.myMenu.destroyers){
button2.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
button2.filters = [new GlowFilter(0xFFFFFF)];
});
button2.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
selectedGlow();
});
button2.buttonMode = true;
button2.addEventListener(MouseEvent.CLICK, function (e:MouseEvent){
select(2);
});
};
if (myGame.myMenu.cruiser){
button3.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
button3.filters = [new GlowFilter(0xFFFFFF)];
});
button3.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
selectedGlow();
});
button3.buttonMode = true;
button3.addEventListener(MouseEvent.CLICK, function (e:MouseEvent){
select(3);
});
};
if (myGame.myMenu.deathStar){
button4.addEventListener(MouseEvent.MOUSE_OVER, function (e:MouseEvent){
buzz();
button4.filters = [new GlowFilter(0xFFFFFF)];
});
button4.addEventListener(MouseEvent.MOUSE_OUT, function (e:MouseEvent){
selectedGlow();
});
button4.buttonMode = true;
button4.addEventListener(MouseEvent.CLICK, function (e:MouseEvent){
select(4);
});
};
updateText();
}
}
}//package
Section 205
//SpaceShipSelectioner_cruiserAsset (SpaceShipSelectioner_cruiserAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_cruiserAsset extends BitmapAsset {
}
}//package
Section 206
//SpaceShipSelectioner_deathStarAsset (SpaceShipSelectioner_deathStarAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_deathStarAsset extends BitmapAsset {
}
}//package
Section 207
//SpaceShipSelectioner_destroyerAsset (SpaceShipSelectioner_destroyerAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_destroyerAsset extends BitmapAsset {
}
}//package
Section 208
//SpaceShipSelectioner_grayCruiserAsset (SpaceShipSelectioner_grayCruiserAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_grayCruiserAsset extends BitmapAsset {
}
}//package
Section 209
//SpaceShipSelectioner_grayDeathStarAsset (SpaceShipSelectioner_grayDeathStarAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_grayDeathStarAsset extends BitmapAsset {
}
}//package
Section 210
//SpaceShipSelectioner_grayDestroyerAsset (SpaceShipSelectioner_grayDestroyerAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_grayDestroyerAsset extends BitmapAsset {
}
}//package
Section 211
//SpaceShipSelectioner_grayStarfighterAsset (SpaceShipSelectioner_grayStarfighterAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_grayStarfighterAsset extends BitmapAsset {
}
}//package
Section 212
//SpaceShipSelectioner_menuAsset (SpaceShipSelectioner_menuAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_menuAsset extends BitmapAsset {
}
}//package
Section 213
//SpaceShipSelectioner_starfighterAsset (SpaceShipSelectioner_starfighterAsset)
package {
import mx.core.*;
public class SpaceShipSelectioner_starfighterAsset extends BitmapAsset {
}
}//package
Section 214
//StatsMenu (StatsMenu)
package {
import flash.events.*;
import flash.display.*;
import caurina.transitions.*;
import flash.text.*;
import flash.filters.*;
public class StatsMenu extends MovieClip {
public var myPercent:Number;
private var researchAsset:Class;
private var finalX:Number;
public var finalY:Number;
public var myMenu:Menu;
private var researchButton:MovieClip;
public var myMoney:Number;
private var percentControled:TextField;
private var moneyTF:TextField;
private var statsmenu:Class;
public function StatsMenu(finX:Number, finY:Number, menu:Menu){
statsmenu = StatsMenu_statsmenu;
researchAsset = StatsMenu_researchAsset;
percentControled = new TextField();
moneyTF = new TextField();
researchButton = new MovieClip();
super();
this.alpha = 0.9;
myMenu = menu;
this.addChild(new statsmenu());
this.finalX = finX;
finalY = finY;
this.y = -200;
this.x = finalX;
Tweener.addTween(this, {y:this.finalY, time:1, transition:"easeOutBack"});
this.setPercentControlled(1);
this.addChild(percentControled);
this.setMoney(0);
this.addChild(moneyTF);
this.researchButton.addChild(new researchAsset());
this.researchButton.x = 55;
this.researchButton.y = 100;
this.researchButton.buttonMode = true;
this.addChild(researchButton);
researchButton.addEventListener(MouseEvent.MOUSE_OVER, researchGlowOn, false, 0, true);
researchButton.addEventListener(MouseEvent.MOUSE_OUT, researchGlowOff, false, 0, true);
researchButton.addEventListener(MouseEvent.CLICK, openResearchMenu, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUp, false, 0, true);
}
public function setMoney(money:Number):void{
myMoney = money;
var style:TextFormat = new TextFormat();
style.color = 8890301;
style.font = "Times New Roman";
style.bold = true;
moneyTF.selectable = false;
moneyTF.x = 35;
moneyTF.y = 80;
moneyTF.width = 150;
moneyTF.height = 40;
moneyTF.text = (("• You have " + money) + " credits");
moneyTF.setTextFormat(style);
}
private function researchGlowOn(e:MouseEvent):void{
SoundManager.playSound("buzz");
researchButton.filters = [new GlowFilter(0xFFFFFF, 0.3, 1, 1)];
}
private function openResearchMenu(e:MouseEvent):void{
if (myMenu.myResearchMenu == null){
SoundManager.playSound("research");
Tweener.addTween(this, {y:-200, time:1, transition:"easeInBack"});
myMenu.myWindow.close();
myMenu.myResearchMenu = new ResearchMenu(this.myMenu);
this.myMenu.addChild(myMenu.myResearchMenu);
} else {
myMenu.myResearchMenu.close();
};
}
private function researchGlowOff(e:MouseEvent):void{
researchButton.filters = null;
}
private function mouseUp(e:MouseEvent):void{
this.stopDrag();
}
private function mouseDown(e:MouseEvent):void{
this.startDrag();
}
public function setPercentControlled(percent:Number):void{
myPercent = percent;
var style:TextFormat = new TextFormat();
style.color = 8890301;
style.font = "Times New Roman";
style.bold = true;
percentControled.selectable = false;
percentControled.x = 35;
percentControled.y = 50;
percentControled.width = 155;
percentControled.height = 40;
percentControled.text = ((" •" + percent) + "% of the galaxy is under\n your control");
percentControled.setTextFormat(style);
}
}
}//package
Section 215
//StatsMenu_researchAsset (StatsMenu_researchAsset)
package {
import mx.core.*;
public class StatsMenu_researchAsset extends BitmapAsset {
}
}//package
Section 216
//StatsMenu_statsmenu (StatsMenu_statsmenu)
package {
import mx.core.*;
public class StatsMenu_statsmenu extends BitmapAsset {
}
}//package
Section 217
//Sun (Sun)
package {
import flash.display.*;
public class Sun extends MovieClip {
private var myContent:Bitmap;
private var myGame:Game;
public function Sun(parentGame:Game, xi:Number, yi:Number){
super();
x = xi;
y = yi;
myGame = parentGame;
myContent = new Bitmap();
myContent.smoothing = true;
myContent.bitmapData = parentGame.myAssets.getAsset("sun").bitmapData;
this.addChild(myContent);
myContent.x = (-(myContent.width) / 2);
myContent.y = (-(myContent.height) / 2);
this.scaleX = (this.scaleY = 0.5);
}
}
}//package