Section 1
//Bar (castle.Bar)
package castle {
import flash.display.*;
public class Bar extends MovieClip {
public var barLine_mc:MovieClip;
private var k:Number;
public function Bar(){
super();
this.k = (barLine_mc.width / 100);
}
public function setValue(p:Number):void{
this.barLine_mc.width = (p * k);
}
}
}//package castle
Section 2
//BaseUpgradeData (castle.BaseUpgradeData)
package castle {
public class BaseUpgradeData {
public var upgrade0ExpValue:Array;
public var upgrade1ExpValue:Array;
public var upgrade2ExpValue:Array;
public var upgrade3ExpValue:Array;
public var upgrade4ExpValue:Array;
public var currentExpirience:Number;// = 0
public var upgrade4ExpCost:Array;
public var upgrade0:Number;// = 0
public var upgrade1:Number;// = 1
public var upgrade0ExpCost:Array;
public var upgrade3:Number;// = 0
public var upgrade4:Number;// = 0
public var upgrade2ExpCost:Array;
public var upgrade2:Number;// = 0
public var upgrade1ExpCost:Array;
public var upgrade3ExpCost:Array;
public function BaseUpgradeData(){
currentExpirience = 0;
upgrade0 = 0;
upgrade1 = 1;
upgrade2 = 0;
upgrade3 = 0;
upgrade4 = 0;
upgrade0ExpCost = [150, 350, 400, 1000];
upgrade1ExpCost = [200, 400, 500, 800];
upgrade2ExpCost = [200, 400, 450, 850];
upgrade3ExpCost = [150, 250, 350, 1200];
upgrade4ExpCost = [300, 500, 600, 1500];
upgrade0ExpValue = [100, 500, 1000, 2000];
upgrade1ExpValue = [15, 30, 80, 150];
upgrade2ExpValue = [2000, 4000, 6000, 8000];
upgrade3ExpValue = [250, 550, 850, 1500];
upgrade4ExpValue = [30, 50, 80, 110];
super();
}
}
}//package castle
Section 3
//Castle (castle.Castle)
package castle {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
public class Castle extends MovieClip {
public var hpBar:CastleHPBar;
public var damageDT:TextField;
public var currentHP:Number;// = 500
public var totalHP:Number;// = 500
public var shieldTimer:Timer;
public var shield:Sprite;
public var damageTextTimer:Timer;
public var castleSkin:CastleSkin;
public var emiAnimation:MovieClip;
public function Castle(){
totalHP = 500;
currentHP = 500;
super();
SimpleToolTip.addToolTip(this.castleSkin, "This is your base\nProtect it from robo-bugs\n You can use base special abilities");
this.currentHP = this.totalHP;
hpBar.updateInfo(this.totalHP, this.currentHP);
this.shield.visible = false;
this.addEventListener(MouseEvent.CLICK, onMouseClick);
this.damageDT.visible = false;
}
private function onDamageTextTimerComplete(e:TimerEvent):void{
this.damageDT.visible = false;
}
private function onMouseClick(e:MouseEvent):void{
}
public function activateShield(t:Number):void{
if (this.shieldTimer != null){
return;
};
if (Global.isDoubleSpeed == false){
this.shieldTimer = new Timer(t, 1);
} else {
this.shieldTimer = new Timer((t / 2), 1);
};
this.shieldTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onShieldTimerComplete);
this.shieldTimer.start();
this.shield.visible = true;
}
private function onShieldTimerComplete(e:TimerEvent):void{
this.shieldTimer.stop();
this.shieldTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onShieldTimerComplete);
this.shieldTimer = null;
this.shield.visible = false;
}
public function update():void{
this.doDamage(0);
}
public function doDamage(d:Number=0){
var p:Number;
if (this.shieldTimer != null){
d = Math.floor((d / 10));
};
if (this.damageTextTimer != null){
this.damageTextTimer.stop();
this.damageTextTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onDamageTextTimerComplete);
this.damageTextTimer = null;
};
this.damageTextTimer = new Timer(1000, 1);
this.damageTextTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onDamageTextTimerComplete);
this.damageTextTimer.start();
this.damageDT.text = ("-" + d.toString(10));
this.damageDT.visible = true;
this.currentHP = (this.currentHP - d);
if (d > 0){
Global.soundManager.addSFXSound("BaseDamages");
};
if (this.currentHP <= 0){
this.currentHP = 0;
};
trace("castle hp:", this.currentHP);
hpBar.updateInfo(this.totalHP, this.currentHP);
p = Math.floor((((totalHP - this.currentHP) / this.totalHP) * 100));
castleSkin.setDamage(p);
if (this.currentHP == 0){
this.dispatchEvent(new Event("CastleDead"));
Global.gameManager.showLooseLevel();
this.dispatchEvent(new Event("save"));
};
}
public function doEmiAnimation():void{
this.emiAnimation.play();
}
}
}//package castle
Section 4
//CastleHPBar (castle.CastleHPBar)
package castle {
import flash.display.*;
import flash.text.*;
public class CastleHPBar extends MovieClip {
public var bar:Bar;
private var percentage:Number;// = 100
public var dt1:TextField;
public var dt2:TextField;
public function CastleHPBar(){
percentage = 100;
super();
}
public function updateInfo(total:Number, current:Number):void{
dt2.text = total.toString();
dt1.text = current.toString();
this.percentage = Math.floor(((current / total) * 100));
bar.setValue(this.percentage);
}
}
}//package castle
Section 5
//CastleSkin (castle.CastleSkin)
package castle {
import flash.display.*;
public class CastleSkin extends MovieClip {
public function CastleSkin(){
super();
this.gotoAndStop(1);
}
public function setDamage(p:Number):void{
this.gotoAndStop(Math.floor(((this.totalFrames * p) / 100)));
}
}
}//package castle
Section 6
//CastleUpgradeIcon (castle.CastleUpgradeIcon)
package castle {
import flash.display.*;
public class CastleUpgradeIcon extends MovieClip {
public var locked_mc:MovieClip;
private var _locked:Boolean;
public var canBuyButton:SimpleButton;
public var content:MovieClip;
private var _canBuy:Boolean;
public var canNOTBuyButton:SimpleButton;
public function CastleUpgradeIcon(){
super();
this.canBuy = true;
this.locked = true;
}
public function set locked(value:Boolean):void{
locked_mc.visible = value;
this.canBuyButton.enabled = !(value);
this.canNOTBuyButton.enabled = !(value);
_locked = value;
}
public function get locked():Boolean{
return (_locked);
}
public function set canBuy(value:Boolean):void{
this.canBuyButton.visible = value;
this.canNOTBuyButton.visible = !(value);
_canBuy = value;
}
public function get canBuy():Boolean{
return (_canBuy);
}
public function setContent(s:Sprite):void{
trace(this.content.numChildren);
while (this.content.numChildren) {
this.content.removeChildAt(0);
};
this.content.addChild(s);
}
}
}//package castle
Section 7
//CastleWindow (castle.CastleWindow)
package castle {
import flash.display.*;
import flash.events.*;
public class CastleWindow extends MovieClip {
public var icon1:CastleUpgradeIcon;
public var doneButton:SimpleButton;
public function CastleWindow(){
super();
icon1.locked = false;
icon1.setContent(new RestoreHP10());
doneButton.addEventListener(MouseEvent.CLICK, onDoneClick);
}
private function onDoneClick(e:MouseEvent):void{
Global.gameManager.hideCastleWindow();
}
}
}//package castle
Section 8
//AuxFunctions (caurina.transitions.AuxFunctions)
package caurina.transitions {
public class AuxFunctions {
public function AuxFunctions(){
super();
}
public static function getObjectLength(p_object:Object):uint{
var totalProperties:uint;
var pName:String;
totalProperties = 0;
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 finalObject:Object;
var currentObject:Object;
var i:int;
var prop:String;
finalObject = {};
i = 0;
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 9
//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 p:Number;
var s:Number;
var a:Number;
if (t == 0){
return (b);
};
t = (t / (d / 2));
if (t == 2){
return ((b + c));
};
p = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * (0.3 * 1.5)) : p_params.period;
a = (((!(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;
s = (((!(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;
s = (((!(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;
s = (((!(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 p:Number;
var s:Number;
var a:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
p = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
a = (((!(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 p:Number;
var s:Number;
var a:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
p = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
a = (((!(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 10
//PropertyInfoObj (caurina.transitions.PropertyInfoObj)
package caurina.transitions {
public class PropertyInfoObj {
public var originalValueComplete:Object;
public var modifierParameters:Array;
public var isSpecialProperty:Boolean;
public var hasModifier:Boolean;
public var valueComplete:Number;
public var extra:Object;
public var valueStart:Number;
public var modifierFunction:Function;
public var arrayIndex:Number;
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;
returnStr = "\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;
nProperty = new PropertyInfoObj(valueStart, valueComplete, originalValueComplete, arrayIndex, extra, isSpecialProperty, modifierFunction, modifierParameters);
return (nProperty);
}
}
}//package caurina.transitions
Section 11
//SpecialProperty (caurina.transitions.SpecialProperty)
package caurina.transitions {
public class SpecialProperty {
public var parameters:Array;
public var preProcess:Function;
public var setValue:Function;
public var getValue: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 = (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 12
//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 = (value + "[SpecialPropertyModifier ");
value = (value + ("modifyValues:" + String(modifyValues)));
value = (value + ", ");
value = (value + ("getValue:" + String(getValue)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 13
//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 = (value + "[SpecialPropertySplitter ");
value = (value + ("splitValues:" + String(splitValues)));
value = (value + ", ");
value = (value + ("parameters:" + String(parameters)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 14
//Tweener (caurina.transitions.Tweener)
package caurina.transitions {
import flash.display.*;
import flash.events.*;
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{
var spm:SpecialPropertyModifier;
if (!_inited){
init();
};
spm = 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{
var sp:SpecialProperty;
if (!_inited){
init();
};
sp = 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 p_obj:Object;
var rTime:Number;
var rDelay:Number;
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];
};
p_obj = p_parameters;
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
rTime = (isNaN(p_obj.time)) ? 0 : p_obj.time;
rDelay = (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 paused:Boolean;
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
paused = false;
i = 0;
while (i < _tweenList.length) {
pauseTweenByIndex(i);
paused = true;
i++;
};
return (paused);
}
public static function removeTweens(p_scope:Object, ... _args):Boolean{
var properties:Array;
var i:uint;
var sps:SpecialPropertySplitter;
var specialProps:Array;
var j:uint;
properties = 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 originalTween:TweenListObj;
var newTween:TweenListObj;
var i:uint;
var pName:String;
var found:Boolean;
originalTween = _tweenList[p_tween];
newTween = 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;
var cTime:Number;
tTweening = _tweenList[p_tween];
if ((((tTweening == null)) || (!(tTweening.isPaused)))){
return (false);
};
cTime = 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{
var hasUpdated:Boolean;
updateTime();
updateFrame();
hasUpdated = false;
hasUpdated = updateTweens();
if (!hasUpdated){
stopEngine();
};
}
public static function updateTime():void{
_currentTime = getTimer();
}
private static function updateTweenByIndex(i:Number):Boolean{
var tTweening:TweenListObj;
var isOver:Boolean;
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 cTime:Number;
var tProperty:Object;
var pv:Number;
var i = i;
tTweening = _tweenList[i];
if ((((tTweening == null)) || (!(Boolean(tTweening.scope))))){
return (false);
};
isOver = false;
cTime = 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 resumed:Boolean;
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
resumed = false;
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 removed:Boolean;
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
removed = false;
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 p_obj:Object;
var rTime:Number;
var rDelay:Number;
var rProperties:Array;
var restrictedWords:Object;
var modifiedProperties:Object;
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];
};
p_obj = TweenListObj.makePropertiesChain(p_parameters);
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
rTime = (isNaN(p_obj.time)) ? 0 : p_obj.time;
rDelay = (isNaN(p_obj.delay)) ? 0 : p_obj.delay;
rProperties = new Array();
restrictedWords = {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};
modifiedProperties = 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 affected:Boolean;
var i:uint;
var affectedProperties:Array;
var j:uint;
var objectProperties:uint;
var slicedTweenIndex:uint;
affected = false;
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;
var tList:Array;
if (!Boolean(_tweenList)){
return ([]);
};
tList = 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;
tTweening = _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;
var c:Number;
if (!Boolean(_tweenList)){
return (0);
};
c = 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 removed:Boolean;
var removedLocally:Boolean;
var i:uint;
var tl: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;
removed = false;
tl = _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{
var sps:SpecialPropertySplitter;
if (!_inited){
init();
};
sps = 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 properties:Array;
var i:uint;
properties = 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 properties:Array;
var i:uint;
properties = 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 15
//TweenListObj (caurina.transitions.TweenListObj)
package caurina.transitions {
public class TweenListObj {
public var onUpdate:Function;
public var useFrames:Boolean;
public var hasStarted:Boolean;
public var onOverwriteParams:Array;
public var timeStart:Number;
public var count: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 transition:Function;
public var timePaused:Number;
public var onCompleteParams:Array;
public var timesCalled:Number;
public var isCaller:Boolean;
public var onError:Function;
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 nTween:TweenListObj;
var pName:String;
nTween = 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 returnStr:String;
var isFirst:Boolean;
var i:String;
returnStr = "\n[TweenListObj ";
returnStr = (returnStr + ("scope:" + String(scope)));
returnStr = (returnStr + ", properties:");
isFirst = true;
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 baseObject:Object;
var chainedObject:Object;
var chain:Object;
var currChainObj:Object;
var len:Number;
var i:Number;
var k:Number;
baseObject = 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 16
//HMAC (com.hurlant.crypto.hash.HMAC)
package com.hurlant.crypto.hash {
import flash.utils.*;
public class HMAC {
private var bits:uint;
private var hash:IHash;
public function HMAC(hash:IHash, bits:uint=0){
super();
this.hash = hash;
this.bits = bits;
}
public function getHashSize():uint{
if (bits != 0){
return ((bits / 8));
};
return (hash.getHashSize());
}
public function dispose():void{
hash = null;
bits = 0;
}
public function compute(key:ByteArray, data:ByteArray):ByteArray{
var hashKey:ByteArray;
var innerKey:ByteArray;
var outerKey:ByteArray;
var i:uint;
var innerHash:ByteArray;
var outerHash:ByteArray;
if (key.length > hash.getInputSize()){
hashKey = hash.hash(key);
} else {
hashKey = new ByteArray();
hashKey.writeBytes(key);
};
while (hashKey.length < hash.getInputSize()) {
hashKey[hashKey.length] = 0;
};
innerKey = new ByteArray();
outerKey = new ByteArray();
i = 0;
while (i < hashKey.length) {
innerKey[i] = (hashKey[i] ^ 54);
outerKey[i] = (hashKey[i] ^ 92);
i++;
};
innerKey.position = hashKey.length;
innerKey.writeBytes(data);
innerHash = hash.hash(innerKey);
outerKey.position = hashKey.length;
outerKey.writeBytes(innerHash);
outerHash = hash.hash(outerKey);
if ((((bits > 0)) && ((bits < (8 * outerHash.length))))){
outerHash.length = (bits / 8);
};
return (outerHash);
}
public function toString():String{
return ((("hmac-" + ((bits > 0)) ? (bits + "-") : "") + hash.toString()));
}
}
}//package com.hurlant.crypto.hash
Section 17
//IHash (com.hurlant.crypto.hash.IHash)
package com.hurlant.crypto.hash {
import flash.utils.*;
public interface IHash {
function toString():String;
function getHashSize():uint;
function getInputSize():uint;
function hash(D:\dev\GAMES\TD;com\hurlant\crypto\hash;IHash.as:ByteArray):ByteArray;
}
}//package com.hurlant.crypto.hash
Section 18
//MD2 (com.hurlant.crypto.hash.MD2)
package com.hurlant.crypto.hash {
import flash.utils.*;
public class MD2 implements IHash {
public static const HASH_SIZE:int = 16;
private static const S:Array = [41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, 39, 53, 62, 204, 231, 191, 247, 151, 3, 0xFF, 25, 48, 179, 72, 165, 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, 31, 26, 219, 153, 141, 51, 159, 17, 131, 20];
public function MD2(){
super();
}
public function getHashSize():uint{
return (HASH_SIZE);
}
public function toString():String{
return ("md2");
}
public function getInputSize():uint{
return (16);
}
public function hash(src:ByteArray):ByteArray{
var savedLength:uint;
var i:uint;
var len:uint;
var checksum:ByteArray;
var L:uint;
var X:ByteArray;
var j:uint;
var t:uint;
var k:uint;
savedLength = src.length;
i = (((16 - (src.length % 16))) || (16));
do {
src[src.length] = i;
} while ((src.length % 16) != 0);
len = src.length;
checksum = new ByteArray();
L = 0;
i = 0;
while (i < len) {
j = 0;
while (j < 16) {
L = (checksum[j] = (checksum[j] ^ S[(src[(i + j)] ^ L)]));
j++;
};
i = (i + 16);
};
src.position = src.length;
src.writeBytes(checksum);
len = (len + 16);
X = new ByteArray();
i = 0;
while (i < len) {
j = 0;
while (j < 16) {
X[(32 + j)] = ((X[(16 + j)] = src[(i + j)]) ^ X[j]);
j++;
};
t = 0;
j = 0;
while (j < 18) {
k = 0;
while (k < 48) {
t = (X[k] ^ S[t]);
X[k] = t;
k++;
};
t = ((t + j) & 0xFF);
j++;
};
i = (i + 16);
};
X.length = 16;
src.length = savedLength;
return (X);
}
}
}//package com.hurlant.crypto.hash
Section 19
//MD5 (com.hurlant.crypto.hash.MD5)
package com.hurlant.crypto.hash {
import flash.utils.*;
public class MD5 implements IHash {
public static const HASH_SIZE:int = 16;
public function MD5(){
super();
}
private function ff(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint{
return (cmn(((b & c) | (~(b) & d)), a, b, x, s, t));
}
private function hh(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint{
return (cmn(((b ^ c) ^ d), a, b, x, s, t));
}
private function cmn(q:uint, a:uint, b:uint, x:uint, s:uint, t:uint):uint{
return ((rol((((a + q) + x) + t), s) + b));
}
public function getHashSize():uint{
return (HASH_SIZE);
}
private function ii(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint{
return (cmn((c ^ (b | ~(d))), a, b, x, s, t));
}
private function rol(num:uint, cnt:uint):uint{
return (((num << cnt) | (num >>> (32 - cnt))));
}
public function toString():String{
return ("md5");
}
public function getInputSize():uint{
return (64);
}
private function gg(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint{
return (cmn(((b & d) | (c & ~(d))), a, b, x, s, t));
}
public function hash(src:ByteArray):ByteArray{
var len:uint;
var savedEndian:String;
var a:Array;
var i:uint;
var h:Array;
var out:ByteArray;
len = (src.length * 8);
savedEndian = src.endian;
while ((src.length % 4) != 0) {
src[src.length] = 0;
};
src.position = 0;
a = [];
src.endian = Endian.LITTLE_ENDIAN;
i = 0;
while (i < src.length) {
a.push(src.readUnsignedInt());
i = (i + 4);
};
h = core_md5(a, len);
out = new ByteArray();
out.endian = Endian.LITTLE_ENDIAN;
i = 0;
while (i < 4) {
out.writeUnsignedInt(h[i]);
i++;
};
src.length = (len / 8);
src.endian = savedEndian;
return (out);
}
private function core_md5(x:Array, len:uint):Array{
var a:uint;
var b:uint;
var c:uint;
var d:uint;
var i:uint;
var olda:uint;
var oldb:uint;
var oldc:uint;
var oldd:uint;
x[(len >> 5)] = (x[(len >> 5)] | (128 << (len % 32)));
x[((((len + 64) >>> 9) << 4) + 14)] = len;
a = 1732584193;
b = 4023233417;
c = 2562383102;
d = 271733878;
i = 0;
while (i < x.length) {
x[i] = ((x[i]) || (0));
x[(i + 1)] = ((x[(i + 1)]) || (0));
x[(i + 2)] = ((x[(i + 2)]) || (0));
x[(i + 3)] = ((x[(i + 3)]) || (0));
x[(i + 4)] = ((x[(i + 4)]) || (0));
x[(i + 5)] = ((x[(i + 5)]) || (0));
x[(i + 6)] = ((x[(i + 6)]) || (0));
x[(i + 7)] = ((x[(i + 7)]) || (0));
x[(i + 8)] = ((x[(i + 8)]) || (0));
x[(i + 9)] = ((x[(i + 9)]) || (0));
x[(i + 10)] = ((x[(i + 10)]) || (0));
x[(i + 11)] = ((x[(i + 11)]) || (0));
x[(i + 12)] = ((x[(i + 12)]) || (0));
x[(i + 13)] = ((x[(i + 13)]) || (0));
x[(i + 14)] = ((x[(i + 14)]) || (0));
x[(i + 15)] = ((x[(i + 15)]) || (0));
olda = a;
oldb = b;
oldc = c;
oldd = d;
a = ff(a, b, c, d, x[(i + 0)], 7, 3614090360);
d = ff(d, a, b, c, x[(i + 1)], 12, 3905402710);
c = ff(c, d, a, b, x[(i + 2)], 17, 606105819);
b = ff(b, c, d, a, x[(i + 3)], 22, 3250441966);
a = ff(a, b, c, d, x[(i + 4)], 7, 4118548399);
d = ff(d, a, b, c, x[(i + 5)], 12, 1200080426);
c = ff(c, d, a, b, x[(i + 6)], 17, 2821735955);
b = ff(b, c, d, a, x[(i + 7)], 22, 4249261313);
a = ff(a, b, c, d, x[(i + 8)], 7, 1770035416);
d = ff(d, a, b, c, x[(i + 9)], 12, 2336552879);
c = ff(c, d, a, b, x[(i + 10)], 17, 4294925233);
b = ff(b, c, d, a, x[(i + 11)], 22, 2304563134);
a = ff(a, b, c, d, x[(i + 12)], 7, 1804603682);
d = ff(d, a, b, c, x[(i + 13)], 12, 4254626195);
c = ff(c, d, a, b, x[(i + 14)], 17, 2792965006);
b = ff(b, c, d, a, x[(i + 15)], 22, 1236535329);
a = gg(a, b, c, d, x[(i + 1)], 5, 4129170786);
d = gg(d, a, b, c, x[(i + 6)], 9, 3225465664);
c = gg(c, d, a, b, x[(i + 11)], 14, 643717713);
b = gg(b, c, d, a, x[(i + 0)], 20, 3921069994);
a = gg(a, b, c, d, x[(i + 5)], 5, 3593408605);
d = gg(d, a, b, c, x[(i + 10)], 9, 38016083);
c = gg(c, d, a, b, x[(i + 15)], 14, 3634488961);
b = gg(b, c, d, a, x[(i + 4)], 20, 3889429448);
a = gg(a, b, c, d, x[(i + 9)], 5, 568446438);
d = gg(d, a, b, c, x[(i + 14)], 9, 3275163606);
c = gg(c, d, a, b, x[(i + 3)], 14, 4107603335);
b = gg(b, c, d, a, x[(i + 8)], 20, 1163531501);
a = gg(a, b, c, d, x[(i + 13)], 5, 2850285829);
d = gg(d, a, b, c, x[(i + 2)], 9, 4243563512);
c = gg(c, d, a, b, x[(i + 7)], 14, 1735328473);
b = gg(b, c, d, a, x[(i + 12)], 20, 2368359562);
a = hh(a, b, c, d, x[(i + 5)], 4, 4294588738);
d = hh(d, a, b, c, x[(i + 8)], 11, 2272392833);
c = hh(c, d, a, b, x[(i + 11)], 16, 1839030562);
b = hh(b, c, d, a, x[(i + 14)], 23, 4259657740);
a = hh(a, b, c, d, x[(i + 1)], 4, 2763975236);
d = hh(d, a, b, c, x[(i + 4)], 11, 1272893353);
c = hh(c, d, a, b, x[(i + 7)], 16, 4139469664);
b = hh(b, c, d, a, x[(i + 10)], 23, 3200236656);
a = hh(a, b, c, d, x[(i + 13)], 4, 681279174);
d = hh(d, a, b, c, x[(i + 0)], 11, 3936430074);
c = hh(c, d, a, b, x[(i + 3)], 16, 3572445317);
b = hh(b, c, d, a, x[(i + 6)], 23, 76029189);
a = hh(a, b, c, d, x[(i + 9)], 4, 3654602809);
d = hh(d, a, b, c, x[(i + 12)], 11, 3873151461);
c = hh(c, d, a, b, x[(i + 15)], 16, 530742520);
b = hh(b, c, d, a, x[(i + 2)], 23, 3299628645);
a = ii(a, b, c, d, x[(i + 0)], 6, 4096336452);
d = ii(d, a, b, c, x[(i + 7)], 10, 1126891415);
c = ii(c, d, a, b, x[(i + 14)], 15, 2878612391);
b = ii(b, c, d, a, x[(i + 5)], 21, 4237533241);
a = ii(a, b, c, d, x[(i + 12)], 6, 1700485571);
d = ii(d, a, b, c, x[(i + 3)], 10, 2399980690);
c = ii(c, d, a, b, x[(i + 10)], 15, 4293915773);
b = ii(b, c, d, a, x[(i + 1)], 21, 2240044497);
a = ii(a, b, c, d, x[(i + 8)], 6, 1873313359);
d = ii(d, a, b, c, x[(i + 15)], 10, 4264355552);
c = ii(c, d, a, b, x[(i + 6)], 15, 2734768916);
b = ii(b, c, d, a, x[(i + 13)], 21, 1309151649);
a = ii(a, b, c, d, x[(i + 4)], 6, 4149444226);
d = ii(d, a, b, c, x[(i + 11)], 10, 3174756917);
c = ii(c, d, a, b, x[(i + 2)], 15, 718787259);
b = ii(b, c, d, a, x[(i + 9)], 21, 3951481745);
a = (a + olda);
b = (b + oldb);
c = (c + oldc);
d = (d + oldd);
i = (i + 16);
};
return ([a, b, c, d]);
}
}
}//package com.hurlant.crypto.hash
Section 20
//SHA1 (com.hurlant.crypto.hash.SHA1)
package com.hurlant.crypto.hash {
public class SHA1 extends SHABase implements IHash {
public static const HASH_SIZE:int = 20;
public function SHA1(){
super();
}
private function ft(t:uint, b:uint, c:uint, d:uint):uint{
if (t < 20){
return (((b & c) | (~(b) & d)));
};
if (t < 40){
return (((b ^ c) ^ d));
};
if (t < 60){
return ((((b & c) | (b & d)) | (c & d)));
};
return (((b ^ c) ^ d));
}
private function kt(t:uint):uint{
return (((t)<20) ? 1518500249 : ((t)<40) ? 1859775393 : ((t)<60) ? 2400959708 : 3395469782);
}
override public function toString():String{
return ("sha1");
}
override public function getHashSize():uint{
return (HASH_SIZE);
}
private function rol(num:uint, cnt:uint):uint{
return (((num << cnt) | (num >>> (32 - cnt))));
}
override protected function core(x:Array, len:uint):Array{
var w:Array;
var a:uint;
var b:uint;
var c:uint;
var d:uint;
var e:uint;
var i:uint;
var olda:uint;
var oldb:uint;
var oldc:uint;
var oldd:uint;
var olde:uint;
var j:uint;
var t:uint;
x[(len >> 5)] = (x[(len >> 5)] | (128 << (24 - (len % 32))));
x[((((len + 64) >> 9) << 4) + 15)] = len;
w = [];
a = 1732584193;
b = 4023233417;
c = 2562383102;
d = 271733878;
e = 3285377520;
i = 0;
while (i < x.length) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
olde = e;
j = 0;
while (j < 80) {
if (j < 16){
w[j] = ((x[(i + j)]) || (0));
} else {
w[j] = rol((((w[(j - 3)] ^ w[(j - 8)]) ^ w[(j - 14)]) ^ w[(j - 16)]), 1);
};
t = ((((rol(a, 5) + ft(j, b, c, d)) + e) + w[j]) + kt(j));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
j++;
};
a = (a + olda);
b = (b + oldb);
c = (c + oldc);
d = (d + oldd);
e = (e + olde);
i = (i + 16);
};
return ([a, b, c, d, e]);
}
}
}//package com.hurlant.crypto.hash
Section 21
//SHA224 (com.hurlant.crypto.hash.SHA224)
package com.hurlant.crypto.hash {
public class SHA224 extends SHA256 {
public function SHA224(){
super();
h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428];
}
override public function getHashSize():uint{
return (28);
}
override public function toString():String{
return ("sha224");
}
}
}//package com.hurlant.crypto.hash
Section 22
//SHA256 (com.hurlant.crypto.hash.SHA256)
package com.hurlant.crypto.hash {
public class SHA256 extends SHABase implements IHash {
protected var h:Array;
protected static const k:Array = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298];
public function SHA256(){
h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225];
super();
}
protected function rrol(num:uint, cnt:uint):uint{
return (((num << (32 - cnt)) | (num >>> cnt)));
}
override public function toString():String{
return ("sha256");
}
override public function getHashSize():uint{
return (32);
}
override protected function core(x:Array, len:uint):Array{
var w:Array;
var a:uint;
var b:uint;
var c:uint;
var d:uint;
var e:uint;
var f:uint;
var g:uint;
var h:uint;
var i:uint;
var olda:uint;
var oldb:uint;
var oldc:uint;
var oldd:uint;
var olde:uint;
var oldf:uint;
var oldg:uint;
var oldh:uint;
var j:uint;
var t2:uint;
var t1:uint;
var s0:uint;
var s1:uint;
x[(len >> 5)] = (x[(len >> 5)] | (128 << (24 - (len % 32))));
x[((((len + 64) >> 9) << 4) + 15)] = len;
w = [];
a = h[0];
b = h[1];
c = h[2];
d = h[3];
e = h[4];
f = h[5];
g = h[6];
h = h[7];
i = 0;
while (i < x.length) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
olde = e;
oldf = f;
oldg = g;
oldh = h;
j = 0;
while (j < 64) {
if (j < 16){
w[j] = ((x[(i + j)]) || (0));
} else {
s0 = ((rrol(w[(j - 15)], 7) ^ rrol(w[(j - 15)], 18)) ^ (w[(j - 15)] >>> 3));
s1 = ((rrol(w[(j - 2)], 17) ^ rrol(w[(j - 2)], 19)) ^ (w[(j - 2)] >>> 10));
w[j] = (((w[(j - 16)] + s0) + w[(j - 7)]) + s1);
};
t2 = (((rrol(a, 2) ^ rrol(a, 13)) ^ rrol(a, 22)) + (((a & b) ^ (a & c)) ^ (b & c)));
t1 = ((((h + ((rrol(e, 6) ^ rrol(e, 11)) ^ rrol(e, 25))) + ((e & f) ^ (g & ~(e)))) + k[j]) + w[j]);
h = g;
g = f;
f = e;
e = (d + t1);
d = c;
c = b;
b = a;
a = (t1 + t2);
j++;
};
a = (a + olda);
b = (b + oldb);
c = (c + oldc);
d = (d + oldd);
e = (e + olde);
f = (f + oldf);
g = (g + oldg);
h = (h + oldh);
i = (i + 16);
};
return ([a, b, c, d, e, f, g, h]);
}
}
}//package com.hurlant.crypto.hash
Section 23
//SHABase (com.hurlant.crypto.hash.SHABase)
package com.hurlant.crypto.hash {
import flash.utils.*;
public class SHABase implements IHash {
public function SHABase(){
super();
}
public function getHashSize():uint{
return (0);
}
public function toString():String{
return ("sha");
}
public function getInputSize():uint{
return (64);
}
public function hash(src:ByteArray):ByteArray{
var savedLength:uint;
var savedEndian:String;
var len:uint;
var a:Array;
var i:uint;
var h:Array;
var out:ByteArray;
var words:uint;
savedLength = src.length;
savedEndian = src.endian;
src.endian = Endian.BIG_ENDIAN;
len = (savedLength * 8);
while ((src.length % 4) != 0) {
src[src.length] = 0;
};
src.position = 0;
a = [];
i = 0;
while (i < src.length) {
a.push(src.readUnsignedInt());
i = (i + 4);
};
h = core(a, len);
out = new ByteArray();
words = (getHashSize() / 4);
i = 0;
while (i < words) {
out.writeUnsignedInt(h[i]);
i++;
};
src.length = savedLength;
src.endian = savedEndian;
return (out);
}
protected function core(x:Array, len:uint):Array{
return (null);
}
}
}//package com.hurlant.crypto.hash
Section 24
//ARC4 (com.hurlant.crypto.prng.ARC4)
package com.hurlant.crypto.prng {
import flash.utils.*;
import com.hurlant.crypto.symmetric.*;
import com.hurlant.util.*;
public class ARC4 implements IPRNG, IStreamCipher {
private const psize:uint = 0x0100;
private var S:ByteArray;
private var i:int;// = 0
private var j:int;// = 0
public function ARC4(key:ByteArray=null){
i = 0;
j = 0;
super();
S = new ByteArray();
if (key){
init(key);
};
}
public function decrypt(block:ByteArray):void{
encrypt(block);
}
public function init(key:ByteArray):void{
var i:int;
var j:int;
var t:int;
i = 0;
while (i < 0x0100) {
S[i] = i;
i++;
};
j = 0;
i = 0;
while (i < 0x0100) {
j = (((j + S[i]) + key[(i % key.length)]) & 0xFF);
t = S[i];
S[i] = S[j];
S[j] = t;
i++;
};
this.i = 0;
this.j = 0;
}
public function dispose():void{
var i:uint;
i = 0;
if (S != null){
i = 0;
while (i < S.length) {
S[i] = (Math.random() * 0x0100);
i++;
};
S.length = 0;
S = null;
};
this.i = 0;
this.j = 0;
Memory.gc();
}
public function encrypt(block:ByteArray):void{
var i:uint;
i = 0;
while (i < block.length) {
var _temp1 = i;
i = (i + 1);
var _local3 = _temp1;
block[_local3] = (block[_local3] ^ next());
};
}
public function next():uint{
var t:int;
i = ((i + 1) & 0xFF);
j = ((j + S[i]) & 0xFF);
t = S[i];
S[i] = S[j];
S[j] = t;
return (S[((t + S[i]) & 0xFF)]);
}
public function getBlockSize():uint{
return (1);
}
public function getPoolSize():uint{
return (psize);
}
public function toString():String{
return ("rc4");
}
}
}//package com.hurlant.crypto.prng
Section 25
//IPRNG (com.hurlant.crypto.prng.IPRNG)
package com.hurlant.crypto.prng {
import flash.utils.*;
public interface IPRNG {
function init(D:\dev\GAMES\TD;com\hurlant\crypto\prng;IPRNG.as:ByteArray):void;
function next():uint;
function dispose():void;
function getPoolSize():uint;
function toString():String;
}
}//package com.hurlant.crypto.prng
Section 26
//Random (com.hurlant.crypto.prng.Random)
package com.hurlant.crypto.prng {
import flash.utils.*;
import com.hurlant.util.*;
import flash.text.*;
import flash.system.*;
public class Random {
private var psize:int;
private var ready:Boolean;// = false
private var seeded:Boolean;// = false
private var state:IPRNG;
private var pool:ByteArray;
private var pptr:int;
public function Random(prng:Class=null){
var t:uint;
ready = false;
seeded = false;
super();
if (prng == null){
prng = ARC4;
};
state = (new (prng) as IPRNG);
psize = state.getPoolSize();
pool = new ByteArray();
pptr = 0;
while (pptr < psize) {
t = (65536 * Math.random());
var _local3 = pptr++;
pool[_local3] = (t >>> 8);
var _local4 = pptr++;
pool[_local4] = (t & 0xFF);
};
pptr = 0;
seed();
}
public function seed(x:int=0):void{
if (x == 0){
x = new Date().getTime();
};
var _local2 = pptr++;
pool[_local2] = (pool[_local2] ^ (x & 0xFF));
var _local3 = pptr++;
pool[_local3] = (pool[_local3] ^ ((x >> 8) & 0xFF));
var _local4 = pptr++;
pool[_local4] = (pool[_local4] ^ ((x >> 16) & 0xFF));
var _local5 = pptr++;
pool[_local5] = (pool[_local5] ^ ((x >> 24) & 0xFF));
pptr = (pptr % psize);
seeded = true;
}
public function toString():String{
return (("random-" + state.toString()));
}
public function dispose():void{
var i:uint;
i = 0;
while (i < pool.length) {
pool[i] = (Math.random() * 0x0100);
i++;
};
pool.length = 0;
pool = null;
state.dispose();
state = null;
psize = 0;
pptr = 0;
Memory.gc();
}
public function autoSeed():void{
var b:ByteArray;
var a:Array;
var f:Font;
b = new ByteArray();
b.writeUnsignedInt(System.totalMemory);
b.writeUTF(Capabilities.serverString);
b.writeUnsignedInt(getTimer());
b.writeUnsignedInt(new Date().getTime());
a = Font.enumerateFonts(true);
for each (f in a) {
b.writeUTF(f.fontName);
b.writeUTF(f.fontStyle);
b.writeUTF(f.fontType);
};
b.position = 0;
while (b.bytesAvailable >= 4) {
seed(b.readUnsignedInt());
};
}
public function nextByte():int{
if (!ready){
if (!seeded){
autoSeed();
};
state.init(pool);
pool.length = 0;
pptr = 0;
ready = true;
};
return (state.next());
}
public function nextBytes(buffer:ByteArray, length:int):void{
while (length--) {
buffer.writeByte(nextByte());
};
}
}
}//package com.hurlant.crypto.prng
Section 27
//RSAKey (com.hurlant.crypto.rsa.RSAKey)
package com.hurlant.crypto.rsa {
import flash.utils.*;
import com.hurlant.math.*;
import com.hurlant.crypto.prng.*;
import com.hurlant.util.*;
public class RSAKey {
public var dmp1:BigInteger;
protected var canDecrypt:Boolean;
public var d:BigInteger;
public var e:int;
public var dmq1:BigInteger;
public var n:BigInteger;
public var p:BigInteger;
public var q:BigInteger;
protected var canEncrypt:Boolean;
public var coeff:BigInteger;
public function RSAKey(N:BigInteger, E:int, D:BigInteger=null, P:BigInteger=null, Q:BigInteger=null, DP:BigInteger=null, DQ:BigInteger=null, C:BigInteger=null){
super();
this.n = N;
this.e = E;
this.d = D;
this.p = P;
this.q = Q;
this.dmp1 = DP;
this.dmq1 = DQ;
this.coeff = C;
canEncrypt = ((!((n == null))) && (!((e == 0))));
canDecrypt = ((canEncrypt) && (!((d == null))));
}
public function verify(src:ByteArray, dst:ByteArray, length:uint, pad:Function=null):void{
_decrypt(doPublic, src, dst, length, pad, 1);
}
public function dump():String{
var s:String;
s = ((((("N=" + n.toString(16)) + "\n") + "E=") + e.toString(16)) + "\n");
if (canDecrypt){
s = (s + (("D=" + d.toString(16)) + "\n"));
if (((!((p == null))) && (!((q == null))))){
s = (s + (("P=" + p.toString(16)) + "\n"));
s = (s + (("Q=" + q.toString(16)) + "\n"));
s = (s + (("DMP1=" + dmp1.toString(16)) + "\n"));
s = (s + (("DMQ1=" + dmq1.toString(16)) + "\n"));
s = (s + (("IQMP=" + coeff.toString(16)) + "\n"));
};
};
return (s);
}
protected function doPrivate2(x:BigInteger):BigInteger{
var xp:BigInteger;
var xq:BigInteger;
var r:BigInteger;
if ((((p == null)) && ((q == null)))){
return (x.modPow(d, n));
};
xp = x.mod(p).modPow(dmp1, p);
xq = x.mod(q).modPow(dmq1, q);
while (xp.compareTo(xq) < 0) {
xp = xp.add(p);
};
r = xp.subtract(xq).multiply(coeff).mod(p).multiply(q).add(xq);
return (r);
}
public function decrypt(src:ByteArray, dst:ByteArray, length:uint, pad:Function=null):void{
_decrypt(doPrivate2, src, dst, length, pad, 2);
}
private function _decrypt(op:Function, src:ByteArray, dst:ByteArray, length:uint, pad:Function, padType:int):void{
var bl:uint;
var end:int;
var block:BigInteger;
var chunk:BigInteger;
var b:ByteArray;
if (pad == null){
pad = pkcs1unpad;
};
if (src.position >= src.length){
src.position = 0;
};
bl = getBlockSize();
end = (src.position + length);
while (src.position < end) {
block = new BigInteger(src, length);
chunk = op(block);
b = pad(chunk, bl);
dst.writeBytes(b);
};
}
protected function doPublic(x:BigInteger):BigInteger{
return (x.modPowInt(e, n));
}
public function dispose():void{
e = 0;
n.dispose();
n = null;
Memory.gc();
}
private function _encrypt(op:Function, src:ByteArray, dst:ByteArray, length:uint, pad:Function, padType:int):void{
var bl:uint;
var end:int;
var block:BigInteger;
var chunk:BigInteger;
if (pad == null){
pad = pkcs1pad;
};
if (src.position >= src.length){
src.position = 0;
};
bl = getBlockSize();
end = (src.position + length);
while (src.position < end) {
block = new BigInteger(pad(src, end, bl, padType), bl);
chunk = op(block);
chunk.toArray(dst);
};
}
private function rawpad(src:ByteArray, end:int, n:uint):ByteArray{
return (src);
}
public function encrypt(src:ByteArray, dst:ByteArray, length:uint, pad:Function=null):void{
_encrypt(doPublic, src, dst, length, pad, 2);
}
private function pkcs1pad(src:ByteArray, end:int, n:uint, type:uint=2):ByteArray{
var out:ByteArray;
var p:uint;
var i:int;
var rng:Random;
var x:int;
out = new ByteArray();
p = src.position;
end = Math.min(end, src.length, ((p + n) - 11));
src.position = end;
i = (end - 1);
while ((((i >= p)) && ((n > 11)))) {
--n;
var _local10 = n;
var _temp1 = i;
i = (i - 1);
out[_local10] = src[_temp1];
};
--n;
_local10 = n;
out[_local10] = 0;
rng = new Random();
while (n > 2) {
x = 0;
while (x == 0) {
x = ((type)==2) ? rng.nextByte() : 0xFF;
};
--n;
var _local11 = n;
out[_local11] = x;
};
--n;
_local11 = n;
out[_local11] = type;
--n;
var _local12 = n;
out[_local12] = 0;
return (out);
}
private function pkcs1unpad(src:BigInteger, n:uint, type:uint=2):ByteArray{
var b:ByteArray;
var out:ByteArray;
var i:int;
b = src.toByteArray();
out = new ByteArray();
i = 0;
while ((((i < b.length)) && ((b[i] == 0)))) {
i++;
};
if (((!(((b.length - i) == (n - 1)))) || ((b[i] > 2)))){
trace(((("PKCS#1 unpad: i=" + i) + ", expected b[i]==[0,1,2], got b[i]=") + b[i].toString(16)));
return (null);
};
i++;
while (b[i] != 0) {
++i;
if (i >= b.length){
trace((((("PKCS#1 unpad: i=" + i) + ", b[i-1]!=0 (=") + b[(i - 1)].toString(16)) + ")"));
return (null);
};
};
while (++i < b.length) {
out.writeByte(b[i]);
};
out.position = 0;
return (out);
}
public function getBlockSize():uint{
return (((n.bitLength() + 7) / 8));
}
public function toString():String{
return ("rsa");
}
public function sign(src:ByteArray, dst:ByteArray, length:uint, pad:Function=null):void{
_encrypt(doPrivate2, src, dst, length, pad, 1);
}
protected function doPrivate(x:BigInteger):BigInteger{
var xp:BigInteger;
var xq:BigInteger;
if ((((p == null)) || ((q == null)))){
return (x.modPow(d, n));
};
xp = x.mod(p).modPow(dmp1, p);
xq = x.mod(q).modPow(dmq1, q);
while (xp.compareTo(xq) < 0) {
xp = xp.add(p);
};
return (xp.subtract(xq).multiply(coeff).mod(p).multiply(q).add(xq));
}
protected static function bigRandom(bits:int, rnd:Random):BigInteger{
var x:ByteArray;
var b:BigInteger;
if (bits < 2){
return (BigInteger.nbv(1));
};
x = new ByteArray();
rnd.nextBytes(x, (bits >> 3));
x.position = 0;
b = new BigInteger(x);
b.primify(bits, 1);
return (b);
}
public static function parsePublicKey(N:String, E:String):RSAKey{
return (new RSAKey(new BigInteger(N, 16), parseInt(E, 16)));
}
public static function generate(B:uint, E:String):RSAKey{
var rng:Random;
var qs:uint;
var key:RSAKey;
var ee:BigInteger;
var p1:BigInteger;
var q1:BigInteger;
var phi:BigInteger;
var t:BigInteger;
rng = new Random();
qs = (B >> 1);
key = new RSAKey(null, 0, null);
key.e = parseInt(E, 16);
ee = new BigInteger(E, 16);
while (true) {
while (true) {
key.p = bigRandom((B - qs), rng);
if ((((key.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0)) && (key.p.isProbablePrime(10)))){
break;
};
};
while (true) {
key.q = bigRandom(qs, rng);
if ((((key.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0)) && (key.q.isProbablePrime(10)))){
break;
};
};
if (key.p.compareTo(key.q) <= 0){
t = key.p;
key.p = key.q;
key.q = t;
};
p1 = key.p.subtract(BigInteger.ONE);
q1 = key.q.subtract(BigInteger.ONE);
phi = p1.multiply(q1);
if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0){
key.n = key.p.multiply(key.q);
key.d = ee.modInverse(phi);
key.dmp1 = key.d.mod(p1);
key.dmq1 = key.d.mod(q1);
key.coeff = key.q.modInverse(key.p);
break;
};
};
return (key);
}
public static function parsePrivateKey(N:String, E:String, D:String, P:String=null, Q:String=null, DMP1:String=null, DMQ1:String=null, IQMP:String=null):RSAKey{
if (P == null){
return (new RSAKey(new BigInteger(N, 16), parseInt(E, 16), new BigInteger(D, 16)));
};
return (new RSAKey(new BigInteger(N, 16), parseInt(E, 16), new BigInteger(D, 16), new BigInteger(P, 16), new BigInteger(Q, 16), new BigInteger(DMP1, 16), new BigInteger(DMQ1), new BigInteger(IQMP)));
}
}
}//package com.hurlant.crypto.rsa
Section 28
//AESKey (com.hurlant.crypto.symmetric.AESKey)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.crypto.prng.*;
import com.hurlant.util.*;
public class AESKey implements ISymmetricKey {
private var state:ByteArray;
private var tmp:ByteArray;
private var Nr:uint;
private var keyLength:uint;
private var key:ByteArray;
private static const _Xtime2:Array = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 27, 25, 31, 29, 19, 17, 23, 21, 11, 9, 15, 13, 3, 1, 7, 5, 59, 57, 63, 61, 51, 49, 55, 53, 43, 41, 47, 45, 35, 33, 39, 37, 91, 89, 95, 93, 83, 81, 87, 85, 75, 73, 79, 77, 67, 65, 71, 69, 123, 121, 127, 125, 115, 113, 119, 117, 107, 105, 111, 109, 99, 97, 103, 101, 155, 153, 159, 157, 147, 145, 151, 149, 139, 137, 143, 141, 131, 129, 135, 133, 187, 185, 191, 189, 179, 177, 183, 181, 171, 169, 175, 173, 163, 161, 167, 165, 219, 217, 223, 221, 211, 209, 215, 213, 203, 201, 207, 205, 195, 193, 199, 197, 251, 249, 0xFF, 253, 243, 241, 247, 245, 235, 233, 239, 237, 227, 225, 231, 229];
private static const _Xtime9:Array = [0, 9, 18, 27, 36, 45, 54, 63, 72, 65, 90, 83, 108, 101, 126, 119, 144, 153, 130, 139, 180, 189, 166, 175, 216, 209, 202, 195, 252, 245, 238, 231, 59, 50, 41, 32, 31, 22, 13, 4, 115, 122, 97, 104, 87, 94, 69, 76, 171, 162, 185, 176, 143, 134, 157, 148, 227, 234, 241, 248, 199, 206, 213, 220, 118, 127, 100, 109, 82, 91, 64, 73, 62, 55, 44, 37, 26, 19, 8, 1, 230, 239, 244, 253, 194, 203, 208, 217, 174, 167, 188, 181, 138, 131, 152, 145, 77, 68, 95, 86, 105, 96, 123, 114, 5, 12, 23, 30, 33, 40, 51, 58, 221, 212, 207, 198, 249, 240, 235, 226, 149, 156, 135, 142, 177, 184, 163, 170, 236, 229, 254, 247, 200, 193, 218, 211, 164, 173, 182, 191, 128, 137, 146, 155, 124, 117, 110, 103, 88, 81, 74, 67, 52, 61, 38, 47, 16, 25, 2, 11, 215, 222, 197, 204, 243, 250, 225, 232, 159, 150, 141, 132, 187, 178, 169, 160, 71, 78, 85, 92, 99, 106, 113, 120, 15, 6, 29, 20, 43, 34, 57, 48, 154, 147, 136, 129, 190, 183, 172, 165, 210, 219, 192, 201, 246, 0xFF, 228, 237, 10, 3, 24, 17, 46, 39, 60, 53, 66, 75, 80, 89, 102, 111, 116, 125, 161, 168, 179, 186, 133, 140, 151, 158, 233, 224, 251, 242, 205, 196, 223, 214, 49, 56, 35, 42, 21, 28, 7, 14, 121, 112, 107, 98, 93, 84, 79, 70];
private static const Nb:uint = 4;
private static const _XtimeB:Array = [0, 11, 22, 29, 44, 39, 58, 49, 88, 83, 78, 69, 116, 127, 98, 105, 176, 187, 166, 173, 156, 151, 138, 129, 232, 227, 254, 245, 196, 207, 210, 217, 123, 112, 109, 102, 87, 92, 65, 74, 35, 40, 53, 62, 15, 4, 25, 18, 203, 192, 221, 214, 231, 236, 241, 250, 147, 152, 133, 142, 191, 180, 169, 162, 246, 253, 224, 235, 218, 209, 204, 199, 174, 165, 184, 179, 130, 137, 148, 159, 70, 77, 80, 91, 106, 97, 124, 119, 30, 21, 8, 3, 50, 57, 36, 47, 141, 134, 155, 144, 161, 170, 183, 188, 213, 222, 195, 200, 249, 242, 239, 228, 61, 54, 43, 32, 17, 26, 7, 12, 101, 110, 115, 120, 73, 66, 95, 84, 247, 252, 225, 234, 219, 208, 205, 198, 175, 164, 185, 178, 131, 136, 149, 158, 71, 76, 81, 90, 107, 96, 125, 118, 31, 20, 9, 2, 51, 56, 37, 46, 140, 135, 154, 145, 160, 171, 182, 189, 212, 223, 194, 201, 248, 243, 238, 229, 60, 55, 42, 33, 16, 27, 6, 13, 100, 111, 114, 121, 72, 67, 94, 85, 1, 10, 23, 28, 45, 38, 59, 48, 89, 82, 79, 68, 117, 126, 99, 104, 177, 186, 167, 172, 157, 150, 139, 128, 233, 226, 0xFF, 244, 197, 206, 211, 216, 122, 113, 108, 103, 86, 93, 64, 75, 34, 41, 52, 63, 14, 5, 24, 19, 202, 193, 220, 215, 230, 237, 240, 251, 146, 153, 132, 143, 190, 181, 168, 163];
private static const _XtimeE:Array = [0, 14, 28, 18, 56, 54, 36, 42, 112, 126, 108, 98, 72, 70, 84, 90, 224, 238, 252, 242, 216, 214, 196, 202, 144, 158, 140, 130, 168, 166, 180, 186, 219, 213, 199, 201, 227, 237, 0xFF, 241, 171, 165, 183, 185, 147, 157, 143, 129, 59, 53, 39, 41, 3, 13, 31, 17, 75, 69, 87, 89, 115, 125, 111, 97, 173, 163, 177, 191, 149, 155, 137, 135, 221, 211, 193, 207, 229, 235, 249, 247, 77, 67, 81, 95, 117, 123, 105, 103, 61, 51, 33, 47, 5, 11, 25, 23, 118, 120, 106, 100, 78, 64, 82, 92, 6, 8, 26, 20, 62, 48, 34, 44, 150, 152, 138, 132, 174, 160, 178, 188, 230, 232, 250, 244, 222, 208, 194, 204, 65, 79, 93, 83, 121, 119, 101, 107, 49, 63, 45, 35, 9, 7, 21, 27, 161, 175, 189, 179, 153, 151, 133, 139, 209, 223, 205, 195, 233, 231, 245, 251, 154, 148, 134, 136, 162, 172, 190, 176, 234, 228, 246, 248, 210, 220, 206, 192, 122, 116, 102, 104, 66, 76, 94, 80, 10, 4, 22, 24, 50, 60, 46, 32, 236, 226, 240, 254, 212, 218, 200, 198, 156, 146, 128, 142, 164, 170, 184, 182, 12, 2, 16, 30, 52, 58, 40, 38, 124, 114, 96, 110, 68, 74, 88, 86, 55, 57, 43, 37, 15, 1, 19, 29, 71, 73, 91, 85, 127, 113, 99, 109, 215, 217, 203, 197, 239, 225, 243, 253, 167, 169, 187, 181, 159, 145, 131, 141];
private static const _Xtime2Sbox:Array = [198, 248, 238, 246, 0xFF, 214, 222, 145, 96, 2, 206, 86, 231, 181, 77, 236, 143, 31, 137, 250, 239, 178, 142, 251, 65, 179, 95, 69, 35, 83, 228, 155, 117, 225, 61, 76, 108, 126, 245, 131, 104, 81, 209, 249, 226, 171, 98, 42, 8, 149, 70, 157, 48, 55, 10, 47, 14, 36, 27, 223, 205, 78, 127, 234, 18, 29, 88, 52, 54, 220, 180, 91, 164, 118, 183, 125, 82, 221, 94, 19, 166, 185, 0, 193, 64, 227, 121, 182, 212, 141, 103, 114, 148, 152, 176, 133, 187, 197, 79, 237, 134, 154, 102, 17, 138, 233, 4, 254, 160, 120, 37, 75, 162, 93, 128, 5, 63, 33, 112, 241, 99, 119, 175, 66, 32, 229, 253, 191, 129, 24, 38, 195, 190, 53, 136, 46, 147, 85, 252, 122, 200, 186, 50, 230, 192, 25, 158, 163, 68, 84, 59, 11, 140, 199, 107, 40, 167, 188, 22, 173, 219, 100, 116, 20, 146, 12, 72, 184, 159, 189, 67, 196, 57, 49, 211, 242, 213, 139, 110, 218, 1, 177, 156, 73, 216, 172, 243, 207, 202, 244, 71, 16, 111, 240, 74, 92, 56, 87, 115, 151, 203, 161, 232, 62, 150, 97, 13, 15, 224, 124, 113, 204, 144, 6, 247, 28, 194, 106, 174, 105, 23, 153, 58, 39, 217, 235, 43, 34, 210, 169, 7, 51, 45, 60, 21, 201, 135, 170, 80, 165, 3, 89, 9, 26, 101, 215, 132, 208, 130, 41, 90, 30, 123, 168, 109, 44];
private static const _Xtime3Sbox:Array = [165, 132, 153, 141, 13, 189, 177, 84, 80, 3, 169, 125, 25, 98, 230, 154, 69, 157, 64, 135, 21, 235, 201, 11, 236, 103, 253, 234, 191, 247, 150, 91, 194, 28, 174, 106, 90, 65, 2, 79, 92, 244, 52, 8, 147, 115, 83, 63, 12, 82, 101, 94, 40, 161, 15, 181, 9, 54, 155, 61, 38, 105, 205, 159, 27, 158, 116, 46, 45, 178, 238, 251, 246, 77, 97, 206, 123, 62, 113, 151, 245, 104, 0, 44, 96, 31, 200, 237, 190, 70, 217, 75, 222, 212, 232, 74, 107, 42, 229, 22, 197, 215, 85, 148, 207, 16, 6, 129, 240, 68, 186, 227, 243, 254, 192, 138, 173, 188, 72, 4, 223, 193, 117, 99, 48, 26, 14, 109, 76, 20, 53, 47, 225, 162, 204, 57, 87, 242, 130, 71, 172, 231, 43, 149, 160, 152, 209, 127, 102, 126, 171, 131, 202, 41, 211, 60, 121, 226, 29, 118, 59, 86, 78, 30, 219, 10, 108, 228, 93, 110, 239, 166, 168, 164, 55, 139, 50, 67, 89, 183, 140, 100, 210, 224, 180, 250, 7, 37, 175, 142, 233, 24, 213, 136, 111, 114, 36, 241, 199, 81, 35, 124, 156, 33, 221, 220, 134, 133, 144, 66, 196, 170, 216, 5, 1, 18, 163, 95, 249, 208, 145, 88, 39, 185, 56, 19, 179, 51, 187, 112, 137, 167, 182, 34, 146, 32, 73, 0xFF, 120, 122, 143, 248, 128, 23, 218, 49, 198, 184, 195, 176, 119, 17, 203, 252, 214, 58];
private static const _InvSbox:Array = [82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 0xFF, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125];
private static const _XtimeD:Array = [0, 13, 26, 23, 52, 57, 46, 35, 104, 101, 114, 127, 92, 81, 70, 75, 208, 221, 202, 199, 228, 233, 254, 243, 184, 181, 162, 175, 140, 129, 150, 155, 187, 182, 161, 172, 143, 130, 149, 152, 211, 222, 201, 196, 231, 234, 253, 240, 107, 102, 113, 124, 95, 82, 69, 72, 3, 14, 25, 20, 55, 58, 45, 32, 109, 96, 119, 122, 89, 84, 67, 78, 5, 8, 31, 18, 49, 60, 43, 38, 189, 176, 167, 170, 137, 132, 147, 158, 213, 216, 207, 194, 225, 236, 251, 246, 214, 219, 204, 193, 226, 239, 248, 245, 190, 179, 164, 169, 138, 135, 144, 157, 6, 11, 28, 17, 50, 63, 40, 37, 110, 99, 116, 121, 90, 87, 64, 77, 218, 215, 192, 205, 238, 227, 244, 249, 178, 191, 168, 165, 134, 139, 156, 145, 10, 7, 16, 29, 62, 51, 36, 41, 98, 111, 120, 117, 86, 91, 76, 65, 97, 108, 123, 118, 85, 88, 79, 66, 9, 4, 19, 30, 61, 48, 39, 42, 177, 188, 171, 166, 133, 136, 159, 146, 217, 212, 195, 206, 237, 224, 247, 250, 183, 186, 173, 160, 131, 142, 153, 148, 223, 210, 197, 200, 235, 230, 241, 252, 103, 106, 125, 112, 83, 94, 73, 68, 15, 2, 21, 24, 59, 54, 33, 44, 12, 1, 22, 27, 56, 53, 34, 47, 100, 105, 126, 115, 80, 93, 74, 71, 220, 209, 198, 203, 232, 229, 242, 0xFF, 180, 185, 174, 163, 128, 141, 154, 151];
private static const _Sbox:Array = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 0xFF, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22];
private static var XtimeE:ByteArray = new ByteArray();
private static var i:uint = 0;
private static var Xtime2Sbox:ByteArray = new ByteArray();
private static var Xtime3Sbox:ByteArray = new ByteArray();
private static var _Rcon:Array = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54];
private static var Sbox:ByteArray = new ByteArray();
private static var Rcon:ByteArray = new ByteArray();
private static var InvSbox:ByteArray = new ByteArray();
private static var Xtime2:ByteArray = new ByteArray();
private static var Xtime9:ByteArray = new ByteArray();
private static var XtimeB:ByteArray = new ByteArray();
private static var XtimeD:ByteArray = new ByteArray();
public function AESKey(key:ByteArray){
super();
tmp = new ByteArray();
state = new ByteArray();
keyLength = key.length;
this.key = new ByteArray();
this.key.writeBytes(key);
expandKey();
}
public function toString():String{
return (("aes" + (8 * keyLength)));
}
public function decrypt(block:ByteArray, index:uint=0):void{
var round:uint;
state.position = 0;
state.writeBytes(block, index, (Nb * 4));
addRoundKey(key, ((Nr * Nb) * 4));
invShiftRows();
round = Nr;
while (round--) {
addRoundKey(key, ((round * Nb) * 4));
if (round){
invMixSubColumns();
};
};
block.position = index;
block.writeBytes(state);
}
protected function invShiftRows():void{
var tmp:uint;
state[0] = InvSbox[state[0]];
state[4] = InvSbox[state[4]];
state[8] = InvSbox[state[8]];
state[12] = InvSbox[state[12]];
tmp = InvSbox[state[13]];
state[13] = InvSbox[state[9]];
state[9] = InvSbox[state[5]];
state[5] = InvSbox[state[1]];
state[1] = tmp;
tmp = InvSbox[state[2]];
state[2] = InvSbox[state[10]];
state[10] = tmp;
tmp = InvSbox[state[6]];
state[6] = InvSbox[state[14]];
state[14] = tmp;
tmp = InvSbox[state[3]];
state[3] = InvSbox[state[7]];
state[7] = InvSbox[state[11]];
state[11] = InvSbox[state[15]];
state[15] = tmp;
}
public function dispose():void{
var i:uint;
var r:Random;
r = new Random();
i = 0;
while (i < key.length) {
key[i] = r.nextByte();
i++;
};
Nr = r.nextByte();
i = 0;
while (i < state.length) {
state[i] = r.nextByte();
i++;
};
i = 0;
while (i < tmp.length) {
tmp[i] = r.nextByte();
i++;
};
key.length = 0;
keyLength = 0;
state.length = 0;
tmp.length = 0;
key = null;
state = null;
tmp = null;
Nr = 0;
Memory.gc();
}
protected function invMixSubColumns():void{
var i:uint;
tmp.length = 0;
tmp[0] = (((XtimeE[state[0]] ^ XtimeB[state[1]]) ^ XtimeD[state[2]]) ^ Xtime9[state[3]]);
tmp[5] = (((Xtime9[state[0]] ^ XtimeE[state[1]]) ^ XtimeB[state[2]]) ^ XtimeD[state[3]]);
tmp[10] = (((XtimeD[state[0]] ^ Xtime9[state[1]]) ^ XtimeE[state[2]]) ^ XtimeB[state[3]]);
tmp[15] = (((XtimeB[state[0]] ^ XtimeD[state[1]]) ^ Xtime9[state[2]]) ^ XtimeE[state[3]]);
tmp[4] = (((XtimeE[state[4]] ^ XtimeB[state[5]]) ^ XtimeD[state[6]]) ^ Xtime9[state[7]]);
tmp[9] = (((Xtime9[state[4]] ^ XtimeE[state[5]]) ^ XtimeB[state[6]]) ^ XtimeD[state[7]]);
tmp[14] = (((XtimeD[state[4]] ^ Xtime9[state[5]]) ^ XtimeE[state[6]]) ^ XtimeB[state[7]]);
tmp[3] = (((XtimeB[state[4]] ^ XtimeD[state[5]]) ^ Xtime9[state[6]]) ^ XtimeE[state[7]]);
tmp[8] = (((XtimeE[state[8]] ^ XtimeB[state[9]]) ^ XtimeD[state[10]]) ^ Xtime9[state[11]]);
tmp[13] = (((Xtime9[state[8]] ^ XtimeE[state[9]]) ^ XtimeB[state[10]]) ^ XtimeD[state[11]]);
tmp[2] = (((XtimeD[state[8]] ^ Xtime9[state[9]]) ^ XtimeE[state[10]]) ^ XtimeB[state[11]]);
tmp[7] = (((XtimeB[state[8]] ^ XtimeD[state[9]]) ^ Xtime9[state[10]]) ^ XtimeE[state[11]]);
tmp[12] = (((XtimeE[state[12]] ^ XtimeB[state[13]]) ^ XtimeD[state[14]]) ^ Xtime9[state[15]]);
tmp[1] = (((Xtime9[state[12]] ^ XtimeE[state[13]]) ^ XtimeB[state[14]]) ^ XtimeD[state[15]]);
tmp[6] = (((XtimeD[state[12]] ^ Xtime9[state[13]]) ^ XtimeE[state[14]]) ^ XtimeB[state[15]]);
tmp[11] = (((XtimeB[state[12]] ^ XtimeD[state[13]]) ^ Xtime9[state[14]]) ^ XtimeE[state[15]]);
i = 0;
while (i < (4 * Nb)) {
state[i] = InvSbox[tmp[i]];
i++;
};
}
private function expandKey():void{
var tmp0:uint;
var tmp1:uint;
var tmp2:uint;
var tmp3:uint;
var tmp4:uint;
var idx:uint;
var Nk:uint;
Nk = (key.length / 4);
Nr = (Nk + 6);
idx = Nk;
while (idx < (Nb * (Nr + 1))) {
tmp0 = key[((4 * idx) - 4)];
tmp1 = key[((4 * idx) - 3)];
tmp2 = key[((4 * idx) - 2)];
tmp3 = key[((4 * idx) - 1)];
if (!(idx % Nk)){
tmp4 = tmp3;
tmp3 = Sbox[tmp0];
tmp0 = (Sbox[tmp1] ^ Rcon[(idx / Nk)]);
tmp1 = Sbox[tmp2];
tmp2 = Sbox[tmp4];
} else {
if ((((Nk > 6)) && (((idx % Nk) == 4)))){
tmp0 = Sbox[tmp0];
tmp1 = Sbox[tmp1];
tmp2 = Sbox[tmp2];
tmp3 = Sbox[tmp3];
};
};
key[((4 * idx) + 0)] = (key[(((4 * idx) - (4 * Nk)) + 0)] ^ tmp0);
key[((4 * idx) + 1)] = (key[(((4 * idx) - (4 * Nk)) + 1)] ^ tmp1);
key[((4 * idx) + 2)] = (key[(((4 * idx) - (4 * Nk)) + 2)] ^ tmp2);
key[((4 * idx) + 3)] = (key[(((4 * idx) - (4 * Nk)) + 3)] ^ tmp3);
idx++;
};
}
protected function addRoundKey(key:ByteArray, offset:uint):void{
var idx:uint;
idx = 0;
while (idx < 16) {
state[idx] = (state[idx] ^ key[(idx + offset)]);
idx++;
};
}
public function encrypt(block:ByteArray, index:uint=0):void{
var round:uint;
state.position = 0;
state.writeBytes(block, index, (Nb * 4));
addRoundKey(key, 0);
round = 1;
while (round < (Nr + 1)) {
if (round < Nr){
mixSubColumns();
} else {
shiftRows();
};
addRoundKey(key, ((round * Nb) * 4));
round++;
};
block.position = index;
block.writeBytes(state);
}
protected function mixSubColumns():void{
tmp.length = 0;
tmp[0] = (((Xtime2Sbox[state[0]] ^ Xtime3Sbox[state[5]]) ^ Sbox[state[10]]) ^ Sbox[state[15]]);
tmp[1] = (((Sbox[state[0]] ^ Xtime2Sbox[state[5]]) ^ Xtime3Sbox[state[10]]) ^ Sbox[state[15]]);
tmp[2] = (((Sbox[state[0]] ^ Sbox[state[5]]) ^ Xtime2Sbox[state[10]]) ^ Xtime3Sbox[state[15]]);
tmp[3] = (((Xtime3Sbox[state[0]] ^ Sbox[state[5]]) ^ Sbox[state[10]]) ^ Xtime2Sbox[state[15]]);
tmp[4] = (((Xtime2Sbox[state[4]] ^ Xtime3Sbox[state[9]]) ^ Sbox[state[14]]) ^ Sbox[state[3]]);
tmp[5] = (((Sbox[state[4]] ^ Xtime2Sbox[state[9]]) ^ Xtime3Sbox[state[14]]) ^ Sbox[state[3]]);
tmp[6] = (((Sbox[state[4]] ^ Sbox[state[9]]) ^ Xtime2Sbox[state[14]]) ^ Xtime3Sbox[state[3]]);
tmp[7] = (((Xtime3Sbox[state[4]] ^ Sbox[state[9]]) ^ Sbox[state[14]]) ^ Xtime2Sbox[state[3]]);
tmp[8] = (((Xtime2Sbox[state[8]] ^ Xtime3Sbox[state[13]]) ^ Sbox[state[2]]) ^ Sbox[state[7]]);
tmp[9] = (((Sbox[state[8]] ^ Xtime2Sbox[state[13]]) ^ Xtime3Sbox[state[2]]) ^ Sbox[state[7]]);
tmp[10] = (((Sbox[state[8]] ^ Sbox[state[13]]) ^ Xtime2Sbox[state[2]]) ^ Xtime3Sbox[state[7]]);
tmp[11] = (((Xtime3Sbox[state[8]] ^ Sbox[state[13]]) ^ Sbox[state[2]]) ^ Xtime2Sbox[state[7]]);
tmp[12] = (((Xtime2Sbox[state[12]] ^ Xtime3Sbox[state[1]]) ^ Sbox[state[6]]) ^ Sbox[state[11]]);
tmp[13] = (((Sbox[state[12]] ^ Xtime2Sbox[state[1]]) ^ Xtime3Sbox[state[6]]) ^ Sbox[state[11]]);
tmp[14] = (((Sbox[state[12]] ^ Sbox[state[1]]) ^ Xtime2Sbox[state[6]]) ^ Xtime3Sbox[state[11]]);
tmp[15] = (((Xtime3Sbox[state[12]] ^ Sbox[state[1]]) ^ Sbox[state[6]]) ^ Xtime2Sbox[state[11]]);
state.position = 0;
state.writeBytes(tmp, 0, (Nb * 4));
}
protected function shiftRows():void{
var tmp:uint;
state[0] = Sbox[state[0]];
state[4] = Sbox[state[4]];
state[8] = Sbox[state[8]];
state[12] = Sbox[state[12]];
tmp = Sbox[state[1]];
state[1] = Sbox[state[5]];
state[5] = Sbox[state[9]];
state[9] = Sbox[state[13]];
state[13] = tmp;
tmp = Sbox[state[2]];
state[2] = Sbox[state[10]];
state[10] = tmp;
tmp = Sbox[state[6]];
state[6] = Sbox[state[14]];
state[14] = tmp;
tmp = Sbox[state[15]];
state[15] = Sbox[state[11]];
state[11] = Sbox[state[7]];
state[7] = Sbox[state[3]];
state[3] = tmp;
}
public function getBlockSize():uint{
return (16);
}
while (i < 0x0100) {
Sbox[i] = _Sbox[i];
InvSbox[i] = _InvSbox[i];
Xtime2Sbox[i] = _Xtime2Sbox[i];
Xtime3Sbox[i] = _Xtime3Sbox[i];
Xtime2[i] = _Xtime2[i];
Xtime9[i] = _Xtime9[i];
XtimeB[i] = _XtimeB[i];
XtimeD[i] = _XtimeD[i];
XtimeE[i] = _XtimeE[i];
i++;
};
i = 0;
while (i < _Rcon.length) {
Rcon[i] = _Rcon[i];
i++;
};
}
}//package com.hurlant.crypto.symmetric
Section 29
//BlowFishKey (com.hurlant.crypto.symmetric.BlowFishKey)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.util.*;
public class BlowFishKey implements ISymmetricKey {
private var S3:Array;
private var S2:Array;
private var P:Array;
private var key:ByteArray;// = null
private var S0:Array;
private var S1:Array;
private static const KP:Array = [608135816, 2242054355, 320440878, 57701188, 2752067618, 698298832, 137296536, 3964562569, 1160258022, 953160567, 3193202383, 887688300, 3232508343, 3380367581, 1065670069, 3041331479, 2450970073, 2306472731];
private static const KS0:Array = [3509652390, 2564797868, 805139163, 3491422135, 3101798381, 1780907670, 3128725573, 4046225305, 614570311, 3012652279, 134345442, 2240740374, 1667834072, 1901547113, 2757295779, 4103290238, 227898511, 1921955416, 1904987480, 2182433518, 2069144605, 3260701109, 2620446009, 720527379, 3318853667, 677414384, 3393288472, 3101374703, 2390351024, 1614419982, 1822297739, 2954791486, 3608508353, 3174124327, 2024746970, 1432378464, 3864339955, 2857741204, 1464375394, 1676153920, 1439316330, 715854006, 3033291828, 289532110, 2706671279, 2087905683, 3018724369, 1668267050, 732546397, 1947742710, 3462151702, 2609353502, 2950085171, 1814351708, 2050118529, 680887927, 999245976, 1800124847, 3300911131, 1713906067, 1641548236, 4213287313, 1216130144, 1575780402, 4018429277, 3917837745, 3693486850, 3949271944, 596196993, 3549867205, 258830323, 2213823033, 772490370, 2760122372, 1774776394, 2652871518, 566650946, 4142492826, 1728879713, 2882767088, 1783734482, 3629395816, 2517608232, 2874225571, 1861159788, 326777828, 3124490320, 2130389656, 2716951837, 967770486, 1724537150, 2185432712, 2364442137, 1164943284, 2105845187, 998989502, 3765401048, 2244026483, 1075463327, 1455516326, 1322494562, 910128902, 469688178, 1117454909, 936433444, 3490320968, 3675253459, 1240580251, 122909385, 2157517691, 634681816, 4142456567, 3825094682, 3061402683, 2540495037, 79693498, 3249098678, 1084186820, 1583128258, 426386531, 1761308591, 1047286709, 322548459, 995290223, 1845252383, 2603652396, 3431023940, 2942221577, 3202600964, 3727903485, 1712269319, 422464435, 3234572375, 1170764815, 3523960633, 3117677531, 1434042557, 442511882, 3600875718, 1076654713, 1738483198, 4213154764, 2393238008, 3677496056, 1014306527, 4251020053, 793779912, 2902807211, 842905082, 4246964064, 1395751752, 1040244610, 2656851899, 3396308128, 445077038, 3742853595, 3577915638, 679411651, 2892444358, 2354009459, 1767581616, 3150600392, 3791627101, 3102740896, 284835224, 4246832056, 1258075500, 768725851, 2589189241, 3069724005, 3532540348, 1274779536, 3789419226, 2764799539, 1660621633, 3471099624, 4011903706, 913787905, 3497959166, 737222580, 2514213453, 2928710040, 3937242737, 1804850592, 3499020752, 2949064160, 2386320175, 2390070455, 2415321851, 4061277028, 2290661394, 2416832540, 1336762016, 1754252060, 3520065937, 3014181293, 791618072, 3188594551, 3933548030, 2332172193, 3852520463, 3043980520, 413987798, 3465142937, 3030929376, 4245938359, 2093235073, 3534596313, 375366246, 2157278981, 2479649556, 555357303, 3870105701, 2008414854, 3344188149, 4221384143, 3956125452, 2067696032, 3594591187, 2921233993, 2428461, 544322398, 577241275, 1471733935, 610547355, 4027169054, 1432588573, 1507829418, 2025931657, 3646575487, 545086370, 48609733, 2200306550, 1653985193, 298326376, 1316178497, 3007786442, 2064951626, 458293330, 2589141269, 3591329599, 3164325604, 727753846, 2179363840, 146436021, 1461446943, 4069977195, 705550613, 3059967265, 3887724982, 4281599278, 3313849956, 1404054877, 2845806497, 146425753, 1854211946];
private static const KS1:Array = [1266315497, 3048417604, 3681880366, 3289982499, 2909710000, 1235738493, 2632868024, 2414719590, 3970600049, 1771706367, 1449415276, 3266420449, 422970021, 1963543593, 2690192192, 3826793022, 1062508698, 1531092325, 1804592342, 2583117782, 2714934279, 4024971509, 1294809318, 4028980673, 1289560198, 2221992742, 1669523910, 35572830, 157838143, 1052438473, 1016535060, 1802137761, 1753167236, 1386275462, 3080475397, 2857371447, 1040679964, 2145300060, 2390574316, 1461121720, 2956646967, 4031777805, 4028374788, 33600511, 2920084762, 1018524850, 629373528, 3691585981, 3515945977, 2091462646, 2486323059, 586499841, 988145025, 935516892, 3367335476, 2599673255, 2839830854, 265290510, 3972581182, 2759138881, 3795373465, 1005194799, 847297441, 406762289, 1314163512, 1332590856, 1866599683, 4127851711, 750260880, 613907577, 1450815602, 3165620655, 3734664991, 3650291728, 3012275730, 3704569646, 1427272223, 778793252, 1343938022, 2676280711, 2052605720, 1946737175, 3164576444, 3914038668, 3967478842, 3682934266, 1661551462, 3294938066, 4011595847, 840292616, 3712170807, 616741398, 312560963, 711312465, 1351876610, 322626781, 1910503582, 271666773, 2175563734, 1594956187, 70604529, 3617834859, 1007753275, 1495573769, 4069517037, 2549218298, 2663038764, 504708206, 2263041392, 3941167025, 2249088522, 1514023603, 1998579484, 1312622330, 694541497, 2582060303, 2151582166, 1382467621, 776784248, 2618340202, 3323268794, 2497899128, 2784771155, 503983604, 4076293799, 907881277, 423175695, 432175456, 1378068232, 4145222326, 3954048622, 3938656102, 3820766613, 2793130115, 2977904593, 26017576, 3274890735, 3194772133, 1700274565, 1756076034, 4006520079, 3677328699, 720338349, 1533947780, 354530856, 688349552, 3973924725, 1637815568, 332179504, 3949051286, 53804574, 2852348879, 3044236432, 1282449977, 3583942155, 3416972820, 4006381244, 1617046695, 2628476075, 3002303598, 1686838959, 431878346, 2686675385, 1700445008, 1080580658, 1009431731, 832498133, 3223435511, 2605976345, 2271191193, 2516031870, 1648197032, 4164389018, 2548247927, 300782431, 375919233, 238389289, 3353747414, 2531188641, 2019080857, 1475708069, 455242339, 2609103871, 448939670, 3451063019, 1395535956, 2413381860, 1841049896, 1491858159, 885456874, 4264095073, 4001119347, 1565136089, 3898914787, 1108368660, 540939232, 1173283510, 2745871338, 3681308437, 4207628240, 3343053890, 4016749493, 1699691293, 1103962373, 3625875870, 2256883143, 3830138730, 1031889488, 3479347698, 1535977030, 4236805024, 3251091107, 2132092099, 1774941330, 1199868427, 1452454533, 157007616, 2904115357, 342012276, 595725824, 1480756522, 206960106, 497939518, 591360097, 863170706, 2375253569, 3596610801, 1814182875, 2094937945, 3421402208, 1082520231, 3463918190, 2785509508, 435703966, 3908032597, 1641649973, 2842273706, 3305899714, 1510255612, 2148256476, 2655287854, 3276092548, 4258621189, 236887753, 3681803219, 274041037, 1734335097, 3815195456, 3317970021, 1899903192, 1026095262, 4050517792, 356393447, 2410691914, 3873677099, 3682840055];
private static const KS3:Array = [976866871, 3556439503, 2881648439, 1522871579, 1555064734, 1336096578, 3548522304, 2579274686, 3574697629, 3205460757, 3593280638, 3338716283, 3079412587, 564236357, 2993598910, 1781952180, 1464380207, 3163844217, 3332601554, 1699332808, 1393555694, 1183702653, 3581086237, 1288719814, 691649499, 2847557200, 2895455976, 3193889540, 2717570544, 1781354906, 1676643554, 2592534050, 3230253752, 1126444790, 2770207658, 2633158820, 2210423226, 2615765581, 2414155088, 3127139286, 673620729, 2805611233, 1269405062, 4015350505, 3341807571, 4149409754, 1057255273, 2012875353, 2162469141, 2276492801, 2601117357, 993977747, 3918593370, 2654263191, 753973209, 36408145, 2530585658, 25011837, 3520020182, 2088578344, 530523599, 2918365339, 1524020338, 1518925132, 3760827505, 3759777254, 1202760957, 3985898139, 3906192525, 674977740, 4174734889, 2031300136, 2019492241, 3983892565, 4153806404, 3822280332, 352677332, 2297720250, 60907813, 90501309, 3286998549, 1016092578, 2535922412, 2839152426, 457141659, 509813237, 4120667899, 652014361, 1966332200, 2975202805, 55981186, 2327461051, 676427537, 3255491064, 2882294119, 3433927263, 1307055953, 942726286, 933058658, 2468411793, 3933900994, 4215176142, 1361170020, 2001714738, 2830558078, 3274259782, 1222529897, 1679025792, 2729314320, 3714953764, 1770335741, 151462246, 3013232138, 1682292957, 1483529935, 471910574, 1539241949, 458788160, 3436315007, 1807016891, 3718408830, 978976581, 1043663428, 3165965781, 1927990952, 4200891579, 2372276910, 3208408903, 3533431907, 1412390302, 2931980059, 4132332400, 1947078029, 3881505623, 4168226417, 2941484381, 1077988104, 1320477388, 886195818, 18198404, 3786409000, 2509781533, 112762804, 3463356488, 1866414978, 891333506, 18488651, 661792760, 1628790961, 3885187036, 3141171499, 876946877, 2693282273, 1372485963, 791857591, 2686433993, 3759982718, 3167212022, 3472953795, 2716379847, 445679433, 3561995674, 3504004811, 3574258232, 54117162, 3331405415, 2381918588, 3769707343, 4154350007, 1140177722, 4074052095, 668550556, 3214352940, 367459370, 261225585, 2610173221, 4209349473, 3468074219, 3265815641, 314222801, 3066103646, 3808782860, 282218597, 3406013506, 3773591054, 379116347, 1285071038, 846784868, 2669647154, 3771962079, 3550491691, 2305946142, 453669953, 1268987020, 3317592352, 3279303384, 3744833421, 2610507566, 3859509063, 266596637, 3847019092, 517658769, 3462560207, 3443424879, 370717030, 4247526661, 2224018117, 4143653529, 4112773975, 2788324899, 2477274417, 1456262402, 2901442914, 1517677493, 1846949527, 2295493580, 3734397586, 2176403920, 1280348187, 1908823572, 3871786941, 846861322, 1172426758, 3287448474, 3383383037, 1655181056, 3139813346, 901632758, 1897031941, 2986607138, 3066810236, 3447102507, 1393639104, 373351379, 950779232, 625454576, 3124240540, 4148612726, 2007998917, 544563296, 2244738638, 2330496472, 2058025392, 1291430526, 424198748, 50039436, 29584100, 3605783033, 2429876329, 2791104160, 1057563949, 3255363231, 3075367218, 3463963227, 1469046755, 985887462];
private static const ROUNDS:uint = 16;
private static const KS2:Array = [3913112168, 2491498743, 4132185628, 2489919796, 1091903735, 1979897079, 3170134830, 3567386728, 3557303409, 857797738, 1136121015, 1342202287, 507115054, 2535736646, 337727348, 3213592640, 1301675037, 2528481711, 1895095763, 1721773893, 3216771564, 62756741, 2142006736, 835421444, 2531993523, 1442658625, 3659876326, 2882144922, 676362277, 1392781812, 170690266, 3921047035, 1759253602, 3611846912, 1745797284, 664899054, 1329594018, 3901205900, 3045908486, 2062866102, 2865634940, 3543621612, 3464012697, 1080764994, 553557557, 3656615353, 3996768171, 991055499, 499776247, 1265440854, 648242737, 3940784050, 980351604, 3713745714, 1749149687, 3396870395, 4211799374, 3640570775, 1161844396, 3125318951, 1431517754, 545492359, 4268468663, 3499529547, 1437099964, 2702547544, 3433638243, 2581715763, 2787789398, 1060185593, 1593081372, 2418618748, 4260947970, 69676912, 2159744348, 86519011, 2512459080, 3838209314, 1220612927, 3339683548, 133810670, 1090789135, 1078426020, 1569222167, 845107691, 3583754449, 4072456591, 1091646820, 628848692, 1613405280, 3757631651, 526609435, 236106946, 48312990, 2942717905, 3402727701, 1797494240, 859738849, 992217954, 4005476642, 2243076622, 3870952857, 3732016268, 765654824, 3490871365, 2511836413, 1685915746, 3888969200, 1414112111, 2273134842, 3281911079, 4080962846, 172450625, 2569994100, 980381355, 4109958455, 2819808352, 2716589560, 2568741196, 3681446669, 3329971472, 1835478071, 660984891, 3704678404, 4045999559, 3422617507, 3040415634, 1762651403, 1719377915, 3470491036, 2693910283, 3642056355, 3138596744, 1364962596, 2073328063, 1983633131, 926494387, 3423689081, 2150032023, 4096667949, 1749200295, 3328846651, 309677260, 2016342300, 1779581495, 3079819751, 111262694, 1274766160, 443224088, 298511866, 1025883608, 3806446537, 1145181785, 168956806, 3641502830, 3584813610, 1689216846, 3666258015, 3200248200, 1692713982, 2646376535, 4042768518, 1618508792, 1610833997, 3523052358, 4130873264, 2001055236, 3610705100, 2202168115, 4028541809, 2961195399, 1006657119, 2006996926, 3186142756, 1430667929, 3210227297, 1314452623, 4074634658, 4101304120, 2273951170, 1399257539, 3367210612, 3027628629, 1190975929, 2062231137, 2333990788, 2221543033, 2438960610, 1181637006, 548689776, 2362791313, 3372408396, 3104550113, 3145860560, 296247880, 1970579870, 3078560182, 3769228297, 1714227617, 3291629107, 3898220290, 166772364, 1251581989, 493813264, 448347421, 195405023, 2709975567, 677966185, 3703036547, 1463355134, 2715995803, 1338867538, 1343315457, 2802222074, 2684532164, 233230375, 2599980071, 2000651841, 3277868038, 1638401717, 4028070440, 3237316320, 6314154, 819756386, 300326615, 590932579, 1405279636, 3267499572, 3150704214, 2428286686, 3959192993, 3461946742, 1862657033, 1266418056, 963775037, 2089974820, 2263052895, 1917689273, 448879540, 3550394620, 3981727096, 150775221, 3627908307, 1303187396, 508620638, 2975983352, 2726630617, 1817252668, 1876281319, 1457606340, 908771278, 3720792119, 3617206836, 2455994898, 1729034894, 1080033504];
private static const BLOCK_SIZE:uint = 8;
private static const P_SZ:uint = (ROUNDS + 2);
private static const SBOX_SK:uint = 0x0100;
public function BlowFishKey(key:ByteArray){
key = null;
super();
this.key = key;
setKey(key);
}
private function F(x:uint):uint{
return ((((S0[(x >>> 24)] + S1[((x >>> 16) & 0xFF)]) ^ S2[((x >>> 8) & 0xFF)]) + S3[(x & 0xFF)]));
}
private function BytesTo32bits(b:ByteArray, i:uint):uint{
return ((((((b[i] & 0xFF) << 24) | ((b[(i + 1)] & 0xFF) << 16)) | ((b[(i + 2)] & 0xFF) << 8)) | (b[(i + 3)] & 0xFF)));
}
public function decrypt(block:ByteArray, index:uint=0):void{
decryptBlock(block, index, block, index);
}
private function decryptBlock(src:ByteArray, srcIndex:uint, dst:ByteArray, dstIndex:uint):void{
var xl:uint;
var xr:uint;
var i:uint;
xl = BytesTo32bits(src, srcIndex);
xr = BytesTo32bits(src, (srcIndex + 4));
xl = (xl ^ P[(ROUNDS + 1)]);
i = ROUNDS;
while (i > 0) {
xr = (xr ^ (F(xl) ^ P[i]));
xl = (xl ^ (F(xr) ^ P[(i - 1)]));
i = (i - 2);
};
xr = (xr ^ P[0]);
Bits32ToBytes(xr, dst, dstIndex);
Bits32ToBytes(xl, dst, (dstIndex + 4));
}
private function setKey(key:ByteArray):void{
var keyLength:uint;
var keyIndex:uint;
var i:uint;
var data:uint;
var j:uint;
S0 = KS0.concat();
S1 = KS1.concat();
S2 = KS2.concat();
S3 = KS3.concat();
P = KP.concat();
keyLength = key.length;
keyIndex = 0;
i = 0;
while (i < P_SZ) {
data = 0;
j = 0;
while (j < 4) {
var _temp1 = keyIndex;
keyIndex = (keyIndex + 1);
data = ((data << 8) | (key[_temp1] & 0xFF));
if (keyIndex >= keyLength){
keyIndex = 0;
};
j++;
};
P[i] = (P[i] ^ data);
i++;
};
processTable(0, 0, P);
processTable(P[(P_SZ - 2)], P[(P_SZ - 1)], S0);
processTable(S0[(SBOX_SK - 2)], S0[(SBOX_SK - 1)], S1);
processTable(S1[(SBOX_SK - 2)], S1[(SBOX_SK - 1)], S2);
processTable(S2[(SBOX_SK - 2)], S2[(SBOX_SK - 1)], S3);
}
public function dispose():void{
var i:uint;
i = 0;
i = 0;
while (i < S0.length) {
S0[i] = 0;
i++;
};
i = 0;
while (i < S1.length) {
S1[i] = 0;
i++;
};
i = 0;
while (i < S2.length) {
S2[i] = 0;
i++;
};
i = 0;
while (i < S3.length) {
S3[i] = 0;
i++;
};
i = 0;
while (i < P.length) {
P[i] = 0;
i++;
};
S0 = null;
S1 = null;
S2 = null;
S3 = null;
P = null;
i = 0;
while (i < key.length) {
key[i] = 0;
i++;
};
key.length = 0;
key = null;
Memory.gc();
}
private function encryptBlock(src:ByteArray, srcIndex:uint, dst:ByteArray, dstIndex:uint):void{
var xl:uint;
var xr:uint;
var i:uint;
xl = BytesTo32bits(src, srcIndex);
xr = BytesTo32bits(src, (srcIndex + 4));
xl = (xl ^ P[0]);
i = 1;
while (i < ROUNDS) {
xr = (xr ^ (F(xl) ^ P[i]));
xl = (xl ^ (F(xr) ^ P[(i + 1)]));
i = (i + 2);
};
xr = (xr ^ P[(ROUNDS + 1)]);
Bits32ToBytes(xr, dst, dstIndex);
Bits32ToBytes(xl, dst, (dstIndex + 4));
}
public function encrypt(block:ByteArray, index:uint=0):void{
encryptBlock(block, index, block, index);
}
private function Bits32ToBytes(i:uint, b:ByteArray, offset:uint):void{
b[(offset + 3)] = i;
b[(offset + 2)] = (i >> 8);
b[(offset + 1)] = (i >> 16);
b[offset] = (i >> 24);
}
private function processTable(xl:uint, xr:uint, table:Array):void{
var size:uint;
var s:uint;
var i:uint;
size = table.length;
s = 0;
while (s < size) {
xl = (xl ^ P[0]);
i = 1;
while (i < ROUNDS) {
xr = (xr ^ (F(xl) ^ P[i]));
xl = (xl ^ (F(xr) ^ P[(i + 1)]));
i = (i + 2);
};
xr = (xr ^ P[(ROUNDS + 1)]);
table[s] = xr;
table[(s + 1)] = xl;
xr = xl;
xl = table[s];
s = (s + 2);
};
}
public function toString():String{
return ("blowfish");
}
public function getBlockSize():uint{
return (BLOCK_SIZE);
}
}
}//package com.hurlant.crypto.symmetric
Section 30
//CBCMode (com.hurlant.crypto.symmetric.CBCMode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public class CBCMode extends IVMode implements IMode {
public function CBCMode(key:ISymmetricKey, padding:IPad=null){
super(key, padding);
}
public function toString():String{
return ((key.toString() + "-cbc"));
}
public function decrypt(src:ByteArray):void{
var vector:ByteArray;
var tmp:ByteArray;
var i:uint;
var j:uint;
vector = getIV4d();
tmp = new ByteArray();
i = 0;
while (i < src.length) {
tmp.position = 0;
tmp.writeBytes(src, i, blockSize);
key.decrypt(src, i);
j = 0;
while (j < blockSize) {
src[(i + j)] = (src[(i + j)] ^ vector[j]);
j++;
};
vector.position = 0;
vector.writeBytes(tmp, 0, blockSize);
i = (i + blockSize);
};
padding.unpad(src);
}
public function encrypt(src:ByteArray):void{
var vector:ByteArray;
var i:uint;
var j:uint;
padding.pad(src);
vector = getIV4e();
i = 0;
while (i < src.length) {
j = 0;
while (j < blockSize) {
src[(i + j)] = (src[(i + j)] ^ vector[j]);
j++;
};
key.encrypt(src, i);
vector.position = 0;
vector.writeBytes(src, i, blockSize);
i = (i + blockSize);
};
}
}
}//package com.hurlant.crypto.symmetric
Section 31
//CFB8Mode (com.hurlant.crypto.symmetric.CFB8Mode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public class CFB8Mode extends IVMode implements IMode {
public function CFB8Mode(key:ISymmetricKey, padding:IPad=null){
super(key, null);
}
public function toString():String{
return ((key.toString() + "-cfb8"));
}
public function decrypt(src:ByteArray):void{
var vector:ByteArray;
var tmp:ByteArray;
var i:uint;
var c:uint;
var j:uint;
vector = getIV4d();
tmp = new ByteArray();
i = 0;
while (i < src.length) {
c = src[i];
tmp.position = 0;
tmp.writeBytes(vector);
key.encrypt(vector);
src[i] = (src[i] ^ vector[0]);
j = 0;
while (j < (blockSize - 1)) {
vector[j] = tmp[(j + 1)];
j++;
};
vector[(blockSize - 1)] = c;
i++;
};
}
public function encrypt(src:ByteArray):void{
var vector:ByteArray;
var tmp:ByteArray;
var i:uint;
var j:uint;
vector = getIV4e();
tmp = new ByteArray();
i = 0;
while (i < src.length) {
tmp.position = 0;
tmp.writeBytes(vector);
key.encrypt(vector);
src[i] = (src[i] ^ vector[0]);
j = 0;
while (j < (blockSize - 1)) {
vector[j] = tmp[(j + 1)];
j++;
};
vector[(blockSize - 1)] = src[i];
i++;
};
}
}
}//package com.hurlant.crypto.symmetric
Section 32
//CFBMode (com.hurlant.crypto.symmetric.CFBMode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public class CFBMode extends IVMode implements IMode {
public function CFBMode(key:ISymmetricKey, padding:IPad=null){
super(key, null);
}
public function toString():String{
return ((key.toString() + "-cfb"));
}
public function decrypt(src:ByteArray):void{
var l:uint;
var vector:ByteArray;
var tmp:ByteArray;
var i:uint;
var chunk:uint;
var j:uint;
l = src.length;
vector = getIV4d();
tmp = new ByteArray();
i = 0;
while (i < src.length) {
key.encrypt(vector);
chunk = (((i + blockSize))<l) ? blockSize : (l - i);
tmp.position = 0;
tmp.writeBytes(src, i, chunk);
j = 0;
while (j < chunk) {
src[(i + j)] = (src[(i + j)] ^ vector[j]);
j++;
};
vector.position = 0;
vector.writeBytes(tmp);
i = (i + blockSize);
};
}
public function encrypt(src:ByteArray):void{
var l:uint;
var vector:ByteArray;
var i:uint;
var chunk:uint;
var j:uint;
l = src.length;
vector = getIV4e();
i = 0;
while (i < src.length) {
key.encrypt(vector);
chunk = (((i + blockSize))<l) ? blockSize : (l - i);
j = 0;
while (j < chunk) {
src[(i + j)] = (src[(i + j)] ^ vector[j]);
j++;
};
vector.position = 0;
vector.writeBytes(src, i, chunk);
i = (i + blockSize);
};
}
}
}//package com.hurlant.crypto.symmetric
Section 33
//CTRMode (com.hurlant.crypto.symmetric.CTRMode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public class CTRMode extends IVMode implements IMode {
public function CTRMode(key:ISymmetricKey, padding:IPad=null){
super(key, padding);
}
public function toString():String{
return ((key.toString() + "-ctr"));
}
private function core(src:ByteArray, iv:ByteArray):void{
var X:ByteArray;
var Xenc:ByteArray;
var i:uint;
var j:uint;
X = new ByteArray();
Xenc = new ByteArray();
X.writeBytes(iv);
i = 0;
while (i < src.length) {
Xenc.position = 0;
Xenc.writeBytes(X);
key.encrypt(Xenc);
j = 0;
while (j < blockSize) {
src[(i + j)] = (src[(i + j)] ^ Xenc[j]);
j++;
};
j = (blockSize - 1);
while (j >= 0) {
var _local7 = X;
var _local8 = j;
var _local9 = (_local7[_local8] + 1);
_local7[_local8] = _local9;
if (X[j] != 0){
break;
};
j--;
};
i = (i + blockSize);
};
}
public function decrypt(src:ByteArray):void{
var vector:ByteArray;
vector = getIV4d();
core(src, vector);
padding.unpad(src);
}
public function encrypt(src:ByteArray):void{
var vector:ByteArray;
padding.pad(src);
vector = getIV4e();
core(src, vector);
}
}
}//package com.hurlant.crypto.symmetric
Section 34
//DESKey (com.hurlant.crypto.symmetric.DESKey)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.util.*;
public class DESKey implements ISymmetricKey {
protected var encKey:Array;
protected var key:ByteArray;
protected var decKey:Array;
private static const SP8:Array = [268439616, 0x1000, 262144, 268701760, 268435456, 268439616, 64, 268435456, 262208, 268697600, 268701760, 266240, 268701696, 266304, 0x1000, 64, 268697600, 268435520, 268439552, 4160, 266240, 262208, 268697664, 268701696, 4160, 0, 0, 268697664, 268435520, 268439552, 266304, 262144, 266304, 262144, 268701696, 0x1000, 64, 268697664, 0x1000, 266304, 268439552, 64, 268435520, 268697600, 268697664, 268435456, 262144, 268439616, 0, 268701760, 262208, 268435520, 268697600, 268439552, 268439616, 0, 268701760, 266240, 266240, 4160, 4160, 262208, 268435456, 268701696];
private static const bytebit:Array = [128, 64, 32, 16, 8, 4, 2, 1];
private static const bigbyte:Array = [0x800000, 0x400000, 0x200000, 0x100000, 524288, 262144, 131072, 65536, 0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100, 128, 64, 32, 16, 8, 4, 2, 1];
private static const pc1:Array = [56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3];
private static const pc2:Array = [13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31];
private static const Df_Key:Array = [1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16, 137, 171, 205, 239, 1, 35, 69, 103];
private static const totrot:Array = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
private static const SP1:Array = [16843776, 0, 65536, 16843780, 16842756, 66564, 4, 65536, 0x0400, 16843776, 16843780, 0x0400, 16778244, 16842756, 16777216, 4, 0x0404, 16778240, 16778240, 66560, 66560, 16842752, 16842752, 16778244, 65540, 16777220, 16777220, 65540, 0, 0x0404, 66564, 16777216, 65536, 16843780, 4, 16842752, 16843776, 16777216, 16777216, 0x0400, 16842756, 65536, 66560, 16777220, 0x0400, 4, 16778244, 66564, 16843780, 65540, 16842752, 16778244, 16777220, 0x0404, 66564, 16843776, 0x0404, 16778240, 16778240, 0, 65540, 66560, 0, 16842756];
private static const SP2:Array = [2148565024, 2147516416, 0x8000, 1081376, 0x100000, 32, 2148532256, 2147516448, 2147483680, 2148565024, 2148564992, 2147483648, 2147516416, 0x100000, 32, 2148532256, 0x108000, 0x100020, 2147516448, 0, 2147483648, 0x8000, 1081376, 2148532224, 0x100020, 2147483680, 0, 0x108000, 32800, 2148564992, 2148532224, 32800, 0, 1081376, 2148532256, 0x100000, 2147516448, 2148532224, 2148564992, 0x8000, 2148532224, 2147516416, 32, 2148565024, 1081376, 32, 0x8000, 2147483648, 32800, 2148564992, 0x100000, 2147483680, 0x100020, 2147516448, 2147483680, 0x100020, 0x108000, 0, 2147516416, 32800, 2147483648, 2148532256, 2148565024, 0x108000];
private static const SP3:Array = [520, 134349312, 0, 134348808, 134218240, 0, 131592, 134218240, 131080, 134217736, 134217736, 131072, 134349320, 131080, 134348800, 520, 134217728, 8, 134349312, 0x0200, 131584, 134348800, 134348808, 131592, 134218248, 131584, 131072, 134218248, 8, 134349320, 0x0200, 134217728, 134349312, 134217728, 131080, 520, 131072, 134349312, 134218240, 0, 0x0200, 131080, 134349320, 134218240, 134217736, 0x0200, 0, 134348808, 134218248, 131072, 134217728, 134349320, 8, 131592, 131584, 134217736, 134348800, 134218248, 520, 134348800, 131592, 8, 134348808, 131584];
private static const SP4:Array = [8396801, 8321, 8321, 128, 8396928, 0x800081, 0x800001, 8193, 0, 0x802000, 0x802000, 8396929, 129, 0, 0x800080, 0x800001, 1, 0x2000, 0x800000, 8396801, 128, 0x800000, 8193, 8320, 0x800081, 1, 8320, 0x800080, 0x2000, 8396928, 8396929, 129, 0x800080, 0x800001, 0x802000, 8396929, 129, 0, 0, 0x802000, 8320, 0x800080, 0x800081, 1, 8396801, 8321, 8321, 128, 8396929, 129, 1, 0x2000, 0x800001, 8193, 8396928, 0x800081, 8193, 8320, 0x800000, 8396801, 128, 0x800000, 0x2000, 8396928];
private static const SP5:Array = [0x0100, 34078976, 34078720, 1107296512, 524288, 0x0100, 1073741824, 34078720, 1074266368, 524288, 33554688, 1074266368, 1107296512, 1107820544, 524544, 1073741824, 33554432, 1074266112, 1074266112, 0, 1073742080, 1107820800, 1107820800, 33554688, 1107820544, 1073742080, 0, 1107296256, 34078976, 33554432, 1107296256, 524544, 524288, 1107296512, 0x0100, 33554432, 1073741824, 34078720, 1107296512, 1074266368, 33554688, 1073741824, 1107820544, 34078976, 1074266368, 0x0100, 33554432, 1107820544, 1107820800, 524544, 1107296256, 1107820800, 34078720, 0, 1074266112, 1107296256, 524544, 33554688, 1073742080, 524288, 0, 1074266112, 34078976, 1073742080];
private static const SP6:Array = [536870928, 541065216, 0x4000, 541081616, 541065216, 16, 541081616, 0x400000, 536887296, 4210704, 0x400000, 536870928, 0x400010, 536887296, 536870912, 16400, 0, 0x400010, 536887312, 0x4000, 0x404000, 536887312, 16, 541065232, 541065232, 0, 4210704, 541081600, 16400, 0x404000, 541081600, 536870912, 536887296, 16, 541065232, 0x404000, 541081616, 0x400000, 16400, 536870928, 0x400000, 536887296, 536870912, 16400, 536870928, 541081616, 0x404000, 541065216, 4210704, 541081600, 0, 541065232, 16, 0x4000, 541065216, 4210704, 0x4000, 0x400010, 536887312, 0, 541081600, 536870912, 0x400010, 536887312];
private static const SP7:Array = [0x200000, 69206018, 67110914, 0, 0x0800, 67110914, 2099202, 69208064, 69208066, 0x200000, 0, 67108866, 2, 67108864, 69206018, 2050, 67110912, 2099202, 0x200002, 67110912, 67108866, 69206016, 69208064, 0x200002, 69206016, 0x0800, 2050, 69208066, 0x200800, 2, 67108864, 0x200800, 67108864, 0x200800, 0x200000, 67110914, 67110914, 69206018, 69206018, 2, 0x200002, 67108864, 67110912, 0x200000, 69208064, 2050, 2099202, 69208064, 2050, 67108866, 69208066, 69206016, 0x200800, 0, 2, 69208066, 0, 2099202, 69206016, 0x0800, 67108866, 67110912, 0x0800, 0x200002];
public function DESKey(key:ByteArray){
super();
this.key = key;
this.encKey = generateWorkingKey(true, key, 0);
this.decKey = generateWorkingKey(false, key, 0);
}
protected function generateWorkingKey(encrypting:Boolean, key:ByteArray, off:uint):Array{
var newKey:Array;
var pc1m:ByteArray;
var pcr:ByteArray;
var l:uint;
var j:uint;
var i:uint;
var m:uint;
var n:uint;
var i1:uint;
var i2:uint;
newKey = [];
pc1m = new ByteArray();
pcr = new ByteArray();
j = 0;
while (j < 56) {
l = pc1[j];
pc1m[j] = !(((key[(off + (l >>> 3))] & bytebit[(l & 7)]) == 0));
j++;
};
i = 0;
while (i < 16) {
if (encrypting){
m = (i << 1);
} else {
m = ((15 - i) << 1);
};
n = (m + 1);
newKey[m] = (newKey[n] = 0);
j = 0;
while (j < 28) {
l = (j + totrot[i]);
if (l < 28){
pcr[j] = pc1m[l];
} else {
pcr[j] = pc1m[(l - 28)];
};
j++;
};
j = 28;
while (j < 56) {
l = (j + totrot[i]);
if (l < 56){
pcr[j] = pc1m[l];
} else {
pcr[j] = pc1m[(l - 28)];
};
j++;
};
j = 0;
while (j < 24) {
if (pcr[pc2[j]]){
newKey[m] = (newKey[m] | bigbyte[j]);
};
if (pcr[pc2[(j + 24)]]){
newKey[n] = (newKey[n] | bigbyte[j]);
};
j++;
};
i++;
};
i = 0;
while (i != 32) {
i1 = newKey[i];
i2 = newKey[(i + 1)];
newKey[i] = (((((i1 & 0xFC0000) << 6) | ((i1 & 4032) << 10)) | ((i2 & 0xFC0000) >>> 10)) | ((i2 & 4032) >>> 6));
newKey[(i + 1)] = (((((i1 & 258048) << 12) | ((i1 & 63) << 16)) | ((i2 & 258048) >>> 4)) | (i2 & 63));
i = (i + 2);
};
return (newKey);
}
public function encrypt(block:ByteArray, index:uint=0):void{
desFunc(encKey, block, index, block, index);
}
public function decrypt(block:ByteArray, index:uint=0):void{
desFunc(decKey, block, index, block, index);
}
public function dispose():void{
var i:uint;
i = 0;
i = 0;
while (i < encKey.length) {
encKey[i] = 0;
i++;
};
i = 0;
while (i < decKey.length) {
decKey[i] = 0;
i++;
};
encKey = null;
decKey = null;
i = 0;
while (i < key.length) {
key[i] = 0;
i++;
};
key.length = 0;
key = null;
Memory.gc();
}
protected function desFunc(wKey:Array, inp:ByteArray, inOff:uint, out:ByteArray, outOff:uint):void{
var work:uint;
var right:uint;
var left:uint;
var round:uint;
var fval:uint;
left = ((inp[(inOff + 0)] & 0xFF) << 24);
left = (left | ((inp[(inOff + 1)] & 0xFF) << 16));
left = (left | ((inp[(inOff + 2)] & 0xFF) << 8));
left = (left | (inp[(inOff + 3)] & 0xFF));
right = ((inp[(inOff + 4)] & 0xFF) << 24);
right = (right | ((inp[(inOff + 5)] & 0xFF) << 16));
right = (right | ((inp[(inOff + 6)] & 0xFF) << 8));
right = (right | (inp[(inOff + 7)] & 0xFF));
work = (((left >>> 4) ^ right) & 252645135);
right = (right ^ work);
left = (left ^ (work << 4));
work = (((left >>> 16) ^ right) & 0xFFFF);
right = (right ^ work);
left = (left ^ (work << 16));
work = (((right >>> 2) ^ left) & 858993459);
left = (left ^ work);
right = (right ^ (work << 2));
work = (((right >>> 8) ^ left) & 0xFF00FF);
left = (left ^ work);
right = (right ^ (work << 8));
right = (((right << 1) | ((right >>> 31) & 1)) & 4294967295);
work = ((left ^ right) & 2863311530);
left = (left ^ work);
right = (right ^ work);
left = (((left << 1) | ((left >>> 31) & 1)) & 4294967295);
round = 0;
while (round < 8) {
work = ((right << 28) | (right >>> 4));
work = (work ^ wKey[((round * 4) + 0)]);
fval = SP7[(work & 63)];
fval = (fval | SP5[((work >>> 8) & 63)]);
fval = (fval | SP3[((work >>> 16) & 63)]);
fval = (fval | SP1[((work >>> 24) & 63)]);
work = (right ^ wKey[((round * 4) + 1)]);
fval = (fval | SP8[(work & 63)]);
fval = (fval | SP6[((work >>> 8) & 63)]);
fval = (fval | SP4[((work >>> 16) & 63)]);
fval = (fval | SP2[((work >>> 24) & 63)]);
left = (left ^ fval);
work = ((left << 28) | (left >>> 4));
work = (work ^ wKey[((round * 4) + 2)]);
fval = SP7[(work & 63)];
fval = (fval | SP5[((work >>> 8) & 63)]);
fval = (fval | SP3[((work >>> 16) & 63)]);
fval = (fval | SP1[((work >>> 24) & 63)]);
work = (left ^ wKey[((round * 4) + 3)]);
fval = (fval | SP8[(work & 63)]);
fval = (fval | SP6[((work >>> 8) & 63)]);
fval = (fval | SP4[((work >>> 16) & 63)]);
fval = (fval | SP2[((work >>> 24) & 63)]);
right = (right ^ fval);
round++;
};
right = ((right << 31) | (right >>> 1));
work = ((left ^ right) & 2863311530);
left = (left ^ work);
right = (right ^ work);
left = ((left << 31) | (left >>> 1));
work = (((left >>> 8) ^ right) & 0xFF00FF);
right = (right ^ work);
left = (left ^ (work << 8));
work = (((left >>> 2) ^ right) & 858993459);
right = (right ^ work);
left = (left ^ (work << 2));
work = (((right >>> 16) ^ left) & 0xFFFF);
left = (left ^ work);
right = (right ^ (work << 16));
work = (((right >>> 4) ^ left) & 252645135);
left = (left ^ work);
right = (right ^ (work << 4));
out[(outOff + 0)] = ((right >>> 24) & 0xFF);
out[(outOff + 1)] = ((right >>> 16) & 0xFF);
out[(outOff + 2)] = ((right >>> 8) & 0xFF);
out[(outOff + 3)] = (right & 0xFF);
out[(outOff + 4)] = ((left >>> 24) & 0xFF);
out[(outOff + 5)] = ((left >>> 16) & 0xFF);
out[(outOff + 6)] = ((left >>> 8) & 0xFF);
out[(outOff + 7)] = (left & 0xFF);
}
public function toString():String{
return ("des");
}
public function getBlockSize():uint{
return (8);
}
}
}//package com.hurlant.crypto.symmetric
Section 35
//ECBMode (com.hurlant.crypto.symmetric.ECBMode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.util.*;
public class ECBMode implements IMode, ICipher {
private var key:ISymmetricKey;
private var padding:IPad;
public function ECBMode(key:ISymmetricKey, padding:IPad=null){
super();
this.key = key;
if (padding == null){
padding = new PKCS5(key.getBlockSize());
} else {
padding.setBlockSize(key.getBlockSize());
};
this.padding = padding;
}
public function encrypt(src:ByteArray):void{
var blockSize:uint;
var tmp:ByteArray;
var dst:ByteArray;
var i:uint;
padding.pad(src);
src.position = 0;
blockSize = key.getBlockSize();
tmp = new ByteArray();
dst = new ByteArray();
i = 0;
while (i < src.length) {
tmp.length = 0;
src.readBytes(tmp, 0, blockSize);
key.encrypt(tmp);
dst.writeBytes(tmp);
i = (i + blockSize);
};
src.length = 0;
src.writeBytes(dst);
}
public function decrypt(src:ByteArray):void{
var blockSize:uint;
var tmp:ByteArray;
var dst:ByteArray;
var i:uint;
src.position = 0;
blockSize = key.getBlockSize();
if ((src.length % blockSize) != 0){
throw (new Error(("ECB mode cipher length must be a multiple of blocksize " + blockSize)));
};
tmp = new ByteArray();
dst = new ByteArray();
i = 0;
while (i < src.length) {
tmp.length = 0;
src.readBytes(tmp, 0, blockSize);
key.decrypt(tmp);
dst.writeBytes(tmp);
i = (i + blockSize);
};
padding.unpad(dst);
src.length = 0;
src.writeBytes(dst);
}
public function dispose():void{
key.dispose();
key = null;
padding = null;
Memory.gc();
}
public function getBlockSize():uint{
return (key.getBlockSize());
}
public function toString():String{
return ((key.toString() + "-ecb"));
}
}
}//package com.hurlant.crypto.symmetric
Section 36
//ICipher (com.hurlant.crypto.symmetric.ICipher)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public interface ICipher {
function encrypt(D:\dev\GAMES\TD;com\hurlant\crypto\symmetric;ICipher.as:ByteArray):void;
function dispose():void;
function getBlockSize():uint;
function toString():String;
function decrypt(D:\dev\GAMES\TD;com\hurlant\crypto\symmetric;ICipher.as:ByteArray):void;
}
}//package com.hurlant.crypto.symmetric
Section 37
//IMode (com.hurlant.crypto.symmetric.IMode)
package com.hurlant.crypto.symmetric {
public interface IMode extends ICipher {
}
}//package com.hurlant.crypto.symmetric
Section 38
//IPad (com.hurlant.crypto.symmetric.IPad)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public interface IPad {
function pad(:ByteArray):void;
function unpad(:ByteArray):void;
function setBlockSize(:uint):void;
}
}//package com.hurlant.crypto.symmetric
Section 39
//IStreamCipher (com.hurlant.crypto.symmetric.IStreamCipher)
package com.hurlant.crypto.symmetric {
public interface IStreamCipher extends ICipher {
}
}//package com.hurlant.crypto.symmetric
Section 40
//ISymmetricKey (com.hurlant.crypto.symmetric.ISymmetricKey)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public interface ISymmetricKey {
function encrypt(_arg1:ByteArray, _arg2:uint=0):void;
function dispose():void;
function getBlockSize():uint;
function toString():String;
function decrypt(_arg1:ByteArray, _arg2:uint=0):void;
}
}//package com.hurlant.crypto.symmetric
Section 41
//IVMode (com.hurlant.crypto.symmetric.IVMode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.crypto.prng.*;
import com.hurlant.util.*;
public class IVMode {
protected var lastIV:ByteArray;
protected var iv:ByteArray;
protected var blockSize:uint;
protected var padding:IPad;
protected var prng:Random;
protected var key:ISymmetricKey;
public function IVMode(key:ISymmetricKey, padding:IPad=null){
super();
this.key = key;
blockSize = key.getBlockSize();
if (padding == null){
padding = new PKCS5(blockSize);
} else {
padding.setBlockSize(blockSize);
};
this.padding = padding;
prng = new Random();
iv = null;
lastIV = new ByteArray();
}
public function set IV(value:ByteArray):void{
iv = value;
lastIV.length = 0;
lastIV.writeBytes(iv);
}
protected function getIV4d():ByteArray{
var vec:ByteArray;
vec = new ByteArray();
if (iv){
vec.writeBytes(iv);
} else {
throw (new Error("an IV must be set before calling decrypt()"));
};
return (vec);
}
protected function getIV4e():ByteArray{
var vec:ByteArray;
vec = new ByteArray();
if (iv){
vec.writeBytes(iv);
} else {
prng.nextBytes(vec, blockSize);
};
lastIV.length = 0;
lastIV.writeBytes(vec);
return (vec);
}
public function get IV():ByteArray{
return (lastIV);
}
public function dispose():void{
var i:uint;
if (iv != null){
i = 0;
while (i < iv.length) {
iv[i] = prng.nextByte();
i++;
};
iv.length = 0;
iv = null;
};
if (lastIV != null){
i = 0;
while (i < iv.length) {
lastIV[i] = prng.nextByte();
i++;
};
lastIV.length = 0;
lastIV = null;
};
key.dispose();
key = null;
padding = null;
prng.dispose();
prng = null;
Memory.gc();
}
public function getBlockSize():uint{
return (key.getBlockSize());
}
}
}//package com.hurlant.crypto.symmetric
Section 42
//NullPad (com.hurlant.crypto.symmetric.NullPad)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public class NullPad implements IPad {
public function NullPad(){
super();
}
public function pad(a:ByteArray):void{
}
public function unpad(a:ByteArray):void{
}
public function setBlockSize(bs:uint):void{
}
}
}//package com.hurlant.crypto.symmetric
Section 43
//OFBMode (com.hurlant.crypto.symmetric.OFBMode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public class OFBMode extends IVMode implements IMode {
public function OFBMode(key:ISymmetricKey, padding:IPad=null){
super(key, null);
}
public function toString():String{
return ((key.toString() + "-ofb"));
}
private function core(src:ByteArray, iv:ByteArray):void{
var l:uint;
var tmp:ByteArray;
var i:uint;
var chunk:uint;
var j:uint;
l = src.length;
tmp = new ByteArray();
i = 0;
while (i < src.length) {
key.encrypt(iv);
tmp.position = 0;
tmp.writeBytes(iv);
chunk = (((i + blockSize))<l) ? blockSize : (l - i);
j = 0;
while (j < chunk) {
src[(i + j)] = (src[(i + j)] ^ iv[j]);
j++;
};
iv.position = 0;
iv.writeBytes(tmp);
i = (i + blockSize);
};
}
public function decrypt(src:ByteArray):void{
var vector:ByteArray;
vector = getIV4d();
core(src, vector);
}
public function encrypt(src:ByteArray):void{
var vector:ByteArray;
vector = getIV4e();
core(src, vector);
}
}
}//package com.hurlant.crypto.symmetric
Section 44
//PKCS5 (com.hurlant.crypto.symmetric.PKCS5)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public class PKCS5 implements IPad {
private var blockSize:uint;
public function PKCS5(blockSize:uint=0){
super();
this.blockSize = blockSize;
}
public function unpad(a:ByteArray):void{
var c:uint;
var i:uint;
var v:uint;
c = (a.length % blockSize);
if (c != 0){
throw (new Error("PKCS#5::unpad: ByteArray.length isn't a multiple of the blockSize"));
};
c = a[(a.length - 1)];
i = c;
while (i > 0) {
v = a[(a.length - 1)];
a.length--;
if (c != v){
throw (new Error((((("PKCS#5:unpad: Invalid padding value. expected [" + c) + "], found [") + v) + "]")));
};
i--;
};
}
public function pad(a:ByteArray):void{
var c:uint;
var i:uint;
c = (blockSize - (a.length % blockSize));
i = 0;
while (i < c) {
a[a.length] = c;
i++;
};
}
public function setBlockSize(bs:uint):void{
blockSize = bs;
}
}
}//package com.hurlant.crypto.symmetric
Section 45
//SimpleIVMode (com.hurlant.crypto.symmetric.SimpleIVMode)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.util.*;
public class SimpleIVMode implements IMode, ICipher {
protected var mode:IVMode;
protected var cipher:ICipher;
public function SimpleIVMode(mode:IVMode){
super();
this.mode = mode;
cipher = (mode as ICipher);
}
public function encrypt(src:ByteArray):void{
var tmp:ByteArray;
cipher.encrypt(src);
tmp = new ByteArray();
tmp.writeBytes(mode.IV);
tmp.writeBytes(src);
src.position = 0;
src.writeBytes(tmp);
}
public function decrypt(src:ByteArray):void{
var tmp:ByteArray;
tmp = new ByteArray();
tmp.writeBytes(src, 0, getBlockSize());
mode.IV = tmp;
tmp = new ByteArray();
tmp.writeBytes(src, getBlockSize());
cipher.decrypt(tmp);
src.length = 0;
src.writeBytes(tmp);
}
public function dispose():void{
mode.dispose();
mode = null;
cipher = null;
Memory.gc();
}
public function toString():String{
return (("simple-" + cipher.toString()));
}
public function getBlockSize():uint{
return (mode.getBlockSize());
}
}
}//package com.hurlant.crypto.symmetric
Section 46
//TripleDESKey (com.hurlant.crypto.symmetric.TripleDESKey)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.util.*;
public class TripleDESKey extends DESKey {
protected var decKey2:Array;
protected var decKey3:Array;
protected var encKey2:Array;
protected var encKey3:Array;
public function TripleDESKey(key:ByteArray){
super(key);
encKey2 = generateWorkingKey(false, key, 8);
decKey2 = generateWorkingKey(true, key, 8);
if (key.length > 16){
encKey3 = generateWorkingKey(true, key, 16);
decKey3 = generateWorkingKey(false, key, 16);
} else {
encKey3 = encKey;
decKey3 = decKey;
};
}
override public function decrypt(block:ByteArray, index:uint=0):void{
desFunc(decKey3, block, index, block, index);
desFunc(decKey2, block, index, block, index);
desFunc(decKey, block, index, block, index);
}
override public function encrypt(block:ByteArray, index:uint=0):void{
desFunc(encKey, block, index, block, index);
desFunc(encKey2, block, index, block, index);
desFunc(encKey3, block, index, block, index);
}
override public function dispose():void{
var i:uint;
super.dispose();
i = 0;
if (encKey2 != null){
i = 0;
while (i < encKey2.length) {
encKey2[i] = 0;
i++;
};
encKey2 = null;
};
if (encKey3 != null){
i = 0;
while (i < encKey3.length) {
encKey3[i] = 0;
i++;
};
encKey3 = null;
};
if (decKey2 != null){
i = 0;
while (i < decKey2.length) {
decKey2[i] = 0;
i++;
};
decKey2 = null;
};
if (decKey3 != null){
i = 0;
while (i < decKey3.length) {
decKey3[i] = 0;
i++;
};
decKey3 = null;
};
Memory.gc();
}
override public function toString():String{
return ("3des");
}
}
}//package com.hurlant.crypto.symmetric
Section 47
//XTeaKey (com.hurlant.crypto.symmetric.XTeaKey)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
import com.hurlant.crypto.prng.*;
import com.hurlant.util.*;
public class XTeaKey implements ISymmetricKey {
public const NUM_ROUNDS:uint = 64;
private var k:Array;
public function XTeaKey(a:ByteArray){
super();
a.position = 0;
k = [a.readUnsignedInt(), a.readUnsignedInt(), a.readUnsignedInt(), a.readUnsignedInt()];
}
public function dispose():void{
var r:Random;
var i:uint;
r = new Random();
i = 0;
while (i < k.length) {
k[i] = r.nextByte();
delete k[i];
i++;
};
k = null;
Memory.gc();
}
public function encrypt(block:ByteArray, index:uint=0):void{
var v0:uint;
var v1:uint;
var i:uint;
var sum:uint;
var delta:uint;
block.position = index;
v0 = block.readUnsignedInt();
v1 = block.readUnsignedInt();
sum = 0;
delta = 2654435769;
i = 0;
while (i < NUM_ROUNDS) {
v0 = (v0 + ((((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[(sum & 3)])));
sum = (sum + delta);
v1 = (v1 + ((((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[((sum >> 11) & 3)])));
i++;
};
block.position = (block.position - 8);
block.writeUnsignedInt(v0);
block.writeUnsignedInt(v1);
}
public function decrypt(block:ByteArray, index:uint=0):void{
var v0:uint;
var v1:uint;
var i:uint;
var delta:uint;
var sum:uint;
block.position = index;
v0 = block.readUnsignedInt();
v1 = block.readUnsignedInt();
delta = 2654435769;
sum = (delta * NUM_ROUNDS);
i = 0;
while (i < NUM_ROUNDS) {
v1 = (v1 - ((((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[((sum >> 11) & 3)])));
sum = (sum - delta);
v0 = (v0 - ((((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[(sum & 3)])));
i++;
};
block.position = (block.position - 8);
block.writeUnsignedInt(v0);
block.writeUnsignedInt(v1);
}
public function toString():String{
return ("xtea");
}
public function getBlockSize():uint{
return (8);
}
public static function parseKey(K:String):XTeaKey{
var a:ByteArray;
a = new ByteArray();
a.writeUnsignedInt(parseInt(K.substr(0, 8), 16));
a.writeUnsignedInt(parseInt(K.substr(8, 8), 16));
a.writeUnsignedInt(parseInt(K.substr(16, 8), 16));
a.writeUnsignedInt(parseInt(K.substr(24, 8), 16));
a.position = 0;
return (new XTeaKey(a));
}
}
}//package com.hurlant.crypto.symmetric
Section 48
//Crypto (com.hurlant.crypto.Crypto)
package com.hurlant.crypto {
import flash.utils.*;
import com.hurlant.crypto.symmetric.*;
import com.hurlant.crypto.hash.*;
import com.hurlant.crypto.rsa.*;
import com.hurlant.crypto.prng.*;
import com.hurlant.util.*;
public class Crypto {
private var b64:Base64;
public function Crypto(){
super();
}
public static function getCipher(name:String, key:ByteArray, pad:IPad=null):ICipher{
var keys:Array;
var _local5:ICipher;
keys = name.split("-");
switch (keys[0]){
case "simple":
keys.shift();
name = keys.join("-");
_local5 = getCipher(name, key, pad);
if ((_local5 is IVMode)){
return (new SimpleIVMode((_local5 as IVMode)));
};
return (_local5);
case "aes":
case "aes128":
case "aes192":
case "aes256":
keys.shift();
if ((key.length * 8) == keys[0]){
keys.shift();
};
return (getMode(keys[0], new AESKey(key), pad));
case "bf":
case "blowfish":
keys.shift();
return (getMode(keys[0], new BlowFishKey(key), pad));
case "des":
keys.shift();
if (((!((keys[0] == "ede"))) && (!((keys[0] == "ede3"))))){
return (getMode(keys[0], new DESKey(key), pad));
};
if (keys.length == 1){
keys.push("ecb");
};
case "3des":
case "des3":
keys.shift();
return (getMode(keys[0], new TripleDESKey(key), pad));
case "xtea":
keys.shift();
return (getMode(keys[0], new XTeaKey(key), pad));
case "rc4":
keys.shift();
return (new ARC4(key));
};
return (null);
}
public static function getHash(name:String):IHash{
switch (name){
case "md2":
return (new MD2());
case "md5":
return (new MD5());
case "sha":
case "sha1":
return (new SHA1());
case "sha224":
return (new SHA224());
case "sha256":
return (new SHA256());
};
return (null);
}
public static function getRSA(E:String, M:String):RSAKey{
return (RSAKey.parsePublicKey(M, E));
}
private static function getMode(name:String, alg:ISymmetricKey, padding:IPad=null):IMode{
switch (name){
case "ecb":
return (new ECBMode(alg, padding));
case "cfb":
return (new CFBMode(alg, padding));
case "cfb8":
return (new CFB8Mode(alg, padding));
case "ofb":
return (new OFBMode(alg, padding));
case "ctr":
return (new CTRMode(alg, padding));
case "cbc":
default:
return (new CBCMode(alg, padding));
};
}
public static function getKeySize(name:String):uint{
var keys:Array;
keys = name.split("-");
switch (keys[0]){
case "simple":
keys.shift();
return (getKeySize(keys.join("-")));
case "aes128":
return (16);
case "aes192":
return (24);
case "aes256":
return (32);
case "aes":
keys.shift();
return ((parseInt(keys[0]) / 8));
case "bf":
case "blowfish":
return (16);
case "des":
keys.shift();
switch (keys[0]){
case "ede":
return (16);
case "ede3":
return (24);
default:
return (8);
};
case "3des":
case "des3":
return (24);
case "xtea":
return (8);
case "rc4":
if (parseInt(keys[1]) > 0){
return ((parseInt(keys[1]) / 8));
};
return (16);
};
return (0);
}
public static function getPad(name:String):IPad{
switch (name){
case "null":
return (new NullPad());
case "pkcs5":
default:
return (new PKCS5());
};
}
public static function getHMAC(name:String):HMAC{
var keys:Array;
var bits:uint;
keys = name.split("-");
if (keys[0] == "hmac"){
keys.shift();
};
bits = 0;
if (keys.length > 1){
bits = parseInt(keys[1]);
};
return (new HMAC(getHash(keys[0]), bits));
}
}
}//package com.hurlant.crypto
Section 49
//BarrettReduction (com.hurlant.math.BarrettReduction)
package com.hurlant.math {
import com.hurlant.math.*;
class BarrettReduction implements IReduction {
private var r2:BigInteger;
private var q3:BigInteger;
private var mu:BigInteger;
private var m:BigInteger;
function BarrettReduction(m:BigInteger){
super();
r2 = new BigInteger();
q3 = new BigInteger();
BigInteger.ONE.dlShiftTo((2 * m.t), r2);
mu = r2.divide(m);
this.m = m;
}
public function reduce(lx:BigInteger):void{
var x:BigInteger;
x = (lx as BigInteger);
x.drShiftTo((m.t - 1), r2);
if (x.t > (m.t + 1)){
x.t = (m.t + 1);
x.clamp();
};
mu.multiplyUpperTo(r2, (m.t + 1), q3);
m.multiplyLowerTo(q3, (m.t + 1), r2);
while (x.compareTo(r2) < 0) {
x.dAddOffset(1, (m.t + 1));
};
x.subTo(r2, x);
while (x.compareTo(m) >= 0) {
x.subTo(m, x);
};
}
public function revert(x:BigInteger):BigInteger{
return (x);
}
public function convert(x:BigInteger):BigInteger{
var r:BigInteger;
if ((((x.s < 0)) || ((x.t > (2 * m.t))))){
return (x.mod(m));
};
if (x.compareTo(m) < 0){
return (x);
};
r = new BigInteger();
x.copyTo(r);
reduce(r);
return (r);
}
public function sqrTo(x:BigInteger, r:BigInteger):void{
x.squareTo(r);
reduce(r);
}
public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void{
x.multiplyTo(y, r);
reduce(r);
}
}
}//package com.hurlant.math
Section 50
//bi_internal (com.hurlant.math.bi_internal)
package com.hurlant.math {
public namespace bi_internal = "http://crypto.hurlant.com/BigInteger";
}//package com.hurlant.math
Section 51
//BigInteger (com.hurlant.math.BigInteger)
package com.hurlant.math {
import flash.utils.*;
import com.hurlant.crypto.prng.*;
import com.hurlant.util.*;
public class BigInteger {
bi_internal var a:Array;
bi_internal var s:int;
public var t:int;
public static const ONE:BigInteger = nbv(1);
public static const ZERO:BigInteger = nbv(0);
public static const DM:int = (DV - 1);
public static const F1:int = 22;
public static const F2:int = 8;
public static const lplim:int = ((1 << 26) / lowprimes[(lowprimes.length - 1)]);
public static const lowprimes:Array = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 0x0101, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509];
public static const FV:Number = Math.pow(2, BI_FP);
public static const BI_FP:int = 52;
public static const DV:int = (1 << DB);
public static const DB:int = 30;
public function BigInteger(value=null, radix:int=0){
var array:ByteArray;
var length:int;
super();
a = new Array();
if ((value is String)){
value = Hex.toArray(value);
radix = 0;
};
if ((value is ByteArray)){
array = (value as ByteArray);
length = ((radix) || ((array.length - array.position)));
fromArray(array, length);
};
}
public function clearBit(n:int):BigInteger{
return (changeBit(n, op_andnot));
}
public function negate():BigInteger{
var r:BigInteger;
r = nbi();
ZERO.subTo(this, r);
return (r);
}
public function andNot(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
bitwiseTo(a, op_andnot, r);
return (r);
}
public function modPow(e:BigInteger, m:BigInteger):BigInteger{
var i:int;
var k:int;
var r:BigInteger;
var z:IReduction;
var g:Array;
var n:int;
var k1:int;
var km:int;
var j:int;
var w:int;
var is1:Boolean;
var r2:BigInteger;
var t:BigInteger;
var g2:BigInteger;
i = e.bitLength();
r = nbv(1);
if (i <= 0){
return (r);
};
if (i < 18){
k = 1;
} else {
if (i < 48){
k = 3;
} else {
if (i < 144){
k = 4;
} else {
if (i < 0x0300){
k = 5;
} else {
k = 6;
};
};
};
};
if (i < 8){
z = new ClassicReduction(m);
} else {
if (m.isEven()){
z = new BarrettReduction(m);
} else {
z = new MontgomeryReduction(m);
};
};
g = [];
n = 3;
k1 = (k - 1);
km = ((1 << k) - 1);
g[1] = z.convert(this);
if (k > 1){
g2 = new BigInteger();
z.sqrTo(g[1], g2);
while (n <= km) {
g[n] = new BigInteger();
z.mulTo(g2, g[(n - 2)], g[n]);
n = (n + 2);
};
};
j = (e.t - 1);
is1 = true;
r2 = new BigInteger();
i = (nbits(e.a[j]) - 1);
while (j >= 0) {
if (i >= k1){
w = ((e.a[j] >> (i - k1)) & km);
} else {
w = ((e.a[j] & ((1 << (i + 1)) - 1)) << (k1 - i));
if (j > 0){
w = (w | (e.a[(j - 1)] >> ((DB + i) - k1)));
};
};
n = k;
while ((w & 1) == 0) {
w = (w >> 1);
n--;
};
i = (i - n);
if (i < 0){
i = (i + DB);
j--;
};
if (is1){
g[w].copyTo(r);
is1 = false;
} else {
while (n > 1) {
z.sqrTo(r, r2);
z.sqrTo(r2, r);
n = (n - 2);
};
if (n > 0){
z.sqrTo(r, r2);
} else {
t = r;
r = r2;
r2 = t;
};
z.mulTo(r2, g[w], r);
};
while ((((j >= 0)) && (((e.a[j] & (1 << i)) == 0)))) {
z.sqrTo(r, r2);
t = r;
r = r2;
r2 = t;
--i;
if (i < 0){
i = (DB - 1);
j--;
};
};
};
return (z.revert(r));
}
public function isProbablePrime(t:int):Boolean{
var i:int;
var x:BigInteger;
var m:int;
var j:int;
x = abs();
if ((((x.t == 1)) && ((x.a[0] <= lowprimes[(lowprimes.length - 1)])))){
i = 0;
while (i < lowprimes.length) {
if (x[0] == lowprimes[i]){
return (true);
};
i++;
};
return (false);
};
if (x.isEven()){
return (false);
};
i = 1;
while (i < lowprimes.length) {
m = lowprimes[i];
j = (i + 1);
while ((((j < lowprimes.length)) && ((m < lplim)))) {
var _temp1 = j;
j = (j + 1);
m = (m * lowprimes[_temp1]);
};
m = x.modInt(m);
while (i < j) {
var _temp2 = m;
var _temp3 = i;
i = (i + 1);
if ((_temp2 % lowprimes[_temp3]) == 0){
return (false);
};
};
};
return (x.millerRabin(t));
}
private function op_or(x:int, y:int):int{
return ((x | y));
}
public function mod(v:BigInteger):BigInteger{
var r:BigInteger;
r = nbi();
abs().divRemTo(v, null, r);
if ((((s < 0)) && ((r.compareTo(ZERO) > 0)))){
v.subTo(r, r);
};
return (r);
}
protected function addTo(a:BigInteger, r:BigInteger):void{
var i:int;
var c:int;
var m:int;
i = 0;
c = 0;
m = Math.min(a.t, t);
while (i < m) {
c = (c + (this.a[i] + a.a[i]));
var _temp1 = i;
i = (i + 1);
var _local6 = _temp1;
r.a[_local6] = (c & DM);
c = (c >> DB);
};
if (a.t < t){
c = (c + a.s);
while (i < t) {
c = (c + this.a[i]);
var _temp2 = i;
i = (i + 1);
_local6 = _temp2;
r.a[_local6] = (c & DM);
c = (c >> DB);
};
c = (c + s);
} else {
c = (c + s);
while (i < a.t) {
c = (c + a.a[i]);
var _temp3 = i;
i = (i + 1);
_local6 = _temp3;
r.a[_local6] = (c & DM);
c = (c >> DB);
};
c = (c + a.s);
};
r.s = ((c)<0) ? -1 : 0;
if (c > 0){
var _temp4 = i;
i = (i + 1);
_local6 = _temp4;
r.a[_local6] = c;
} else {
if (c < -1){
var _temp5 = i;
i = (i + 1);
_local6 = _temp5;
r.a[_local6] = (DV + c);
};
};
r.t = i;
r.clamp();
}
protected function bitwiseTo(a:BigInteger, op:Function, r:BigInteger):void{
var i:int;
var f:int;
var m:int;
m = Math.min(a.t, t);
i = 0;
while (i < m) {
r.a[i] = op(this.a[i], a.a[i]);
i++;
};
if (a.t < t){
f = (a.s & DM);
i = m;
while (i < t) {
r.a[i] = op(this.a[i], f);
i++;
};
r.t = t;
} else {
f = (s & DM);
i = m;
while (i < a.t) {
r.a[i] = op(f, a.a[i]);
i++;
};
r.t = a.t;
};
r.s = op(s, a.s);
r.clamp();
}
protected function modInt(n:int):int{
var d:int;
var r:int;
var i:int;
if (n <= 0){
return (0);
};
d = (DV % n);
r = ((s)<0) ? (n - 1) : 0;
if (t > 0){
if (d == 0){
r = (a[0] % n);
} else {
i = (t - 1);
while (i >= 0) {
r = (((d * r) + a[i]) % n);
i--;
};
};
};
return (r);
}
protected function chunkSize(r:Number):int{
return (Math.floor(((Math.LN2 * DB) / Math.log(r))));
}
bi_internal function dAddOffset(n:int, w:int):void{
while (t <= w) {
var _local3 = t++;
a[_local3] = 0;
};
a[w] = (a[w] + n);
while (a[w] >= DV) {
a[w] = (a[w] - DV);
++w;
if (w >= t){
_local3 = t++;
a[_local3] = 0;
};
_local3 = a;
var _local4 = w;
var _local5 = (_local3[_local4] + 1);
_local3[_local4] = _local5;
};
}
bi_internal function lShiftTo(n:int, r:BigInteger):void{
var bs:int;
var cbs:int;
var bm:int;
var ds:int;
var c:int;
var i:int;
bs = (n % DB);
cbs = (DB - bs);
bm = ((1 << cbs) - 1);
ds = (n / DB);
c = ((s << bs) & DM);
i = (t - 1);
while (i >= 0) {
r.a[((i + ds) + 1)] = ((a[i] >> cbs) | c);
c = ((a[i] & bm) << bs);
i--;
};
i = (ds - 1);
while (i >= 0) {
r.a[i] = 0;
i--;
};
r.a[ds] = c;
r.t = ((t + ds) + 1);
r.s = s;
r.clamp();
}
public function getLowestSetBit():int{
var i:int;
i = 0;
while (i < t) {
if (a[i] != 0){
return (((i * DB) + lbit(a[i])));
};
i++;
};
if (s < 0){
return ((t * DB));
};
return (-1);
}
public function subtract(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
subTo(a, r);
return (r);
}
public function primify(bits:int, t:int):void{
if (!testBit((bits - 1))){
bitwiseTo(BigInteger.ONE.shiftLeft((bits - 1)), op_or, this);
};
if (isEven()){
dAddOffset(1, 0);
};
while (!(isProbablePrime(t))) {
dAddOffset(2, 0);
while (bitLength() > bits) {
subTo(BigInteger.ONE.shiftLeft((bits - 1)), this);
};
};
}
public function gcd(a:BigInteger):BigInteger{
var x:BigInteger;
var y:BigInteger;
var i:int;
var g:int;
var t:BigInteger;
x = ((s)<0) ? negate() : clone();
y = ((a.s)<0) ? a.negate() : a.clone();
if (x.compareTo(y) < 0){
t = x;
x = y;
y = t;
};
i = x.getLowestSetBit();
g = y.getLowestSetBit();
if (g < 0){
return (x);
};
if (i < g){
g = i;
};
if (g > 0){
x.rShiftTo(g, x);
y.rShiftTo(g, y);
};
while (x.sigNum() > 0) {
i = x.getLowestSetBit();
if (i > 0){
x.rShiftTo(i, x);
};
i = y.getLowestSetBit();
if (i > 0){
y.rShiftTo(i, y);
};
if (x.compareTo(y) >= 0){
x.subTo(y, x);
x.rShiftTo(1, x);
} else {
y.subTo(x, y);
y.rShiftTo(1, y);
};
};
if (g > 0){
y.lShiftTo(g, y);
};
return (y);
}
bi_internal function multiplyLowerTo(a:BigInteger, n:int, r:BigInteger):void{
var i:int;
var j:int;
i = Math.min((t + a.t), n);
r.s = 0;
r.t = i;
while (i > 0) {
--i;
var _local6 = i;
r.a[_local6] = 0;
};
j = (r.t - t);
while (i < j) {
r.a[(i + t)] = am(0, a.a[i], r, i, 0, t);
i++;
};
j = Math.min(a.t, n);
while (i < j) {
am(0, a.a[i], r, i, 0, (n - i));
i++;
};
r.clamp();
}
public function modPowInt(e:int, m:BigInteger):BigInteger{
var z:IReduction;
if ((((e < 0x0100)) || (m.isEven()))){
z = new ClassicReduction(m);
} else {
z = new MontgomeryReduction(m);
};
return (exp(e, z));
}
bi_internal function intAt(str:String, index:int):int{
return (parseInt(str.charAt(index), 36));
}
public function testBit(n:int):Boolean{
var j:int;
j = Math.floor((n / DB));
if (j >= t){
return (!((s == 0)));
};
return (!(((a[j] & (1 << (n % DB))) == 0)));
}
bi_internal function exp(e:int, z:IReduction):BigInteger{
var r:BigInteger;
var r2:BigInteger;
var g:BigInteger;
var i:int;
var t:BigInteger;
if ((((e > 4294967295)) || ((e < 1)))){
return (ONE);
};
r = nbi();
r2 = nbi();
g = z.convert(this);
i = (nbits(e) - 1);
g.copyTo(r);
while (--i >= 0) {
z.sqrTo(r, r2);
if ((e & (1 << i)) > 0){
z.mulTo(r2, g, r);
} else {
t = r;
r = r2;
r2 = t;
};
};
return (z.revert(r));
}
public function toArray(array:ByteArray):uint{
var k:int;
var km:int;
var d:int;
var i:int;
var p:int;
var m:Boolean;
var c:int;
k = 8;
km = ((1 << 8) - 1);
d = 0;
i = t;
p = (DB - ((i * DB) % k));
m = false;
c = 0;
var _temp1 = i;
i = (i - 1);
if (_temp1 > 0){
if ((((p < DB)) && (((a[i] >> p) > 0)))){
m = true;
array.writeByte(d);
c++;
};
while (i >= 0) {
if (p < k){
d = ((a[i] & ((1 << p) - 1)) << (k - p));
var _temp2 = d;
i = (i - 1);
p = (p + (DB - k));
d = (_temp2 | (a[i] >> p));
} else {
p = (p - k);
d = ((a[i] >> p) & km);
if (p <= 0){
p = (p + DB);
i--;
};
};
if (d > 0){
m = true;
};
if (m){
array.writeByte(d);
c++;
};
};
};
return (c);
}
public function dispose():void{
var r:Random;
var i:uint;
r = new Random();
i = 0;
while (i < a.length) {
a[i] = r.nextByte();
delete a[i];
i++;
};
a = null;
t = 0;
s = 0;
Memory.gc();
}
private function lbit(x:int):int{
var r:int;
if (x == 0){
return (-1);
};
r = 0;
if ((x & 0xFFFF) == 0){
x = (x >> 16);
r = (r + 16);
};
if ((x & 0xFF) == 0){
x = (x >> 8);
r = (r + 8);
};
if ((x & 15) == 0){
x = (x >> 4);
r = (r + 4);
};
if ((x & 3) == 0){
x = (x >> 2);
r = (r + 2);
};
if ((x & 1) == 0){
r++;
};
return (r);
}
bi_internal function divRemTo(m:BigInteger, q:BigInteger=null, r:BigInteger=null):void{
var pm:BigInteger;
var pt:BigInteger;
var y:BigInteger;
var ts:int;
var ms:int;
var nsh:int;
var ys:int;
var y0:int;
var yt:Number;
var d1:Number;
var d2:Number;
var e:Number;
var i:int;
var j:int;
var t:BigInteger;
var qd:int;
var m = m;
var q = q;
var r = r;
pm = m.abs();
if (pm.t <= 0){
return;
};
pt = abs();
if (pt.t < pm.t){
if (q != null){
q.fromInt(0);
};
if (r != null){
copyTo(r);
};
return;
};
if (r == null){
r = nbi();
};
y = nbi();
ts = s;
ms = m.s;
nsh = (DB - nbits(pm.a[(pm.t - 1)]));
if (nsh > 0){
pm.lShiftTo(nsh, y);
pt.lShiftTo(nsh, r);
} else {
pm.copyTo(y);
pt.copyTo(r);
};
ys = y.t;
y0 = y.a[(ys - 1)];
if (y0 == 0){
return;
};
yt = ((y0 * (1 << F1)) + ((ys)>1) ? (y.a[(ys - 2)] >> F2) : 0);
d1 = (FV / yt);
d2 = ((1 << F1) / yt);
e = (1 << F2);
i = r.t;
j = (i - ys);
t = ((q)==null) ? nbi() : q;
y.dlShiftTo(j, t);
if (r.compareTo(t) >= 0){
var _local5 = r.t++;
r.a[_local5] = 1;
r.subTo(t, r);
};
ONE.dlShiftTo(ys, t);
t.subTo(y, y);
while (y.t < ys) {
y.(y.t++); //not popped
};
while ((j = (j - 1)), (j - 1) >= 0) {
i = (i - 1);
qd = ((r.a[(i - 1)])==y0) ? DM : ((Number(r.a[i]) * d1) + ((Number(r.a[(i - 1)]) + e) * d2));
if ((r.a[i] = (r.a[i] + y.am(0, qd, r, j, 0, ys))) < qd){
y.dlShiftTo(j, t);
r.subTo(t, r);
while ((qd = (qd - 1)), r.a[i] < (qd - 1)) {
r.subTo(t, r);
};
};
};
if (q != null){
r.drShiftTo(ys, q);
if (ts != ms){
ZERO.subTo(q, q);
};
};
r.t = ys;
r.clamp();
if (nsh > 0){
r.rShiftTo(nsh, r);
};
if (ts < 0){
ZERO.subTo(r, r);
};
}
public function remainder(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
divRemTo(a, null, r);
return (r);
}
public function divide(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
divRemTo(a, r, null);
return (r);
}
public function divideAndRemainder(a:BigInteger):Array{
var q:BigInteger;
var r:BigInteger;
q = new BigInteger();
r = new BigInteger();
divRemTo(a, q, r);
return ([q, r]);
}
public function valueOf():Number{
var coef:Number;
var value:Number;
var i:uint;
coef = 1;
value = 0;
i = 0;
while (i < t) {
value = (value + (a[i] * coef));
coef = (coef * DV);
i++;
};
return (value);
}
public function shiftLeft(n:int):BigInteger{
var r:BigInteger;
r = new BigInteger();
if (n < 0){
rShiftTo(-(n), r);
} else {
lShiftTo(n, r);
};
return (r);
}
public function multiply(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
multiplyTo(a, r);
return (r);
}
bi_internal function am(i:int, x:int, w:BigInteger, j:int, c:int, n:int):int{
var xl:int;
var xh:int;
var l:int;
var h:int;
var m:int;
xl = (x & 32767);
xh = (x >> 15);
while (--n >= 0) {
l = (a[i] & 32767);
var _temp1 = i;
i = (i + 1);
h = (a[_temp1] >> 15);
m = ((xh * l) + (h * xl));
l = ((((xl * l) + ((m & 32767) << 15)) + w.a[j]) + (c & 1073741823));
c = ((((l >>> 30) + (m >>> 15)) + (xh * h)) + (c >>> 30));
var _temp2 = j;
j = (j + 1);
var _local12 = _temp2;
w.a[_local12] = (l & 1073741823);
};
return (c);
}
bi_internal function drShiftTo(n:int, r:BigInteger):void{
var i:int;
i = n;
while (i < t) {
r.a[(i - n)] = a[i];
i++;
};
r.t = Math.max((t - n), 0);
r.s = s;
}
public function add(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
addTo(a, r);
return (r);
}
bi_internal function multiplyUpperTo(a:BigInteger, n:int, r:BigInteger):void{
var i:int;
n--;
i = (r.t = ((t + a.t) - n));
r.s = 0;
while (--i >= 0) {
r.a[i] = 0;
};
i = Math.max((n - t), 0);
while (i < a.t) {
r.a[((t + i) - n)] = am((n - i), a.a[i], r, 0, 0, ((t + i) - n));
i++;
};
r.clamp();
r.drShiftTo(1, r);
}
protected function nbi(){
return (new BigInteger());
}
protected function millerRabin(t:int):Boolean{
var n1:BigInteger;
var k:int;
var r:BigInteger;
var a:BigInteger;
var i:int;
var y:BigInteger;
var j:int;
n1 = subtract(BigInteger.ONE);
k = n1.getLowestSetBit();
if (k <= 0){
return (false);
};
r = n1.shiftRight(k);
t = ((t + 1) >> 1);
if (t > lowprimes.length){
t = lowprimes.length;
};
a = new BigInteger();
i = 0;
while (i < t) {
a.fromInt(lowprimes[i]);
y = a.modPow(r, this);
if (((!((y.compareTo(BigInteger.ONE) == 0))) && (!((y.compareTo(n1) == 0))))){
j = 1;
while ((((j++ < k)) && (!((y.compareTo(n1) == 0))))) {
y = y.modPowInt(2, this);
if (y.compareTo(BigInteger.ONE) == 0){
return (false);
};
};
if (y.compareTo(n1) != 0){
return (false);
};
};
i++;
};
return (true);
}
bi_internal function dMultiply(n:int):void{
a[t] = am(0, (n - 1), this, 0, 0, t);
t++;
clamp();
}
private function op_andnot(x:int, y:int):int{
return ((x & ~(y)));
}
bi_internal function clamp():void{
var c:int;
c = (s & DM);
while ((((t > 0)) && ((a[(t - 1)] == c)))) {
t--;
};
}
bi_internal function invDigit():int{
var x:int;
var y:int;
if (t < 1){
return (0);
};
x = a[0];
if ((x & 1) == 0){
return (0);
};
y = (x & 3);
y = ((y * (2 - ((x & 15) * y))) & 15);
y = ((y * (2 - ((x & 0xFF) * y))) & 0xFF);
y = ((y * (2 - (((x & 0xFFFF) * y) & 0xFFFF))) & 0xFFFF);
y = ((y * (2 - ((x * y) % DV))) % DV);
return (((y)>0) ? (DV - y) : -(y));
}
protected function changeBit(n:int, op:Function):BigInteger{
var r:BigInteger;
r = BigInteger.ONE.shiftLeft(n);
bitwiseTo(r, op, r);
return (r);
}
public function equals(a:BigInteger):Boolean{
return ((compareTo(a) == 0));
}
public function compareTo(v:BigInteger):int{
var r:int;
var i:int;
r = (s - v.s);
if (r != 0){
return (r);
};
i = t;
r = (i - v.t);
if (r != 0){
return (r);
};
while (--i >= 0) {
r = (a[i] - v.a[i]);
if (r != 0){
return (r);
};
};
return (0);
}
public function shiftRight(n:int):BigInteger{
var r:BigInteger;
r = new BigInteger();
if (n < 0){
lShiftTo(-(n), r);
} else {
rShiftTo(n, r);
};
return (r);
}
bi_internal function multiplyTo(v:BigInteger, r:BigInteger):void{
var x:BigInteger;
var y:BigInteger;
var i:int;
x = abs();
y = v.abs();
i = x.t;
r.t = (i + y.t);
while (--i >= 0) {
r.a[i] = 0;
};
i = 0;
while (i < y.t) {
r.a[(i + x.t)] = x.am(0, y.a[i], r, i, 0, x.t);
i++;
};
r.s = 0;
r.clamp();
if (s != v.s){
ZERO.subTo(r, r);
};
}
public function bitCount():int{
var r:int;
var x:int;
var i:int;
r = 0;
x = (s & DM);
i = 0;
while (i < t) {
r = (r + cbit((a[i] ^ x)));
i++;
};
return (r);
}
public function byteValue():int{
return (((t)==0) ? s : ((a[0] << 24) >> 24));
}
private function cbit(x:int):int{
var r:uint;
r = 0;
while (x != 0) {
x = (x & (x - 1));
r++;
};
return (r);
}
bi_internal function rShiftTo(n:int, r:BigInteger):void{
var ds:int;
var bs:int;
var cbs:int;
var bm:int;
var i:int;
r.s = s;
ds = (n / DB);
if (ds >= t){
r.t = 0;
return;
};
bs = (n % DB);
cbs = (DB - bs);
bm = ((1 << bs) - 1);
r.a[0] = (a[ds] >> bs);
i = (ds + 1);
while (i < t) {
r.a[((i - ds) - 1)] = (r.a[((i - ds) - 1)] | ((a[i] & bm) << cbs));
r.a[(i - ds)] = (a[i] >> bs);
i++;
};
if (bs > 0){
r.a[((t - ds) - 1)] = (r.a[((t - ds) - 1)] | ((s & bm) << cbs));
};
r.t = (t - ds);
r.clamp();
}
public function modInverse(m:BigInteger):BigInteger{
var ac:Boolean;
var u:BigInteger;
var v:BigInteger;
var a:BigInteger;
var b:BigInteger;
var c:BigInteger;
var d:BigInteger;
ac = m.isEven();
if (((((isEven()) && (ac))) || ((m.sigNum() == 0)))){
return (BigInteger.ZERO);
};
u = m.clone();
v = clone();
a = nbv(1);
b = nbv(0);
c = nbv(0);
d = nbv(1);
while (u.sigNum() != 0) {
while (u.isEven()) {
u.rShiftTo(1, u);
if (ac){
if (((!(a.isEven())) || (!(b.isEven())))){
a.addTo(this, a);
b.subTo(m, b);
};
a.rShiftTo(1, a);
} else {
if (!b.isEven()){
b.subTo(m, b);
};
};
b.rShiftTo(1, b);
};
while (v.isEven()) {
v.rShiftTo(1, v);
if (ac){
if (((!(c.isEven())) || (!(d.isEven())))){
c.addTo(this, c);
d.subTo(m, d);
};
c.rShiftTo(1, c);
} else {
if (!d.isEven()){
d.subTo(m, d);
};
};
d.rShiftTo(1, d);
};
if (u.compareTo(v) >= 0){
u.subTo(v, u);
if (ac){
a.subTo(c, a);
};
b.subTo(d, b);
} else {
v.subTo(u, v);
if (ac){
c.subTo(a, c);
};
d.subTo(b, d);
};
};
if (v.compareTo(BigInteger.ONE) != 0){
return (BigInteger.ZERO);
};
if (d.compareTo(m) >= 0){
return (d.subtract(m));
};
if (d.sigNum() < 0){
d.addTo(m, d);
} else {
return (d);
};
if (d.sigNum() < 0){
return (d.add(m));
};
return (d);
}
bi_internal function fromArray(value:ByteArray, length:int):void{
var p:int;
var i:int;
var sh:int;
var k:int;
var x:int;
p = value.position;
i = (p + length);
sh = 0;
k = 8;
t = 0;
s = 0;
while (--i >= p) {
x = ((i < value.length)) ? value[i] : 0;
if (sh == 0){
var _local8 = t++;
a[_local8] = x;
} else {
if ((sh + k) > DB){
a[(t - 1)] = (a[(t - 1)] | ((x & ((1 << (DB - sh)) - 1)) << sh));
_local8 = t++;
a[_local8] = (x >> (DB - sh));
} else {
a[(t - 1)] = (a[(t - 1)] | (x << sh));
};
};
sh = (sh + k);
if (sh >= DB){
sh = (sh - DB);
};
};
clamp();
value.position = Math.min((p + length), value.length);
}
bi_internal function copyTo(r:BigInteger):void{
var i:int;
i = (t - 1);
while (i >= 0) {
r.a[i] = a[i];
i--;
};
r.t = t;
r.s = s;
}
public function intValue():int{
if (s < 0){
if (t == 1){
return ((a[0] - DV));
};
if (t == 0){
return (-1);
};
} else {
if (t == 1){
return (a[0]);
};
if (t == 0){
return (0);
};
};
return ((((a[1] & ((1 << (32 - DB)) - 1)) << DB) | a[0]));
}
public function min(a:BigInteger):BigInteger{
return (((compareTo(a))<0) ? this : a);
}
public function bitLength():int{
if (t <= 0){
return (0);
};
return (((DB * (t - 1)) + nbits((a[(t - 1)] ^ (s & DM)))));
}
public function shortValue():int{
return (((t)==0) ? s : ((a[0] << 16) >> 16));
}
public function and(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
bitwiseTo(a, op_and, r);
return (r);
}
protected function toRadix(b:uint=10):String{
var cs:int;
var a:Number;
var d:BigInteger;
var y:BigInteger;
var z:BigInteger;
var r:String;
if ((((((sigNum() == 0)) || ((b < 2)))) || ((b > 32)))){
return ("0");
};
cs = chunkSize(b);
a = Math.pow(b, cs);
d = nbv(a);
y = nbi();
z = nbi();
r = "";
divRemTo(d, y, z);
while (y.sigNum() > 0) {
r = ((a + z.intValue()).toString(b).substr(1) + r);
y.divRemTo(d, y, z);
};
return ((z.intValue().toString(b) + r));
}
public function not():BigInteger{
var r:BigInteger;
var i:int;
r = new BigInteger();
i = 0;
while (i < t) {
r[i] = (DM & ~(a[i]));
i++;
};
r.t = t;
r.s = ~(s);
return (r);
}
bi_internal function subTo(v:BigInteger, r:BigInteger):void{
var i:int;
var c:int;
var m:int;
i = 0;
c = 0;
m = Math.min(v.t, t);
while (i < m) {
c = (c + (a[i] - v.a[i]));
var _temp1 = i;
i = (i + 1);
var _local6 = _temp1;
r.a[_local6] = (c & DM);
c = (c >> DB);
};
if (v.t < t){
c = (c - v.s);
while (i < t) {
c = (c + a[i]);
var _temp2 = i;
i = (i + 1);
_local6 = _temp2;
r.a[_local6] = (c & DM);
c = (c >> DB);
};
c = (c + s);
} else {
c = (c + s);
while (i < v.t) {
c = (c - v.a[i]);
var _temp3 = i;
i = (i + 1);
_local6 = _temp3;
r.a[_local6] = (c & DM);
c = (c >> DB);
};
c = (c - v.s);
};
r.s = ((c)<0) ? -1 : 0;
if (c < -1){
var _temp4 = i;
i = (i + 1);
_local6 = _temp4;
r.a[_local6] = (DV + c);
} else {
if (c > 0){
var _temp5 = i;
i = (i + 1);
_local6 = _temp5;
r.a[_local6] = c;
};
};
r.t = i;
r.clamp();
}
public function clone():BigInteger{
var r:BigInteger;
r = new BigInteger();
this.copyTo(r);
return (r);
}
public function pow(e:int):BigInteger{
return (exp(e, new NullReduction()));
}
public function flipBit(n:int):BigInteger{
return (changeBit(n, op_xor));
}
public function xor(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
bitwiseTo(a, op_xor, r);
return (r);
}
public function or(a:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
bitwiseTo(a, op_or, r);
return (r);
}
public function max(a:BigInteger):BigInteger{
return (((compareTo(a))>0) ? this : a);
}
bi_internal function fromInt(value:int):void{
t = 1;
s = ((value)<0) ? -1 : 0;
if (value > 0){
a[0] = value;
} else {
if (value < -1){
a[0] = (value + DV);
} else {
t = 0;
};
};
}
bi_internal function isEven():Boolean{
return ((((t)>0) ? (a[0] & 1) : s == 0));
}
public function toString(radix:Number=16):String{
var k:int;
var km:int;
var d:int;
var m:Boolean;
var r:String;
var i:int;
var p:int;
if (s < 0){
return (("-" + negate().toString(radix)));
};
switch (radix){
case 2:
k = 1;
break;
case 4:
k = 2;
break;
case 8:
k = 3;
break;
case 16:
k = 4;
break;
case 32:
k = 5;
break;
};
km = ((1 << k) - 1);
d = 0;
m = false;
r = "";
i = t;
p = (DB - ((i * DB) % k));
var _temp1 = i;
i = (i - 1);
if (_temp1 > 0){
if ((((p < DB)) && (((a[i] >> p) > 0)))){
m = true;
r = d.toString(36);
};
while (i >= 0) {
if (p < k){
d = ((a[i] & ((1 << p) - 1)) << (k - p));
var _temp2 = d;
i = (i - 1);
p = (p + (DB - k));
d = (_temp2 | (a[i] >> p));
} else {
p = (p - k);
d = ((a[i] >> p) & km);
if (p <= 0){
p = (p + DB);
i--;
};
};
if (d > 0){
m = true;
};
if (m){
r = (r + d.toString(36));
};
};
};
return ((m) ? r : "0");
}
public function setBit(n:int):BigInteger{
return (changeBit(n, op_or));
}
public function abs():BigInteger{
return (((s)<0) ? negate() : this);
}
bi_internal function nbits(x:int):int{
var r:int;
var t:int;
r = 1;
t = (x >>> 16);
if (t != 0){
x = t;
r = (r + 16);
};
t = (x >> 8);
if (t != 0){
x = t;
r = (r + 8);
};
t = (x >> 4);
if (t != 0){
x = t;
r = (r + 4);
};
t = (x >> 2);
if (t != 0){
x = t;
r = (r + 2);
};
t = (x >> 1);
if (t != 0){
x = t;
r = (r + 1);
};
return (r);
}
public function sigNum():int{
if (s < 0){
return (-1);
};
if ((((t <= 0)) || ((((t == 1)) && ((a[0] <= 0)))))){
return (0);
};
return (1);
}
public function toByteArray():ByteArray{
var i:int;
var r:ByteArray;
var p:int;
var d:int;
var k:int;
i = t;
r = new ByteArray();
r[0] = s;
p = (DB - ((i * DB) % 8));
k = 0;
var _temp1 = i;
i = (i - 1);
if (_temp1 > 0){
if ((((p < DB)) && (!(((a[i] >> p) == ((s & DM) >> p)))))){
var _temp2 = k;
k = (k + 1);
var _local6 = _temp2;
r[_local6] = (d | (s << (DB - p)));
};
while (i >= 0) {
if (p < 8){
d = ((a[i] & ((1 << p) - 1)) << (8 - p));
var _temp3 = d;
i = (i - 1);
p = (p + (DB - 8));
d = (_temp3 | (a[i] >> p));
} else {
p = (p - 8);
d = ((a[i] >> p) & 0xFF);
if (p <= 0){
p = (p + DB);
i--;
};
};
if ((d & 128) != 0){
d = (d | -256);
};
if ((((k == 0)) && (!(((s & 128) == (d & 128)))))){
k++;
};
if ((((k > 0)) || (!((d == s))))){
var _temp4 = k;
k = (k + 1);
_local6 = _temp4;
r[_local6] = d;
};
};
};
return (r);
}
bi_internal function squareTo(r:BigInteger):void{
var x:BigInteger;
var i:int;
var c:int;
x = abs();
i = (r.t = (2 * x.t));
while (--i >= 0) {
r.a[i] = 0;
};
i = 0;
while (i < (x.t - 1)) {
c = x.am(i, x.a[i], r, (2 * i), 0, 1);
if ((r.a[(i + x.t)] = (r.a[(i + x.t)] + x.am((i + 1), (2 * x.a[i]), r, ((2 * i) + 1), c, ((x.t - i) - 1)))) >= DV){
r.a[(i + x.t)] = (r.a[(i + x.t)] - DV);
r.a[((i + x.t) + 1)] = 1;
};
i++;
};
if (r.t > 0){
r.a[(r.t - 1)] = (r.a[(r.t - 1)] + x.am(i, x.a[i], r, (2 * i), 0, 1));
};
r.s = 0;
r.clamp();
}
private function op_and(x:int, y:int):int{
return ((x & y));
}
protected function fromRadix(s:String, b:int=10):void{
var cs:int;
var d:Number;
var mi:Boolean;
var j:int;
var w:int;
var i:int;
var x:int;
fromInt(0);
cs = chunkSize(b);
d = Math.pow(b, cs);
mi = false;
j = 0;
w = 0;
i = 0;
while (i < s.length) {
x = intAt(s, i);
if (x < 0){
if ((((s.charAt(i) == "-")) && ((sigNum() == 0)))){
mi = true;
};
} else {
w = ((b * w) + x);
++j;
if (j >= cs){
dMultiply(d);
dAddOffset(w, 0);
j = 0;
w = 0;
};
};
i++;
};
if (j > 0){
dMultiply(Math.pow(b, j));
dAddOffset(w, 0);
};
if (mi){
BigInteger.ZERO.subTo(this, this);
};
}
bi_internal function dlShiftTo(n:int, r:BigInteger):void{
var i:int;
i = (t - 1);
while (i >= 0) {
r.a[(i + n)] = a[i];
i--;
};
i = (n - 1);
while (i >= 0) {
r.a[i] = 0;
i--;
};
r.t = (t + n);
r.s = s;
}
private function op_xor(x:int, y:int):int{
return ((x ^ y));
}
public static function nbv(value:int):BigInteger{
var bn:BigInteger;
bn = new (BigInteger);
bn.fromInt(value);
return (bn);
}
}
}//package com.hurlant.math
Section 52
//ClassicReduction (com.hurlant.math.ClassicReduction)
package com.hurlant.math {
import com.hurlant.math.*;
class ClassicReduction implements IReduction {
private var m:BigInteger;
function ClassicReduction(m:BigInteger){
super();
this.m = m;
}
public function revert(x:BigInteger):BigInteger{
return (x);
}
public function reduce(x:BigInteger):void{
x.divRemTo(m, null, x);
}
public function convert(x:BigInteger):BigInteger{
if ((((x.s < 0)) || ((x.compareTo(m) >= 0)))){
return (x.mod(m));
};
return (x);
}
public function sqrTo(x:BigInteger, r:BigInteger):void{
x.squareTo(r);
reduce(r);
}
public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void{
x.multiplyTo(y, r);
reduce(r);
}
}
}//package com.hurlant.math
Section 53
//IReduction (com.hurlant.math.IReduction)
package com.hurlant.math {
import com.hurlant.math.*;
interface IReduction {
function convert(:BigInteger):BigInteger;
function revert(:BigInteger):BigInteger;
function reduce(D:\dev\GAMES\TD;com\hurlant\math;IReduction.as:BigInteger):void;
function sqrTo(_arg1:BigInteger, _arg2:BigInteger):void;
function mulTo(_arg1:BigInteger, _arg2:BigInteger, _arg3:BigInteger):void;
}
}//package com.hurlant.math
Section 54
//MontgomeryReduction (com.hurlant.math.MontgomeryReduction)
package com.hurlant.math {
import com.hurlant.math.*;
class MontgomeryReduction implements IReduction {
private var um:int;
private var mp:int;
private var mph:int;
private var mpl:int;
private var mt2:int;
private var m:BigInteger;
function MontgomeryReduction(m:BigInteger){
super();
this.m = m;
mp = m.invDigit();
mpl = (mp & 32767);
mph = (mp >> 15);
um = ((1 << (BigInteger.DB - 15)) - 1);
mt2 = (2 * m.t);
}
public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void{
x.multiplyTo(y, r);
reduce(r);
}
public function revert(x:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
x.copyTo(r);
reduce(r);
return (r);
}
public function convert(x:BigInteger):BigInteger{
var r:BigInteger;
r = new BigInteger();
x.abs().dlShiftTo(m.t, r);
r.divRemTo(m, null, r);
if ((((x.s < 0)) && ((r.compareTo(BigInteger.ZERO) > 0)))){
m.subTo(r, r);
};
return (r);
}
public function reduce(x:BigInteger):void{
var i:int;
var j:int;
var u0:int;
while (x.t <= mt2) {
var _local5 = x.t++;
x.a[_local5] = 0;
};
i = 0;
while (i < m.t) {
j = (x.a[i] & 32767);
u0 = (((j * mpl) + ((((j * mph) + ((x.a[i] >> 15) * mpl)) & um) << 15)) & BigInteger.DM);
j = (i + m.t);
x.a[j] = (x.a[j] + m.am(0, u0, x, i, 0, m.t));
while (x.a[j] >= BigInteger.DV) {
x.a[j] = (x.a[j] - BigInteger.DV);
_local5 = x.a;
++j;
var _local6 = j;
var _local7 = (_local5[_local6] + 1);
_local5[_local6] = _local7;
};
i++;
};
x.clamp();
x.drShiftTo(m.t, x);
if (x.compareTo(m) >= 0){
x.subTo(m, x);
};
}
public function sqrTo(x:BigInteger, r:BigInteger):void{
x.squareTo(r);
reduce(r);
}
}
}//package com.hurlant.math
Section 55
//NullReduction (com.hurlant.math.NullReduction)
package com.hurlant.math {
public class NullReduction implements IReduction {
public function NullReduction(){
super();
}
public function reduce(x:BigInteger):void{
}
public function revert(x:BigInteger):BigInteger{
return (x);
}
public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void{
x.multiplyTo(y, r);
}
public function convert(x:BigInteger):BigInteger{
return (x);
}
public function sqrTo(x:BigInteger, r:BigInteger):void{
x.squareTo(r);
}
}
}//package com.hurlant.math
Section 56
//Base64 (com.hurlant.util.Base64)
package com.hurlant.util {
import flash.utils.*;
public class Base64 {
public static const version:String = "1.0.0";
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
public function Base64(){
super();
throw (new Error("Base64 class is static container only"));
}
public static function encode(data:String):String{
var bytes:ByteArray;
bytes = new ByteArray();
bytes.writeUTFBytes(data);
return (encodeByteArray(bytes));
}
public static function encodeByteArray(data:ByteArray):String{
var output:String;
var dataBuffer:Array;
var outputBuffer:Array;
var i:uint;
var j:uint;
var k:uint;
output = "";
outputBuffer = new Array(4);
data.position = 0;
while (data.bytesAvailable > 0) {
dataBuffer = new Array();
i = 0;
while ((((i < 3)) && ((data.bytesAvailable > 0)))) {
dataBuffer[i] = data.readUnsignedByte();
i++;
};
outputBuffer[0] = ((dataBuffer[0] & 252) >> 2);
outputBuffer[1] = (((dataBuffer[0] & 3) << 4) | (dataBuffer[1] >> 4));
outputBuffer[2] = (((dataBuffer[1] & 15) << 2) | (dataBuffer[2] >> 6));
outputBuffer[3] = (dataBuffer[2] & 63);
j = dataBuffer.length;
while (j < 3) {
outputBuffer[(j + 1)] = 64;
j++;
};
k = 0;
while (k < outputBuffer.length) {
output = (output + BASE64_CHARS.charAt(outputBuffer[k]));
k++;
};
};
return (output);
}
public static function decode(data:String):String{
var bytes:ByteArray;
bytes = decodeToByteArray(data);
return (bytes.readUTFBytes(bytes.length));
}
public static function decodeToByteArray(data:String):ByteArray{
var output:ByteArray;
var dataBuffer:Array;
var outputBuffer:Array;
var i:uint;
var j:uint;
var k:uint;
output = new ByteArray();
dataBuffer = new Array(4);
outputBuffer = new Array(3);
i = 0;
while (i < data.length) {
j = 0;
while ((((j < 4)) && (((i + j) < data.length)))) {
dataBuffer[j] = BASE64_CHARS.indexOf(data.charAt((i + j)));
j++;
};
outputBuffer[0] = ((dataBuffer[0] << 2) + ((dataBuffer[1] & 48) >> 4));
outputBuffer[1] = (((dataBuffer[1] & 15) << 4) + ((dataBuffer[2] & 60) >> 2));
outputBuffer[2] = (((dataBuffer[2] & 3) << 6) + dataBuffer[3]);
k = 0;
while (k < outputBuffer.length) {
if (dataBuffer[(k + 1)] == 64){
break;
};
output.writeByte(outputBuffer[k]);
k++;
};
i = (i + 4);
};
output.position = 0;
return (output);
}
}
}//package com.hurlant.util
Section 57
//Hex (com.hurlant.util.Hex)
package com.hurlant.util {
import flash.utils.*;
public class Hex {
public function Hex(){
super();
}
public static function fromString(str:String, colons:Boolean=false):String{
var a:ByteArray;
a = new ByteArray();
a.writeUTFBytes(str);
return (fromArray(a, colons));
}
public static function toString(hex:String):String{
var a:ByteArray;
a = toArray(hex);
return (a.readUTFBytes(a.length));
}
public static function toArray(hex:String):ByteArray{
var a:ByteArray;
var i:uint;
hex = hex.replace(/\s|:/gm, "");
a = new ByteArray();
if ((hex.length & (1 == 1))){
hex = ("0" + hex);
};
i = 0;
while (i < hex.length) {
a[(i / 2)] = parseInt(hex.substr(i, 2), 16);
i = (i + 2);
};
return (a);
}
public static function fromArray(array:ByteArray, colons:Boolean=false):String{
var s:String;
var i:uint;
s = "";
i = 0;
while (i < array.length) {
s = (s + ("0" + array[i].toString(16)).substr(-2, 2));
if (colons){
if (i < (array.length - 1)){
s = (s + ":");
};
};
i++;
};
return (s);
}
}
}//package com.hurlant.util
Section 58
//Memory (com.hurlant.util.Memory)
package com.hurlant.util {
import flash.net.*;
import flash.system.*;
public class Memory {
public function Memory(){
super();
}
public static function gc():void{
new LocalConnection().connect("foo");
new LocalConnection().connect("foo");
//unresolved jump
var _slot1 = e;
}
public static function get used():uint{
return (System.totalMemory);
}
}
}//package com.hurlant.util
Section 59
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var contentspotid:String;
private var cpmstarLoader:Loader;
public function AdLoader(contentspotid:String){
super();
this.contentspotid = contentspotid;
addEventListener(Event.ADDED, addedHandler);
}
private function addedHandler(event:Event):void{
var cpmstarViewSWFUrl:String;
var container:DisplayObjectContainer;
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
cpmstarViewSWFUrl = "http://server.cpmstar.com/adviewas3.swf";
container = 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);
}
private function dispatchHandler(event:Event):void{
dispatchEvent(event);
}
}
}//package CPMStar
Section 60
//AttackCastleAnimData (creeps.AttackCastleAnimData)
package creeps {
public class AttackCastleAnimData {
public var currentFrame:Number;// = 1
public var array:Array;
public var totalFrames:Number;// = 7
public function AttackCastleAnimData(){
totalFrames = 7;
currentFrame = 1;
super();
this.array = new Array();
this.array[1] = {x:-2, y:-5};
this.array[2] = {x:-1, y:-5};
this.array[3] = {x:-1, y:-2};
this.array[4] = {x:1, y:6};
this.array[5] = {x:3, y:6};
this.array[6] = {x:0, y:0};
}
public function getY():Number{
return (this.array[this.currentFrame].y);
}
public function getX():Number{
return (this.array[this.currentFrame].x);
}
}
}//package creeps
Section 61
//CoinForDeath (creeps.CoinForDeath)
package creeps {
import flash.display.*;
import flash.events.*;
public class CoinForDeath extends MovieClip {
public function CoinForDeath(){
super();
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void{
if (this.currentFrame == this.totalFrames){
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
this.dispatchEvent(new Event("removeMe"));
};
}
}
}//package creeps
Section 62
//Creep (creeps.Creep)
package creeps {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import castle.*;
import flash.geom.*;
public class Creep extends MovieClip {
public var creep:MovieClip;
private var currentMoveIndex:Number;// = -1
public var bar:Bar;
private var isDieing:Boolean;// = false
public var exp:Number;// = 0
public var hitpoints:Number;// = 100
public var attack:MovieClip;
public var speed:Number;// = 3
private var rotationSpeed:Number;// = 30
public var totalHitpoints:Number;// = 100
public var damage:MovieClip;
public var death:MovieClip;
public var dieSound:String;// = "Die1"
public var freeze:MovieClip;
public var gold:Number;// = 20
public var mc:MovieClip;
private var movesArray:Array;
private var attackAnimData:AttackCastleAnimData;
public var damageToCastle:Number;// = 22
private var freezeTimer:Timer;
public function Creep(){
var dx:Number;
var dy:Number;
speed = 3;
rotationSpeed = 30;
damageToCastle = 22;
dieSound = "Die1";
isDieing = false;
currentMoveIndex = -1;
hitpoints = 100;
totalHitpoints = 100;
gold = 20;
exp = 0;
movesArray = new Array();
super();
trace("creep", this.rotation);
this.creep.damage.stop();
this.creep.death.stop();
this.creep.freeze.stop();
this.creep.attack.stop();
this.creep.attack.visible = false;
this.movesArray = new Array();
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
dx = Math.floor(((Math.random() * 5) - 3));
dy = Math.floor(((Math.random() * 5) - 3));
this.creep.x = (this.creep.x + dx);
this.creep.y = (this.creep.y + dy);
this.bar.x = (this.bar.x + dx);
this.bar.y = (this.bar.y + dy);
Global.gameManager.addEventListener("pauseGame", onPauseGame);
Global.gameManager.addEventListener("resumeGame", onResumeGame);
}
private function isPointReached(point:Point):Boolean{
if (this.x == point.x){
if (this.y == point.y){
return (true);
};
};
return (false);
}
private function onResumeGame(e:Event):void{
if (this.hitpoints > 0){
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
};
}
private function onPauseGame(e:Event):void{
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function addMove(point:Point):void{
if (this.currentMoveIndex == -1){
this.currentMoveIndex = 0;
};
this.movesArray.unshift(point);
}
private function onDeathEnterFrame(e:Event):void{
if (creep.death.currentFrame == creep.death.totalFrames){
creep.death.gotoAndStop(1);
this.creep.death.removeEventListener(Event.ENTER_FRAME, onDamageEnterFrame);
this.dispatchEvent(new Event("ImDead"));
};
}
public function attackCastle(d:Number):void{
this.creep.attack.visible = true;
this.creep.attack.play();
this.addEventListener(Event.ENTER_FRAME, onAttackCastleEnterFrame);
}
private function goToNextStep():void{
this.currentMoveIndex++;
if ((((this.currentMoveIndex >= this.movesArray.length)) && ((isDieing == false)))){
this.currentMoveIndex = -1;
this.attackCastle(this.damageToCastle);
};
}
public function prepareToDie():void{
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
this.removeEventListener(Event.ENTER_FRAME, onAttackCastleEnterFrame);
if (this.freezeTimer != null){
this.freezeTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onFreezeTimerComplete);
this.freezeTimer.stop();
this.freezeTimer = null;
};
Global.gameManager.removeEventListener("pauseGame", onPauseGame);
Global.gameManager.removeEventListener("resumeGame", onResumeGame);
}
private function onDamageEnterFrame(e:Event):void{
if (creep.damage.currentFrame == creep.damage.totalFrames){
creep.damage.gotoAndStop(1);
this.creep.damage.removeEventListener(Event.ENTER_FRAME, onDamageEnterFrame);
};
}
private function isAngelReached(angel:Number):Boolean{
if (this.creep.rotation == angel){
return (true);
};
return (false);
}
public function startMove(ar:Array):void{
this.movesArray = ar;
this.currentMoveIndex = 2;
}
private function onFreezeEnterFrame(e:Event):void{
if (creep.freeze.currentFrame == creep.freeze.totalFrames){
creep.freeze.gotoAndStop(1);
this.creep.freeze.removeEventListener(Event.ENTER_FRAME, onFreezeEnterFrame);
};
}
public function doFreeze(t:Number):void{
this.creep.freeze.play();
this.creep.freeze.addEventListener(Event.ENTER_FRAME, onFreezeEnterFrame);
if (Global.isDoubleSpeed == false){
this.freezeTimer = new Timer(t, 1);
} else {
this.freezeTimer = new Timer((t / 2), 1);
};
this.freezeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onFreezeTimerComplete);
this.freezeTimer.start();
}
private function onEnterFrame(e:Event):void{
var point:Point;
var angel:Number;
if (this.stage == null){
this.prepareToDie();
};
if (this.freezeTimer != null){
if (this.freezeTimer.running){
return;
};
};
if (this.currentMoveIndex == -1){
return;
};
if ((this.movesArray[this.currentMoveIndex] is Point)){
point = this.movesArray[this.currentMoveIndex];
if (this.isPointReached(point)){
this.goToNextStep();
return;
};
if (point.x == this.x){
if (point.y > this.y){
this.y = (this.y + this.speed);
} else {
if (point.y < this.y){
this.y = (this.y - this.speed);
};
};
} else {
if (this.x < point.x){
this.x = (this.x + speed);
} else {
if (this.x > point.x){
this.x = (this.x - speed);
};
};
};
};
if ((this.movesArray[this.currentMoveIndex] is Number)){
angel = this.movesArray[this.currentMoveIndex];
if (this.isAngelReached(angel)){
this.goToNextStep();
return;
};
if (((((angel - this.creep.rotation) <= 90)) && (((angel - this.creep.rotation) > 0)))){
this.creep.rotation = (this.creep.rotation + this.rotationSpeed);
} else {
if (angel != -90){
this.creep.rotation = (this.creep.rotation - this.rotationSpeed);
} else {
if (angel == -90){
if ((((this.creep.rotation > -90)) && ((this.creep.rotation < 90)))){
this.creep.rotation = (this.creep.rotation - this.rotationSpeed);
} else {
this.creep.rotation = (this.creep.rotation + this.rotationSpeed);
};
};
};
};
};
}
public function addTurn(angel:Number):void{
if (this.currentMoveIndex == -1){
this.currentMoveIndex = 0;
};
this.movesArray.unshift(angel);
}
private function onAttackCastleEnterFrame(e:Event):void{
if (creep.attack.currentFrame == creep.attack.totalFrames){
creep.attack.gotoAndStop(1);
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
Global.castle.doDamage(this.damageToCastle);
this.creep.attack.removeEventListener(Event.ENTER_FRAME, onAttackCastleEnterFrame);
this.dispatchEvent(new Event("ImAttack"));
};
}
public function doDamage(d:Number=10):void{
trace("creeps.Creep.doDamage", d);
this.hitpoints = (this.hitpoints - d);
this.bar.setValue(Math.floor(((this.hitpoints / this.totalHitpoints) * 100)));
if (this.hitpoints <= 0){
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
this.creep.death.play();
this.isDieing = true;
Global.soundManager.addDieSound(this.dieSound);
this.creep.mc.visible = false;
this.creep.death.addEventListener(Event.ENTER_FRAME, onDeathEnterFrame);
} else {
this.creep.damage.play();
this.creep.damage.addEventListener(Event.ENTER_FRAME, onDamageEnterFrame);
};
}
private function onFreezeTimerComplete(e:TimerEvent):void{
this.freezeTimer.stop();
this.freezeTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onFreezeTimerComplete);
}
}
}//package creeps
Section 63
//Creep1 (creeps.Creep1)
package creeps {
public class Creep1 extends Creep {
public function Creep1(){
super();
this.dieSound = "Die1";
}
}
}//package creeps
Section 64
//Creep2 (creeps.Creep2)
package creeps {
public class Creep2 extends Creep {
public function Creep2(){
super();
this.dieSound = "Die2";
}
}
}//package creeps
Section 65
//Creep3 (creeps.Creep3)
package creeps {
public class Creep3 extends Creep {
public function Creep3(){
super();
this.dieSound = "Die3";
}
}
}//package creeps
Section 66
//Creep4 (creeps.Creep4)
package creeps {
public class Creep4 extends Creep {
public function Creep4(){
super();
this.dieSound = "Die4";
}
}
}//package creeps
Section 67
//Creep5 (creeps.Creep5)
package creeps {
public class Creep5 extends Creep {
public function Creep5(){
super();
this.dieSound = "Die5";
}
}
}//package creeps
Section 68
//Creep6 (creeps.Creep6)
package creeps {
public class Creep6 extends Creep {
public function Creep6(){
super();
this.dieSound = "Die6";
}
}
}//package creeps
Section 69
//Creep7 (creeps.Creep7)
package creeps {
public class Creep7 extends Creep {
public function Creep7(){
super();
this.dieSound = "Die7";
}
}
}//package creeps
Section 70
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import fl.events.*;
public class BaseButton extends UIComponent {
protected var _selected:Boolean;// = false
private var unlockedMouseState:String;
protected var pressTimer:Timer;
protected var mouseState:String;
protected var background:DisplayObject;
private var _mouseStateLocked:Boolean;// = false
protected var _autoRepeat:Boolean;// = false
private static var defaultStyles:Object = {upSkin:"Button_upSkin", downSkin:"Button_downSkin", overSkin:"Button_overSkin", disabledSkin:"Button_disabledSkin", selectedDisabledSkin:"Button_selectedDisabledSkin", selectedUpSkin:"Button_selectedUpSkin", selectedDownSkin:"Button_selectedDownSkin", selectedOverSkin:"Button_selectedOverSkin", focusRectSkin:null, focusRectPadding:null, repeatDelay:500, repeatInterval:35};
public function BaseButton(){
_selected = false;
_autoRepeat = false;
_mouseStateLocked = false;
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
protected function endPress():void{
pressTimer.reset();
}
public function set mouseStateLocked(_arg1:Boolean):void{
_mouseStateLocked = _arg1;
if (_arg1 == false){
setMouseState(unlockedMouseState);
} else {
unlockedMouseState = mouseState;
};
}
public function get autoRepeat():Boolean{
return (_autoRepeat);
}
public function set autoRepeat(_arg1:Boolean):void{
_autoRepeat = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
mouseEnabled = _arg1;
}
public function get selected():Boolean{
return (_selected);
}
protected function mouseEventHandler(_arg1:MouseEvent):void{
if (_arg1.type == MouseEvent.MOUSE_DOWN){
setMouseState("down");
startPress();
} else {
if ((((_arg1.type == MouseEvent.ROLL_OVER)) || ((_arg1.type == MouseEvent.MOUSE_UP)))){
setMouseState("over");
endPress();
} else {
if (_arg1.type == MouseEvent.ROLL_OUT){
setMouseState("up");
endPress();
};
};
};
}
public function setMouseState(_arg1:String):void{
if (_mouseStateLocked){
unlockedMouseState = _arg1;
return;
};
if (mouseState == _arg1){
return;
};
mouseState = _arg1;
invalidate(InvalidationType.STATE);
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function buttonDown(_arg1:TimerEvent):void{
if (!_autoRepeat){
endPress();
return;
};
if (pressTimer.currentCount == 1){
pressTimer.delay = Number(getStyleValue("repeatInterval"));
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
public function set selected(_arg1:Boolean):void{
if (_selected == _arg1){
return;
};
_selected = _arg1;
invalidate(InvalidationType.STATE);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function setupMouseEvents():void{
addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
}
protected function drawLayout():void{
background.width = width;
background.height = height;
}
protected function drawBackground():void{
var _local1:String;
var _local2:DisplayObject;
_local1 = (enabled) ? mouseState : "disabled";
if (selected){
_local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
};
_local1 = (_local1 + "Skin");
_local2 = background;
background = getDisplayObjectInstance(getStyleValue(_local1));
addChildAt(background, 0);
if (((!((_local2 == null))) && (!((_local2 == background))))){
removeChild(_local2);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 71
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.core.*;
import fl.managers.*;
public class Button extends LabelButton implements IFocusManagerComponent {
protected var emphasizedBorder:DisplayObject;
protected var _emphasized:Boolean;// = false
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function Button(){
_emphasized = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
var _local3:*;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("emphasizedPadding"));
if ((((_local2 < 0)) || (!(_emphasized)))){
_local2 = 0;
};
_local3 = getStyleValue("focusRectPadding");
_local3 = ((_local3)==null) ? 2 : _local3;
_local3 = (_local3 + _local2);
uiFocusRect.x = -(_local3);
uiFocusRect.y = -(_local3);
uiFocusRect.width = (width + (_local3 * 2));
uiFocusRect.height = (height + (_local3 * 2));
};
}
public function set emphasized(_arg1:Boolean):void{
_emphasized = _arg1;
invalidate(InvalidationType.STYLES);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
public function get emphasized():Boolean{
return (_emphasized);
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
protected function drawEmphasized():void{
var _local1:Object;
var _local2:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
_local1 = getStyleValue("emphasizedSkin");
if (_local1 != null){
emphasizedBorder = getDisplayObjectInstance(_local1);
};
if (emphasizedBorder != null){
addChildAt(emphasizedBorder, 0);
_local2 = Number(getStyleValue("emphasizedPadding"));
emphasizedBorder.x = (emphasizedBorder.y = -(_local2));
emphasizedBorder.width = (width + (_local2 * 2));
emphasizedBorder.height = (height + (_local2 * 2));
};
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 72
//ButtonLabelPlacement (fl.controls.ButtonLabelPlacement)
package fl.controls {
public class ButtonLabelPlacement {
public static const TOP:String = "top";
public static const LEFT:String = "left";
public static const BOTTOM:String = "bottom";
public static const RIGHT:String = "right";
}
}//package fl.controls
Section 73
//CheckBox (fl.controls.CheckBox)
package fl.controls {
import flash.display.*;
public class CheckBox extends LabelButton {
private static var defaultStyles:Object = {icon:null, upIcon:"CheckBox_upIcon", downIcon:"CheckBox_downIcon", overIcon:"CheckBox_overIcon", disabledIcon:"CheckBox_disabledIcon", selectedDisabledIcon:"CheckBox_selectedDisabledIcon", focusRectSkin:null, focusRectPadding:null, selectedUpIcon:"CheckBox_selectedUpIcon", selectedDownIcon:"CheckBox_selectedDownIcon", selectedOverIcon:"CheckBox_selectedOverIcon", textFormat:null, disabledTextFormat:null, embedFonts:null, textPadding:5};
public static var createAccessibilityImplementation:Function;
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = (background.x - _local2);
uiFocusRect.y = (background.y - _local2);
uiFocusRect.width = (background.width + (_local2 << 1));
uiFocusRect.height = (background.height + (_local2 << 1));
};
}
override public function get autoRepeat():Boolean{
return (false);
}
override public function set autoRepeat(_arg1:Boolean):void{
}
override public function set toggle(_arg1:Boolean):void{
throw (new Error("Warning: You cannot change a CheckBox's toggle."));
}
override public function get toggle():Boolean{
return (true);
}
override protected function configUI():void{
var _local1:Shape;
var _local2:Graphics;
super.configUI();
super.toggle = true;
_local1 = new Shape();
_local2 = _local1.graphics;
_local2.beginFill(0, 0);
_local2.drawRect(0, 0, 100, 100);
_local2.endFill();
background = (_local1 as DisplayObject);
addChildAt(background, 0);
}
override protected function drawLayout():void{
var _local1:Number;
super.drawLayout();
_local1 = Number(getStyleValue("textPadding"));
switch (_labelPlacement){
case ButtonLabelPlacement.RIGHT:
icon.x = _local1;
textField.x = (icon.x + (icon.width + _local1));
background.width = ((textField.x + textField.width) + _local1);
background.height = (Math.max(textField.height, icon.height) + (_local1 * 2));
break;
case ButtonLabelPlacement.LEFT:
icon.x = ((width - icon.width) - _local1);
textField.x = (((width - icon.width) - (_local1 * 2)) - textField.width);
background.width = ((textField.width + icon.width) + (_local1 * 3));
background.height = (Math.max(textField.height, icon.height) + (_local1 * 2));
break;
case ButtonLabelPlacement.TOP:
case ButtonLabelPlacement.BOTTOM:
background.width = (Math.max(textField.width, icon.width) + (_local1 * 2));
background.height = ((textField.height + icon.height) + (_local1 * 3));
break;
};
background.x = Math.min((icon.x - _local1), (textField.x - _local1));
background.y = Math.min((icon.y - _local1), (textField.y - _local1));
}
override protected function drawBackground():void{
}
override protected function initializeAccessibility():void{
if (CheckBox.createAccessibilityImplementation != null){
CheckBox.createAccessibilityImplementation(this);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 74
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var mode:String;// = "center"
public var textField:TextField;
protected var _label:String;// = "Label"
private static var defaultStyles:Object = {icon:null, upIcon:null, downIcon:null, overIcon:null, disabledIcon:null, selectedDisabledIcon:null, selectedUpIcon:null, selectedDownIcon:null, selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function LabelButton(){
_labelPlacement = ButtonLabelPlacement.RIGHT;
_toggle = false;
_label = "Label";
mode = "center";
super();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
public function get labelPlacement():String{
return (_labelPlacement);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set toggle(_arg1:Boolean):void{
if (((!(_arg1)) && (super.selected))){
selected = false;
};
_toggle = _arg1;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
public function get label():String{
return (_label);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
public function get toggle():Boolean{
return (_toggle);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
_local3 = (textField.textWidth + 4);
_local4 = (textField.textHeight + 4);
_local5 = ((icon)==null) ? 0 : (icon.width + _local1);
_local6 = ((icon)==null) ? 0 : (icon.height + _local1);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
_local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
if ((height - 2) > _local4){
_local8 = _local4;
} else {
_local8 = (height - 2);
};
_local3 = _local7;
textField.width = _local3;
_local4 = _local8;
textField.height = _local4;
textField.x = Math.round(((width - _local3) / 2));
textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
if (icon != null){
icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
};
} else {
_local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
_local3 = _local7;
textField.width = _local3;
textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
};
};
};
super.drawLayout();
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
protected function drawIcon():void{
var _local1:DisplayObject;
var _local2:String;
var _local3:Object;
_local1 = icon;
_local2 = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
_local3 = getStyleValue(_local2);
if (_local3 == null){
_local3 = getStyleValue("icon");
};
if (_local3 != null){
icon = getDisplayObjectInstance(_local3);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((_local1 == null))) && (!((_local1 == icon))))){
removeChild(_local1);
};
}
public function set label(_arg1:String):void{
_label = _arg1;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 75
//RadioButton (fl.controls.RadioButton)
package fl.controls {
import flash.display.*;
import flash.events.*;
import fl.managers.*;
import flash.ui.*;
public class RadioButton extends LabelButton implements IFocusManagerGroup {
protected var _value:Object;
protected var defaultGroupName:String;// = "RadioButtonGroup"
protected var _group:RadioButtonGroup;
private static var defaultStyles:Object = {icon:null, upIcon:"RadioButton_upIcon", downIcon:"RadioButton_downIcon", overIcon:"RadioButton_overIcon", disabledIcon:"RadioButton_disabledIcon", selectedDisabledIcon:"RadioButton_selectedDisabledIcon", selectedUpIcon:"RadioButton_selectedUpIcon", selectedDownIcon:"RadioButton_selectedDownIcon", selectedOverIcon:"RadioButton_selectedOverIcon", focusRectSkin:null, focusRectPadding:null, textFormat:null, disabledTextFormat:null, embedFonts:null, textPadding:5};
public static var createAccessibilityImplementation:Function;
public function RadioButton(){
defaultGroupName = "RadioButtonGroup";
super();
mode = "border";
groupName = defaultGroupName;
}
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = (background.x - _local2);
uiFocusRect.y = (background.y - _local2);
uiFocusRect.width = (background.width + (_local2 * 2));
uiFocusRect.height = (background.height + (_local2 * 2));
};
}
private function setThis():void{
var _local1:RadioButtonGroup;
_local1 = _group;
if (_local1 != null){
if (_local1.selection != this){
_local1.selection = this;
};
} else {
super.selected = true;
};
}
override public function get autoRepeat():Boolean{
return (false);
}
override public function set autoRepeat(_arg1:Boolean):void{
}
protected function handleClick(_arg1:MouseEvent):void{
if (_group == null){
return;
};
_group.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true));
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case Keyboard.DOWN:
setNext(!(_arg1.ctrlKey));
_arg1.stopPropagation();
break;
case Keyboard.UP:
setPrev(!(_arg1.ctrlKey));
_arg1.stopPropagation();
break;
case Keyboard.LEFT:
setPrev(!(_arg1.ctrlKey));
_arg1.stopPropagation();
break;
case Keyboard.RIGHT:
setNext(!(_arg1.ctrlKey));
_arg1.stopPropagation();
break;
case Keyboard.SPACE:
setThis();
_toggle = false;
default:
super.keyDownHandler(_arg1);
break;
};
}
private function setNext(_arg1:Boolean=true):void{
var _local2:RadioButtonGroup;
var _local3:IFocusManager;
var _local4:int;
var _local5:Number;
var _local6:int;
var _local7:*;
_local2 = _group;
if (_local2 == null){
return;
};
_local3 = focusManager;
if (_local3){
_local3.showFocusIndicator = true;
};
_local4 = _local2.getRadioButtonIndex(this);
_local5 = _local2.numRadioButtons;
_local6 = _local4;
if (_local4 != -1){
do {
_local6++;
_local6 = ((_local6)>(_local2.numRadioButtons - 1)) ? 0 : _local6;
_local7 = _local2.getRadioButtonAt(_local6);
if (((_local7) && (_local7.enabled))){
if (_arg1){
_local2.selection = _local7;
};
_local7.setFocus();
return;
};
if (((_arg1) && (!((_local2.getRadioButtonAt(_local6) == _local2.selection))))){
_local2.selection = this;
};
this.drawFocus(true);
} while (_local6 != _local4);
};
}
public function get group():RadioButtonGroup{
return (_group);
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
super.keyUpHandler(_arg1);
if ((((_arg1.keyCode == Keyboard.SPACE)) && (!(_toggle)))){
_toggle = true;
};
}
override public function get selected():Boolean{
return (super.selected);
}
override public function set toggle(_arg1:Boolean):void{
throw (new Error("Warning: You cannot change a RadioButtons toggle."));
}
public function set value(_arg1:Object):void{
_value = _arg1;
}
public function set group(_arg1:RadioButtonGroup):void{
groupName = _arg1.name;
}
override public function set selected(_arg1:Boolean):void{
if ((((_arg1 == false)) || (selected))){
return;
};
if (_group != null){
_group.selection = this;
} else {
super.selected = _arg1;
};
}
override protected function draw():void{
super.draw();
}
override public function get toggle():Boolean{
return (true);
}
override protected function configUI():void{
var _local1:Shape;
var _local2:Graphics;
super.configUI();
super.toggle = true;
_local1 = new Shape();
_local2 = _local1.graphics;
_local2.beginFill(0, 0);
_local2.drawRect(0, 0, 100, 100);
_local2.endFill();
background = (_local1 as DisplayObject);
addChildAt(background, 0);
addEventListener(MouseEvent.CLICK, handleClick, false, 0, true);
}
public function set groupName(_arg1:String):void{
if (_group != null){
_group.removeRadioButton(this);
_group.removeEventListener(Event.CHANGE, handleChange);
};
_group = ((_arg1)==null) ? null : RadioButtonGroup.getGroup(_arg1);
if (_group != null){
_group.addRadioButton(this);
_group.addEventListener(Event.CHANGE, handleChange, false, 0, true);
};
}
public function get value():Object{
return (_value);
}
override protected function drawLayout():void{
var _local1:Number;
super.drawLayout();
_local1 = Number(getStyleValue("textPadding"));
switch (_labelPlacement){
case ButtonLabelPlacement.RIGHT:
icon.x = _local1;
textField.x = (icon.x + (icon.width + _local1));
background.width = ((textField.x + textField.width) + _local1);
background.height = (Math.max(textField.height, icon.height) + (_local1 * 2));
break;
case ButtonLabelPlacement.LEFT:
icon.x = ((width - icon.width) - _local1);
textField.x = (((width - icon.width) - (_local1 * 2)) - textField.width);
background.width = ((textField.width + icon.width) + (_local1 * 3));
background.height = (Math.max(textField.height, icon.height) + (_local1 * 2));
break;
case ButtonLabelPlacement.TOP:
case ButtonLabelPlacement.BOTTOM:
background.width = (Math.max(textField.width, icon.width) + (_local1 * 2));
background.height = ((textField.height + icon.height) + (_local1 * 3));
break;
};
background.x = Math.min((icon.x - _local1), (textField.x - _local1));
background.y = Math.min((icon.y - _local1), (textField.y - _local1));
}
override protected function drawBackground():void{
}
override protected function initializeAccessibility():void{
if (RadioButton.createAccessibilityImplementation != null){
RadioButton.createAccessibilityImplementation(this);
};
}
public function get groupName():String{
return (((_group)==null) ? null : _group.name);
}
private function setPrev(_arg1:Boolean=true):void{
var _local2:RadioButtonGroup;
var _local3:IFocusManager;
var _local4:int;
var _local5:int;
var _local6:*;
_local2 = _group;
if (_local2 == null){
return;
};
_local3 = focusManager;
if (_local3){
_local3.showFocusIndicator = true;
};
_local4 = _local2.getRadioButtonIndex(this);
_local5 = _local4;
if (_local4 != -1){
do {
--_local5;
_local5 = ((_local5)==-1) ? (_local2.numRadioButtons - 1) : _local5;
_local6 = _local2.getRadioButtonAt(_local5);
if (((_local6) && (_local6.enabled))){
if (_arg1){
_local2.selection = _local6;
};
_local6.setFocus();
return;
};
if (((_arg1) && (!((_local2.getRadioButtonAt(_local5) == _local2.selection))))){
_local2.selection = this;
};
this.drawFocus(true);
} while (_local5 != _local4);
};
}
protected function handleChange(_arg1:Event):void{
super.selected = (_group.selection == this);
dispatchEvent(new Event(Event.CHANGE, true));
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 76
//RadioButtonGroup (fl.controls.RadioButtonGroup)
package fl.controls {
import flash.events.*;
public class RadioButtonGroup extends EventDispatcher {
protected var _selection:RadioButton;
protected var radioButtons:Array;
protected var _name:String;
private static var groups:Object;
private static var groupCount:uint = 0;
public function RadioButtonGroup(_arg1:String){
_name = _arg1;
radioButtons = [];
registerGroup(this);
}
public function getRadioButtonIndex(_arg1:RadioButton):int{
var _local2:int;
var _local3:RadioButton;
_local2 = 0;
while (_local2 < radioButtons.length) {
_local3 = (radioButtons[_local2] as RadioButton);
if (_local3 == _arg1){
return (_local2);
};
_local2++;
};
return (-1);
}
public function get numRadioButtons():int{
return (radioButtons.length);
}
public function get name():String{
return (_name);
}
public function get selection():RadioButton{
return (_selection);
}
public function set selection(_arg1:RadioButton):void{
if ((((((_selection == _arg1)) || ((_arg1 == null)))) || ((getRadioButtonIndex(_arg1) == -1)))){
return;
};
_selection = _arg1;
dispatchEvent(new Event(Event.CHANGE, true));
}
public function set selectedData(_arg1:Object):void{
var _local2:int;
var _local3:RadioButton;
_local2 = 0;
while (_local2 < radioButtons.length) {
_local3 = (radioButtons[_local2] as RadioButton);
if (_local3.value == _arg1){
selection = _local3;
return;
};
_local2++;
};
}
public function removeRadioButton(_arg1:RadioButton):void{
var _local2:int;
_local2 = getRadioButtonIndex(_arg1);
if (_local2 != -1){
radioButtons.splice(_local2, 1);
};
if (_selection == _arg1){
_selection = null;
};
}
public function addRadioButton(_arg1:RadioButton):void{
if (_arg1.groupName != name){
_arg1.groupName = name;
return;
};
radioButtons.push(_arg1);
if (_arg1.selected){
selection = _arg1;
};
}
public function getRadioButtonAt(_arg1:int):RadioButton{
return (RadioButton(radioButtons[_arg1]));
}
public function get selectedData():Object{
var _local1:RadioButton;
_local1 = _selection;
return (((_local1)==null) ? null : _local1.value);
}
public static function getGroup(_arg1:String):RadioButtonGroup{
var _local2:RadioButtonGroup;
if (groups == null){
groups = {};
};
_local2 = (groups[_arg1] as RadioButtonGroup);
if (_local2 == null){
_local2 = new RadioButtonGroup(_arg1);
if ((++groupCount % 20) == 0){
cleanUpGroups();
};
};
return (_local2);
}
private static function registerGroup(_arg1:RadioButtonGroup):void{
if (groups == null){
groups = {};
};
groups[_arg1.name] = _arg1;
}
private static function cleanUpGroups():void{
var _local1:String;
var _local2:RadioButtonGroup;
for (_local1 in groups) {
_local2 = (groups[_local1] as RadioButtonGroup);
if (_local2.radioButtons.length == 0){
delete groups[_local1];
};
};
}
}
}//package fl.controls
Section 77
//Slider (fl.controls.Slider)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import fl.events.*;
import flash.ui.*;
public class Slider extends UIComponent implements IFocusManagerComponent {
protected var _direction:String;
protected var _liveDragging:Boolean;// = false
protected var _value:Number;// = 0
protected var _snapInterval:Number;// = 0
protected var _minimum:Number;// = 0
protected var _maximum:Number;// = 10
protected var track:BaseButton;
protected var _tickInterval:Number;// = 0
protected var tickContainer:Sprite;
protected var thumb:BaseButton;
protected static const TICK_STYLES:Object = {upSkin:"tickSkin"};
protected static const TRACK_STYLES:Object = {upSkin:"sliderTrackSkin", overSkin:"sliderTrackSkin", downSkin:"sliderTrackSkin", disabledSkin:"sliderTrackDisabledSkin"};
protected static const THUMB_STYLES:Object = {upSkin:"thumbUpSkin", overSkin:"thumbOverSkin", downSkin:"thumbDownSkin", disabledSkin:"thumbDisabledSkin"};
protected static var defaultStyles:Object = {thumbUpSkin:"SliderThumb_upSkin", thumbOverSkin:"SliderThumb_overSkin", thumbDownSkin:"SliderThumb_downSkin", thumbDisabledSkin:"SliderThumb_disabledSkin", sliderTrackSkin:"SliderTrack_skin", sliderTrackDisabledSkin:"SliderTrack_disabledSkin", tickSkin:"SliderTick_skin", focusRectSkin:null, focusRectPadding:null};
public function Slider(){
_direction = SliderDirection.HORIZONTAL;
_minimum = 0;
_maximum = 10;
_value = 0;
_tickInterval = 0;
_snapInterval = 0;
_liveDragging = false;
super();
setStyles();
}
public function get minimum():Number{
return (_minimum);
}
public function set minimum(_arg1:Number):void{
_minimum = _arg1;
this.value = Math.max(_arg1, this.value);
invalidate(InvalidationType.DATA);
}
public function get maximum():Number{
return (_maximum);
}
protected function positionThumb():void{
thumb.x = ((((_direction)==SliderDirection.VERTICAL) ? ((maximum - minimum) - value) : (value - minimum) / (maximum - minimum)) * _width);
}
protected function clearTicks():void{
if (((!(tickContainer)) || (!(tickContainer.parent)))){
return;
};
removeChild(tickContainer);
}
protected function onTrackClick(_arg1:MouseEvent):void{
calculateValue(track.mouseX, InteractionInputType.MOUSE, SliderEventClickTarget.TRACK);
if (!liveDragging){
dispatchEvent(new SliderEvent(SliderEvent.CHANGE, value, SliderEventClickTarget.TRACK, InteractionInputType.MOUSE));
};
}
public function set maximum(_arg1:Number):void{
_maximum = _arg1;
this.value = Math.min(_arg1, this.value);
invalidate(InvalidationType.DATA);
}
public function get liveDragging():Boolean{
return (_liveDragging);
}
protected function doDrag(_arg1:MouseEvent):void{
var _local2:Number;
var _local3:Number;
_local2 = (_width / snapInterval);
_local3 = track.mouseX;
calculateValue(_local3, InteractionInputType.MOUSE, SliderEventClickTarget.THUMB);
dispatchEvent(new SliderEvent(SliderEvent.THUMB_DRAG, value, SliderEventClickTarget.THUMB, InteractionInputType.MOUSE));
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:uint;
var _local3:Number;
var _local4:Boolean;
if (!enabled){
return;
};
_local2 = ((snapInterval)>0) ? snapInterval : 1;
_local4 = (direction == SliderDirection.HORIZONTAL);
if ((((((_arg1.keyCode == Keyboard.DOWN)) && (!(_local4)))) || ((((_arg1.keyCode == Keyboard.LEFT)) && (_local4))))){
_local3 = (value - _local2);
} else {
if ((((((_arg1.keyCode == Keyboard.UP)) && (!(_local4)))) || ((((_arg1.keyCode == Keyboard.RIGHT)) && (_local4))))){
_local3 = (value + _local2);
} else {
if ((((((_arg1.keyCode == Keyboard.PAGE_DOWN)) && (!(_local4)))) || ((((_arg1.keyCode == Keyboard.HOME)) && (_local4))))){
_local3 = minimum;
} else {
if ((((((_arg1.keyCode == Keyboard.PAGE_UP)) && (!(_local4)))) || ((((_arg1.keyCode == Keyboard.END)) && (_local4))))){
_local3 = maximum;
};
};
};
};
if (!isNaN(_local3)){
_arg1.stopPropagation();
doSetValue(_local3, InteractionInputType.KEYBOARD, null, _arg1.keyCode);
};
}
override public function set enabled(_arg1:Boolean):void{
if (enabled == _arg1){
return;
};
super.enabled = _arg1;
track.enabled = (thumb.enabled = _arg1);
}
protected function thumbPressHandler(_arg1:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, doDrag, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbReleaseHandler, false, 0, true);
dispatchEvent(new SliderEvent(SliderEvent.THUMB_PRESS, value, InteractionInputType.MOUSE, SliderEventClickTarget.THUMB));
}
public function get snapInterval():Number{
return (_snapInterval);
}
protected function thumbReleaseHandler(_arg1:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, doDrag);
stage.removeEventListener(MouseEvent.MOUSE_UP, thumbReleaseHandler);
dispatchEvent(new SliderEvent(SliderEvent.THUMB_RELEASE, value, InteractionInputType.MOUSE, SliderEventClickTarget.THUMB));
dispatchEvent(new SliderEvent(SliderEvent.CHANGE, value, SliderEventClickTarget.THUMB, InteractionInputType.MOUSE));
}
public function set liveDragging(_arg1:Boolean):void{
_liveDragging = _arg1;
}
public function set value(_arg1:Number):void{
doSetValue(_arg1);
}
public function set direction(_arg1:String):void{
var _local2:Boolean;
_direction = _arg1;
_local2 = (_direction == SliderDirection.VERTICAL);
if (isLivePreview){
if (_local2){
setScaleY(-1);
y = track.height;
} else {
setScaleY(1);
y = 0;
};
positionThumb();
return;
};
if (((_local2) && (componentInspectorSetting))){
if ((rotation % 90) == 0){
setScaleY(-1);
};
};
if (!componentInspectorSetting){
rotation = (_local2) ? 90 : 0;
};
}
public function set tickInterval(_arg1:Number):void{
_tickInterval = _arg1;
invalidate(InvalidationType.SIZE);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES)){
setStyles();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
track.setSize(_width, track.height);
track.drawNow();
thumb.drawNow();
};
if (tickInterval > 0){
drawTicks();
} else {
clearTicks();
};
positionThumb();
super.draw();
}
override protected function configUI():void{
super.configUI();
thumb = new BaseButton();
thumb.setSize(13, 13);
thumb.autoRepeat = false;
addChild(thumb);
thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbPressHandler, false, 0, true);
track = new BaseButton();
track.move(0, 0);
track.setSize(80, 4);
track.autoRepeat = false;
track.useHandCursor = false;
track.addEventListener(MouseEvent.CLICK, onTrackClick, false, 0, true);
addChildAt(track, 0);
}
public function set snapInterval(_arg1:Number):void{
_snapInterval = _arg1;
}
public function get value():Number{
return (_value);
}
public function get direction():String{
return (_direction);
}
public function get tickInterval():Number{
return (_tickInterval);
}
override public function setSize(_arg1:Number, _arg2:Number):void{
if ((((_direction == SliderDirection.VERTICAL)) && (!(isLivePreview)))){
super.setSize(_arg2, _arg1);
} else {
super.setSize(_arg1, _arg2);
};
invalidate(InvalidationType.SIZE);
}
protected function drawTicks():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:uint;
var _local5:DisplayObject;
clearTicks();
tickContainer = new Sprite();
_local1 = ((maximum)<1) ? (tickInterval / 100) : tickInterval;
_local2 = ((maximum - minimum) / _local1);
_local3 = (_width / _local2);
_local4 = 0;
while (_local4 <= _local2) {
_local5 = getDisplayObjectInstance(getStyleValue("tickSkin"));
_local5.x = (_local3 * _local4);
_local5.y = ((track.y - _local5.height) - 2);
tickContainer.addChild(_local5);
_local4++;
};
addChild(tickContainer);
}
protected function calculateValue(_arg1:Number, _arg2:String, _arg3:String, _arg4:int=undefined):void{
var _local5:Number;
_local5 = ((_arg1 / _width) * (maximum - minimum));
if (_direction == SliderDirection.VERTICAL){
_local5 = (maximum - _local5);
} else {
_local5 = (minimum + _local5);
};
doSetValue(_local5, _arg2, _arg3, _arg4);
}
protected function getPrecision(_arg1:Number):Number{
var _local2:String;
_local2 = _arg1.toString();
if (_local2.indexOf(".") == -1){
return (0);
};
return (_local2.split(".").pop().length);
}
protected function doSetValue(_arg1:Number, _arg2:String=null, _arg3:String=null, _arg4:int=undefined):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local5 = _value;
if (((!((_snapInterval == 0))) && (!((_snapInterval == 1))))){
_local6 = Math.pow(10, getPrecision(snapInterval));
_local7 = (_snapInterval * _local6);
_local8 = Math.round((_arg1 * _local6));
_local9 = (Math.round((_local8 / _local7)) * _local7);
_arg1 = (_local9 / _local6);
_value = Math.max(minimum, Math.min(maximum, _arg1));
} else {
_value = Math.max(minimum, Math.min(maximum, Math.round(_arg1)));
};
if (((!((_local5 == _value))) && (((((liveDragging) && (!((_arg3 == null))))) || ((_arg2 == InteractionInputType.KEYBOARD)))))){
dispatchEvent(new SliderEvent(SliderEvent.CHANGE, value, _arg3, _arg2, _arg4));
};
positionThumb();
}
protected function setStyles():void{
copyStylesToChild(thumb, THUMB_STYLES);
copyStylesToChild(track, TRACK_STYLES);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 78
//SliderDirection (fl.controls.SliderDirection)
package fl.controls {
public class SliderDirection {
public static var HORIZONTAL:String = "horizontal";
public static var VERTICAL:String = "vertical";
}
}//package fl.controls
Section 79
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 80
//InvalidationType (fl.core.InvalidationType)
package fl.core {
public class InvalidationType {
public static const SIZE:String = "size";
public static const ALL:String = "all";
public static const DATA:String = "data";
public static const SCROLL:String = "scroll";
public static const STATE:String = "state";
public static const STYLES:String = "styles";
public static const SELECTED:String = "selected";
public static const RENDERER_STYLES:String = "rendererStyles";
}
}//package fl.core
Section 81
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
import flash.system.*;
public class UIComponent extends Sprite {
protected var _enabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var _oldIMEMode:String;// = null
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var uiFocusRect:DisplayObject;
protected var _width:Number;
public var version:String;// = "3.0.0.15"
protected var isFocused:Boolean;// = false
protected var callLaterMethods:Dictionary;
private var _focusEnabled:Boolean;// = true
private var tempText:TextField;
protected var invalidateFlag:Boolean;// = false
protected var _inspector:Boolean;// = false
protected var sharedStyles:Object;
protected var invalidHash:Object;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var instanceStyles:Object;
protected var _x:Number;
protected var _y:Number;
public static var inCallLaterPhase:Boolean = false;
private static var defaultStyles:Object = {focusRectSkin:"focusRectSkin", focusRectPadding:2, textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)};
public static var createAccessibilityImplementation:Function;
private static var focusManagers:Dictionary = new Dictionary(false);
public function UIComponent(){
version = "3.0.0.15";
isLivePreview = false;
invalidateFlag = false;
_enabled = true;
isFocused = false;
_focusEnabled = true;
_mouseFocusEnabled = true;
_imeMode = null;
_oldIMEMode = null;
errorCaught = false;
_inspector = false;
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
isFocused = _arg1;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (_arg1){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(_local2);
uiFocusRect.y = -(_local2);
uiFocusRect.width = (width + (_local2 * 2));
uiFocusRect.height = (height + (_local2 * 2));
addChildAt(uiFocusRect, 0);
};
}
private function callLaterDispatcher(_arg1:Event):void{
var _local2:Dictionary;
var _local3:Object;
if (_arg1.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
_arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
_local2 = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (isOurFocus((_arg1.target as DisplayObject))){
_local2 = focusManager;
if (((_local2) && (_local2.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
public function setStyle(_arg1:String, _arg2:Object):void{
if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
instanceStyles[_arg1] = _arg2;
invalidate(InvalidationType.STYLES);
}
override public function get visible():Boolean{
return (super.visible);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
protected function setIMEMode(_arg1:Boolean){
var enabled = _arg1;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
try {
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
} catch(e:Error) {
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
};
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSharedStyle(_arg1:String, _arg2:Object):void{
if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
sharedStyles[_arg1] = _arg2;
if (instanceStyles[_arg1] == null){
invalidate(InvalidationType.STYLES);
};
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set scaleX(_arg1:Number):void{
setSize((startWidth * _arg1), height);
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
override public function set scaleY(_arg1:Number):void{
setSize(width, (startHeight * _arg1));
}
protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
var classDef:Object;
var skin = _arg1;
classDef = null;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
try {
classDef = getDefinitionByName(skin.toString());
} catch(e:Error) {
try {
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
} catch(e:Error) {
};
};
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
var _local3:String;
for (_local3 in _arg2) {
_arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
};
}
protected function beforeComponentParameters():void{
}
protected function callLater(_arg1:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[_arg1] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
override public function set visible(_arg1:Boolean):void{
var _local2:String;
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
_local2 = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function hookAccessibility(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
public function set componentInspectorSetting(_arg1:Boolean):void{
_inspector = _arg1;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
override public function set y(_arg1:Number):void{
move(_x, _arg1);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function focusOutHandler(_arg1:FocusEvent):void{
if (isOurFocus((_arg1.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
public function set mouseFocusEnabled(_arg1:Boolean):void{
_mouseFocusEnabled = _arg1;
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function validate():void{
invalidHash = {};
}
override public function get height():Number{
return (_height);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
public function get enabled():Boolean{
return (_enabled);
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function getScaleY():Number{
return (super.scaleY);
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
protected function afterComponentParameters():void{
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function configUI():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
isLivePreview = checkLivePreview();
_local1 = rotation;
rotation = 0;
_local2 = super.width;
_local3 = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(_local2, _local3);
move(super.x, super.y);
rotation = _local1;
startWidth = _local2;
startHeight = _local3;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
protected function setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
public function set focusManager(_arg1:IFocusManager):void{
UIComponent.focusManagers[this] = _arg1;
}
public function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
protected function isInvalid(_arg1:String, ... _args):Boolean{
if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject;
_local1 = this;
while (_local1) {
if (UIComponent.focusManagers[_local1] != null){
return (IFocusManager(UIComponent.focusManagers[_local1]));
};
_local1 = _local1.parent;
};
return (null);
}
override public function get width():Number{
return (_width);
}
public function move(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
super.x = Math.round(_arg1);
super.y = Math.round(_arg2);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local2:Object;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:String;
_local2 = {};
_local3 = _args.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 82
//ComponentEvent (fl.events.ComponentEvent)
package fl.events {
import flash.events.*;
public class ComponentEvent extends Event {
public static const HIDE:String = "hide";
public static const BUTTON_DOWN:String = "buttonDown";
public static const MOVE:String = "move";
public static const RESIZE:String = "resize";
public static const ENTER:String = "enter";
public static const LABEL_CHANGE:String = "labelChange";
public static const SHOW:String = "show";
public function ComponentEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function toString():String{
return (formatToString("ComponentEvent", "type", "bubbles", "cancelable"));
}
override public function clone():Event{
return (new ComponentEvent(type, bubbles, cancelable));
}
}
}//package fl.events
Section 83
//InteractionInputType (fl.events.InteractionInputType)
package fl.events {
public class InteractionInputType {
public static const MOUSE:String = "mouse";
public static const KEYBOARD:String = "keyboard";
}
}//package fl.events
Section 84
//SliderEvent (fl.events.SliderEvent)
package fl.events {
import flash.events.*;
public class SliderEvent extends Event {
protected var _triggerEvent:String;
protected var _keyCode:Number;
protected var _value:Number;
protected var _clickTarget:String;
public static const CHANGE:String = "change";
public static const THUMB_PRESS:String = "thumbPress";
public static const THUMB_DRAG:String = "thumbDrag";
public static const THUMB_RELEASE:String = "thumbRelease";
public function SliderEvent(_arg1:String, _arg2:Number, _arg3:String, _arg4:String, _arg5:int=0){
_value = _arg2;
_keyCode = _arg5;
_triggerEvent = _arg4;
_clickTarget = _arg3;
super(_arg1);
}
public function get clickTarget():String{
return (_clickTarget);
}
override public function clone():Event{
return (new SliderEvent(type, _value, _clickTarget, _triggerEvent, _keyCode));
}
override public function toString():String{
return (formatToString("SliderEvent", "type", "value", "bubbles", "cancelable", "keyCode", "triggerEvent", "clickTarget"));
}
public function get triggerEvent():String{
return (_triggerEvent);
}
public function get value():Number{
return (_value);
}
public function get keyCode():Number{
return (_keyCode);
}
}
}//package fl.events
Section 85
//SliderEventClickTarget (fl.events.SliderEventClickTarget)
package fl.events {
public class SliderEventClickTarget {
public static const TRACK:String = "track";
public static const THUMB:String = "thumb";
}
}//package fl.events
Section 86
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
activated = false;
calculateCandidates = true;
_showFocusIndicator = true;
_defaultButtonEnabled = true;
super();
focusableObjects = new Dictionary(true);
if (_arg1 != null){
_form = _arg1;
addFocusables(DisplayObject(_arg1));
_arg1.addEventListener(Event.ADDED, addedHandler);
_arg1.addEventListener(Event.REMOVED, removedHandler);
activate();
};
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
var _local5:int;
var _local6:int;
var _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
_local5 = focusableCandidates.length;
_local6 = _arg1;
while (true) {
if (_arg2){
_arg1--;
} else {
_arg1++;
};
if (_arg3){
if (((_arg2) && ((_arg1 < 0)))){
break;
};
if (((!(_arg2)) && ((_arg1 == _local5)))){
break;
};
} else {
_arg1 = ((_arg1 + _local5) % _local5);
if (_local6 == _arg1){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
_local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
if ((_local7 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local7);
_local9 = 0;
while (_local9 < focusableCandidates.length) {
_local10 = focusableCandidates[_local9];
if ((_local10 is IFocusManagerGroup)){
_local11 = IFocusManagerGroup(_local10);
if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
_arg1 = _local9;
break;
};
};
_local9++;
};
};
return (_arg1);
};
};
return (_arg1);
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = _arg1;
var skipTopLevel = _arg2;
if (!skipTopLevel){
if ((o is IFocusManagerComponent)){
focusable = IFocusManagerComponent(o);
if (focusable.focusEnabled){
if (((focusable.tabEnabled) && (isTabVisible(o)))){
focusableObjects[o] = true;
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
} else {
if ((o is InteractiveObject)){
io = (o as InteractiveObject);
if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
focusableObjects[io] = true;
calculateCandidates = true;
};
io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
};
};
if ((o is DisplayObjectContainer)){
doc = DisplayObjectContainer(o);
o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
i = 0;
while (i < doc.numChildren) {
try {
child = doc.getChildAt(i);
if (child != null){
addFocusables(doc.getChildAt(i));
};
} catch(error:SecurityError) {
};
i = (i + 1);
};
};
};
}
private function getChildIndex(_arg1:DisplayObjectContainer, _arg2:DisplayObject):int{
return (_arg1.getChildIndex(_arg2));
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
_local2 = (_arg1.target as InteractiveObject);
}
private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
var _local3:IFocusManagerGroup;
if (!isEnabledAndVisible(_arg1)){
return (false);
};
if ((_arg1 is IFocusManagerGroup)){
_local3 = IFocusManagerGroup(_arg1);
if (_arg2 == _local3.groupName){
return (false);
};
};
return (true);
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject;
_local2 = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function sortFocusableObjectsTabIndex():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
focusableCandidates.push(_local2);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function removeFocusables(_arg1:DisplayObject):void{
var _local2:Object;
var _local3:DisplayObject;
if ((_arg1 is DisplayObjectContainer)){
_arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
_arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
for (_local2 in focusableObjects) {
_local3 = DisplayObject(_local2);
if (DisplayObjectContainer(_arg1).contains(_local3)){
if (_local3 == lastFocus){
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local2];
calculateCandidates = true;
};
};
};
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject;
_local2 = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
while (_arg1 != InteractiveObject(form)) {
if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
if (_arg1 == null){
break;
};
};
return (null);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
var _local2:DisplayObjectContainer;
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
_local2 = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject;
_local1 = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
var _local3:TextField;
var _local4:SimpleButton;
_local2 = DisplayObject(form).parent;
while (_arg1 != _local2) {
if ((_arg1 is UIComponent)){
if (!UIComponent(_arg1).enabled){
return (false);
};
} else {
if ((_arg1 is TextField)){
_local3 = TextField(_arg1);
if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
return (false);
};
} else {
if ((_arg1 is SimpleButton)){
_local4 = SimpleButton(_arg1);
if (!_local4.enabled){
return (false);
};
};
};
};
if (!_arg1.visible){
return (false);
};
_arg1 = _arg1.parent;
};
return (true);
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button;
_local2 = (_arg1) ? Button(_arg1) : null;
if (_local2 != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = _local2;
defButton = _local2;
if (_local2){
_local2.emphasized = true;
};
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
if (!hasFocusableObjects()){
return;
};
_local2 = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_local2);
};
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
private function sortFocusableObjects():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(_local2);
};
focusableCandidates.sort(sortByDepth);
}
private function keyFocusChangeHandler(_arg1:FocusEvent):void{
showFocusIndicator = true;
if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
setFocusToNextObject(_arg1);
_arg1.preventDefault();
};
}
private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
var _local2:int;
var _local3:int;
_local2 = focusableCandidates.length;
_local3 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (focusableCandidates[_local3] == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function hideFocus():void{
}
private function removedHandler(_arg1:Event):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:InteractiveObject;
_local3 = DisplayObject(_arg1.target);
if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
if (_local3 == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local3];
calculateCandidates = true;
} else {
if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
_local4 = (_local3 as InteractiveObject);
if (_local4){
if (_local4 == lastFocus){
lastFocus = null;
};
delete focusableObjects[_local4];
calculateCandidates = true;
};
_local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
};
};
removeFocusables(_local3);
}
private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:DisplayObject;
_local3 = "";
_local4 = "";
_local8 = "0000";
_local9 = DisplayObject(_arg1);
_local10 = DisplayObject(_arg2);
while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
_local5 = getChildIndex(_local9.parent, _local9);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local3 = (_local7 + _local3);
_local9 = _local9.parent;
};
while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
_local5 = getChildIndex(_local10.parent, _local10);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local4 = (_local7 + _local4);
_local10 = _local10.parent;
};
return (((_local3 > _local4)) ? 1 : ((_local3 < _local4)) ? -1 : 0);
}
public function get defaultButton():Button{
return (_defaultButton);
}
private function activateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
public function showFocus():void{
}
public function set defaultButtonEnabled(_arg1:Boolean):void{
_defaultButtonEnabled = _arg1;
}
public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
var _local2:DisplayObject;
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
_local2 = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
_local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
_local4 = getIndexOfFocusedObject(_local2);
_local5 = false;
_local6 = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
_local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:InteractiveObject;
if (_arg1.isDefaultPrevented()){
return;
};
_local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
if (!_local2){
return;
};
showFocusIndicator = false;
if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
setFocus(_local2);
};
lastAction = "MOUSEDOWN";
}
private function isTabVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
_local2 = _arg1.parent;
while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
if (!_local2.tabChildren){
return (false);
};
_local2 = _local2.parent;
};
return (true);
}
public function get nextTabIndex():int{
return (0);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function focusInHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
var _local3:Button;
_local2 = InteractiveObject(_arg1.target);
if (form.contains(_local2)){
lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
if ((lastFocus is Button)){
_local3 = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = _local3;
_local3.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function tabEnabledChangeHandler(_arg1:Event):void{
var _local2:InteractiveObject;
var _local3:Boolean;
calculateCandidates = true;
_local2 = InteractiveObject(_arg1.target);
_local3 = (focusableObjects[_local2] == true);
if (_local2.tabEnabled){
if (((!(_local3)) && (isTabVisible(_local2)))){
if (!(_local2 is IFocusManagerComponent)){
_local2.focusRect = false;
};
focusableObjects[_local2] = true;
};
} else {
if (_local3){
delete focusableObjects[_local2];
};
};
}
public function set showFocusIndicator(_arg1:Boolean):void{
_showFocusIndicator = _arg1;
}
public function get form():DisplayObjectContainer{
return (_form);
}
private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
return (((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : ((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2));
}
public function activate():void{
if (activated){
return;
};
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
}
}//package fl.managers
Section 87
//IFocusManager (fl.managers.IFocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
public interface IFocusManager {
function getFocus():InteractiveObject;
function deactivate():void;
function set defaultButton(_arg1:Button):void;
function set showFocusIndicator(_arg1:Boolean):void;
function get defaultButtonEnabled():Boolean;
function get nextTabIndex():int;
function get defaultButton():Button;
function get showFocusIndicator():Boolean;
function setFocus(_arg1:InteractiveObject):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(_arg1:Boolean):void;
function hideFocus():void;
function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 88
//IFocusManagerComponent (fl.managers.IFocusManagerComponent)
package fl.managers {
public interface IFocusManagerComponent {
function set focusEnabled(_arg1:Boolean):void;
function drawFocus(_arg1:Boolean):void;
function setFocus():void;
function get focusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function get mouseFocusEnabled():Boolean;
}
}//package fl.managers
Section 89
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function set groupName(_arg1:String):void;
function set selected(_arg1:Boolean):void;
function get groupName():String;
function get selected():Boolean;
}
}//package fl.managers
Section 90
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.utils.*;
import flash.text.*;
public class StyleManager {
private var globalStyles:Object;
private var classToDefaultStylesDict:Dictionary;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToInstancesDict:Dictionary;
private static var _instance:StyleManager;
public function StyleManager(){
styleToClassesHash = {};
classToInstancesDict = new Dictionary(true);
classToStylesDict = new Dictionary(true);
classToDefaultStylesDict = new Dictionary(true);
globalStyles = UIComponent.getStyleDefinition();
}
public static function clearComponentStyle(_arg1:Object, _arg2:String):void{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
delete _local4[_arg2];
invalidateComponentStyle(_local3, _arg2);
};
}
private static function getClassDef(_arg1:Object):Class{
var component = _arg1;
if ((component is Class)){
return ((component as Class));
};
try {
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
if ((component is UIComponent)){
try {
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
};
};
};
return (null);
}
public static function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Class;
var _local5:Object;
_local4 = getClassDef(_arg1);
_local5 = getInstance().classToStylesDict[_local4];
if (_local5 == null){
_local5 = (getInstance().classToStylesDict[_local4] = {});
};
if (_local5 == _arg3){
return;
};
_local5[_arg2] = _arg3;
invalidateComponentStyle(_local4, _arg2);
}
private static function setSharedStyles(_arg1:UIComponent):void{
var _local2:StyleManager;
var _local3:Class;
var _local4:Object;
var _local5:String;
_local2 = getInstance();
_local3 = getClassDef(_arg1);
_local4 = _local2.classToDefaultStylesDict[_local3];
for (_local5 in _local4) {
_arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
};
}
public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
return (((_local4)==null) ? null : _local4[_arg2]);
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
var _local3:Dictionary;
var _local4:Object;
var _local5:UIComponent;
_local3 = getInstance().classToInstancesDict[_arg1];
if (_local3 == null){
return;
};
for (_local4 in _local3) {
_local5 = (_local4 as UIComponent);
if (_local5 == null){
} else {
_local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
};
};
}
private static function invalidateStyle(_arg1:String):void{
var _local2:Dictionary;
var _local3:Object;
_local2 = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var inst:StyleManager;
var classDef:Class;
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
inst = getInstance();
classDef = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
try {
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
} catch(err:Error) {
try {
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
} catch(e:Error) {
defaultStyles = UIComponent.getStyleDefinition();
break;
};
};
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
inst.classToStylesDict[classDef] = {};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
public static function getStyle(_arg1:String):Object{
return (getInstance().globalStyles[_arg1]);
}
private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
var _local3:Class;
var _local4:StyleManager;
var _local5:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance();
_local5 = _local4.classToStylesDict[_local3][_arg2];
if (_local5 != null){
return (_local5);
};
_local5 = _local4.globalStyles[_arg2];
if (_local5 != null){
return (_local5);
};
return (_local4.classToDefaultStylesDict[_local3][_arg2]);
}
public static function setStyle(_arg1:String, _arg2:Object):void{
var _local3:Object;
_local3 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 91
//FieldData1 (levels.level1.FieldData1)
package levels.level1 {
import levels.*;
public class FieldData1 extends FieldDataBase {
public function FieldData1(){
super();
}
override protected function setCustomData():void{
super.map = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 2, 6, 1, 1], [7, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1], [1, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
super.path = ["a-90", "r-2", "a-0", "u-1", "a-90", "r-9", "a-180", "d-7", "a--90", "l-8", "a-180", "d-1"];
}
}
}//package levels.level1
Section 92
//Level1 (levels.level1.Level1)
package levels.level1 {
import flash.utils.*;
import levels.*;
public class Level1 extends LevelBase {
public function Level1(){
super();
new Wave1();
new Wave2();
new Wave3();
new Wave4();
new Wave5();
new Wave6();
new Wave7();
new Wave8();
new Wave9();
new Wave10();
new Wave11();
new Wave12();
new Wave13();
new Wave14();
new Wave15();
new Wave16();
new Wave17();
new Wave18();
new Wave19();
new Wave20();
}
override protected function configParams():void{
var i:Number;
var waveClassName:Class;
this.waves = 20;
this.goldAtStart = 250;
this.wavesArray = new Array();
i = 1;
while (i <= this.waves) {
waveClassName = (getDefinitionByName(("levels.level1.Wave" + i)) as Class);
this.wavesArray.push(new (waveClassName));
i++;
};
}
}
}//package levels.level1
Section 93
//Wave1 (levels.level1.Wave1)
package levels.level1 {
import levels.*;
public class Wave1 extends WaveBase {
public function Wave1(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Rider";
this.description = "Fast weak creatures";
this.speed = 3;
this.gold = 4;
this.betweenInterval = 500;
this.totalAmount = 8;
this.skin = "Creep1";
this.hitpoints = 60;
this.exp = 1;
}
}
}//package levels.level1
Section 94
//Wave10 (levels.level1.Wave10)
package levels.level1 {
import levels.*;
public class Wave10 extends WaveBase {
public function Wave10(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Simple Monster";
this.description = "Slow weak creatures";
this.speed = 2;
this.betweenInterval = 700;
this.totalAmount = 10;
this.skin = "Creep7";
this.gold = 2;
this.hitpoints = 250;
}
}
}//package levels.level1
Section 95
//Wave11 (levels.level1.Wave11)
package levels.level1 {
import levels.*;
public class Wave11 extends WaveBase {
public function Wave11(){
super();
}
override protected function configParams():void{
this.minDamage = 50;
this.maxDamage = 150;
this.name = "Power Rider";
this.description = "BOSS";
this.speed = 5;
this.betweenInterval = 100;
this.totalAmount = 1;
this.skin = "Creep1";
this.gold = 100;
this.hitpoints = 700;
this.exp = 50;
}
}
}//package levels.level1
Section 96
//Wave12 (levels.level1.Wave12)
package levels.level1 {
import levels.*;
public class Wave12 extends WaveBase {
public function Wave12(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Biter";
this.description = "Huge number of biters";
this.speed = 3;
this.betweenInterval = 400;
this.totalAmount = 30;
this.skin = "Creep3";
this.gold = 3;
this.hitpoints = 180;
}
}
}//package levels.level1
Section 97
//Wave13 (levels.level1.Wave13)
package levels.level1 {
import levels.*;
public class Wave13 extends WaveBase {
public function Wave13(){
super();
}
override protected function configParams():void{
this.minDamage = 50;
this.maxDamage = 150;
this.name = "Super Spy";
this.description = "BOSS";
this.speed = 2;
this.betweenInterval = 700;
this.totalAmount = 1;
this.skin = "Creep4";
this.gold = 200;
this.hitpoints = 2300;
this.exp = 60;
}
}
}//package levels.level1
Section 98
//Wave14 (levels.level1.Wave14)
package levels.level1 {
import levels.*;
public class Wave14 extends WaveBase {
public function Wave14(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Crawler";
this.description = "Slow heavy armored";
this.speed = 1;
this.betweenInterval = 500;
this.totalAmount = 10;
this.skin = "Creep2";
this.gold = 4;
this.hitpoints = 400;
}
}
}//package levels.level1
Section 99
//Wave15 (levels.level1.Wave15)
package levels.level1 {
import levels.*;
public class Wave15 extends WaveBase {
public function Wave15(){
super();
}
override protected function configParams():void{
this.minDamage = 50;
this.maxDamage = 150;
this.name = "Blue bombs";
this.description = "Fast and dengerous";
this.speed = 5;
this.betweenInterval = 500;
this.totalAmount = 10;
this.skin = "Creep6";
this.gold = 3;
this.hitpoints = 200;
}
}
}//package levels.level1
Section 100
//Wave16 (levels.level1.Wave16)
package levels.level1 {
import levels.*;
public class Wave16 extends WaveBase {
public function Wave16(){
super();
}
override protected function configParams():void{
this.minDamage = 10;
this.maxDamage = 50;
this.name = "Royal Crawler";
this.description = "Kill them to get extra Exp";
this.speed = 1;
this.betweenInterval = 700;
this.totalAmount = 3;
this.skin = "Creep2";
this.gold = 70;
this.hitpoints = 1000;
this.exp = 100;
}
}
}//package levels.level1
Section 101
//Wave17 (levels.level1.Wave17)
package levels.level1 {
import levels.*;
public class Wave17 extends WaveBase {
public function Wave17(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Bomb";
this.description = "Huge number of bombs";
this.speed = 5;
this.betweenInterval = 300;
this.totalAmount = 25;
this.skin = "Creep7";
this.gold = 10;
this.hitpoints = 150;
}
}
}//package levels.level1
Section 102
//Wave18 (levels.level1.Wave18)
package levels.level1 {
import levels.*;
public class Wave18 extends WaveBase {
public function Wave18(){
super();
}
override protected function configParams():void{
this.minDamage = 50;
this.maxDamage = 150;
this.name = "Simple Monster";
this.description = "Slow strong creatures";
this.speed = 10;
this.betweenInterval = 600;
this.totalAmount = 10;
this.skin = "Creep1";
this.gold = 5;
this.hitpoints = 500;
this.exp = 2;
}
}
}//package levels.level1
Section 103
//Wave19 (levels.level1.Wave19)
package levels.level1 {
import levels.*;
public class Wave19 extends WaveBase {
public function Wave19(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Simple Monster";
this.description = "Slow strong creatures";
this.speed = 1;
this.betweenInterval = 700;
this.totalAmount = 10;
this.skin = "Creep7";
this.gold = 2;
this.hitpoints = 600;
}
}
}//package levels.level1
Section 104
//Wave2 (levels.level1.Wave2)
package levels.level1 {
import levels.*;
public class Wave2 extends WaveBase {
public function Wave2(){
super();
}
override protected function configParams():void{
this.minDamage = 7;
this.maxDamage = 15;
this.name = "Crawler";
this.description = "Slow weak creatures";
this.speed = 1;
this.betweenInterval = 700;
this.totalAmount = 10;
this.skin = "Creep2";
this.gold = 4;
this.hitpoints = 150;
}
}
}//package levels.level1
Section 105
//Wave20 (levels.level1.Wave20)
package levels.level1 {
import levels.*;
public class Wave20 extends WaveBase {
public function Wave20(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Simple Monster";
this.description = "Slow strong creatures";
this.speed = 1;
this.betweenInterval = 700;
this.totalAmount = 10;
this.skin = "Creep7";
this.gold = 2;
this.hitpoints = 650;
}
}
}//package levels.level1
Section 106
//Wave3 (levels.level1.Wave3)
package levels.level1 {
import levels.*;
public class Wave3 extends WaveBase {
public function Wave3(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 20;
this.name = "Biter";
this.description = "Medium speed";
this.speed = 2;
this.betweenInterval = 1000;
this.totalAmount = 9;
this.skin = "Creep3";
this.gold = 4;
this.hitpoints = 200;
}
}
}//package levels.level1
Section 107
//Wave4 (levels.level1.Wave4)
package levels.level1 {
import levels.*;
public class Wave4 extends WaveBase {
public function Wave4(){
super();
}
override protected function configParams():void{
this.minDamage = 10;
this.maxDamage = 35;
this.name = "Spy";
this.description = "Medium";
this.speed = 3;
this.betweenInterval = 930;
this.totalAmount = 10;
this.skin = "Creep4";
this.gold = 5;
this.hitpoints = 200;
}
}
}//package levels.level1
Section 108
//Wave5 (levels.level1.Wave5)
package levels.level1 {
import levels.*;
public class Wave5 extends WaveBase {
public function Wave5(){
super();
}
override protected function configParams():void{
this.minDamage = 30;
this.maxDamage = 55;
this.name = "Ant";
this.description = "Slow and strong";
this.speed = 1;
this.betweenInterval = 500;
this.totalAmount = 5;
this.skin = "Creep5";
this.gold = 10;
this.hitpoints = 400;
}
}
}//package levels.level1
Section 109
//Wave6 (levels.level1.Wave6)
package levels.level1 {
import levels.*;
public class Wave6 extends WaveBase {
public function Wave6(){
super();
}
override protected function configParams():void{
this.minDamage = 200;
this.maxDamage = 400;
this.name = "Blue Bomb";
this.description = "BOSS !!!";
this.speed = 2;
this.betweenInterval = 700;
this.totalAmount = 1;
this.skin = "Creep6";
this.gold = 70;
this.hitpoints = 700;
}
}
}//package levels.level1
Section 110
//Wave7 (levels.level1.Wave7)
package levels.level1 {
import levels.*;
public class Wave7 extends WaveBase {
public function Wave7(){
super();
}
override protected function configParams():void{
this.minDamage = 20;
this.maxDamage = 40;
this.name = "Mine";
this.description = "Slow weak ";
this.speed = 3;
this.betweenInterval = 1000;
this.totalAmount = 15;
this.skin = "Creep7";
this.gold = 4;
this.hitpoints = 220;
}
}
}//package levels.level1
Section 111
//Wave8 (levels.level1.Wave8)
package levels.level1 {
import levels.*;
public class Wave8 extends WaveBase {
public function Wave8(){
super();
}
override protected function configParams():void{
this.minDamage = 50;
this.maxDamage = 75;
this.name = "Fast Rider";
this.description = "Extra fast";
this.speed = 5;
this.betweenInterval = 300;
this.totalAmount = 10;
this.skin = "Creep1";
this.gold = 4;
this.hitpoints = 110;
}
}
}//package levels.level1
Section 112
//Wave9 (levels.level1.Wave9)
package levels.level1 {
import levels.*;
public class Wave9 extends WaveBase {
public function Wave9(){
super();
}
override protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Royal Ant";
this.description = "2 BOSSES !!!";
this.speed = 1;
this.betweenInterval = 2000;
this.totalAmount = 2;
this.skin = "Creep5";
this.gold = 50;
this.hitpoints = 1500;
}
}
}//package levels.level1
Section 113
//FieldData2 (levels.level2.FieldData2)
package levels.level2 {
import levels.*;
public class FieldData2 extends FieldDataBase {
public function FieldData2(){
super();
}
override protected function setCustomData():void{
super.map = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [7, 2, 2, 6, 1, 1, 1, 5, 2, 2, 2, 6, 1, 1], [1, 1, 1, 9, 1, 1, 1, 9, 1, 1, 1, 9, 1, 1], [1, 1, 1, 9, 1, 1, 1, 9, 1, 1, 1, 9, 1, 1], [1, 5, 2, 3, 1, 1, 1, 9, 1, 1, 1, 9, 1, 1], [1, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1, 9, 1, 1], [1, 4, 2, 2, 2, 2, 2, 3, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1], [1, 1, 1, 1, 1, 1, 5, 2, 2, 6, 1, 4, 6, 1], [1, 1, 1, 1, 1, 1, 9, 1, 1, 9, 1, 1, 9, 1], [1, 1, 1, 1, 1, 1, 8, 1, 1, 4, 2, 2, 3, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
super.path = ["a-90", "r-3", "a-180", "d-3", "a--90", "l-2", "a-180", "d-2", "a-90", "r-6", "a-0", "u-5", "a-90", "r-4", "a-180", "d-7", "a-90", "r-1", "a-180", "d-2", "a--90", "l-3", "a-0", "u-2", "a--90", "l-3", "a-180", "d-2"];
}
}
}//package levels.level2
Section 114
//FieldData3 (levels.level3.FieldData3)
package levels.level3 {
import levels.*;
public class FieldData3 extends FieldDataBase {
public function FieldData3(){
super();
}
override protected function setCustomData():void{
super.map = [[7, 2, 2, 2, 2, 6, 1, 5, 2, 2, 2, 2, 6, 1], [1, 1, 1, 1, 1, 4, 2, 3, 1, 1, 1, 1, 4, 6], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9], [5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 1, 9], [9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 9], [9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 9], [9, 1, 1, 5, 2, 2, 2, 6, 1, 1, 1, 9, 1, 9], [9, 1, 1, 9, 1, 1, 1, 8, 1, 1, 1, 9, 1, 9], [9, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 9, 1, 9], [9, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 9, 1, 9], [9, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 9, 1, 9], [9, 1, 1, 4, 2, 2, 2, 2, 2, 2, 2, 3, 1, 9], [9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9], [4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]];
super.path = ["a-90", "r-5", "a-180", "d-1", "a-90", "r-2", "a-0", "u-1", "a-90", "r-5", "a-180", "d-1", "a-90", "r-1", "a-180", "d-12", "a--90", "l-13", "a-0", "u-10", "a-90", "r-11", "a-180", "d-8", "a--90", "l-8", "a-0", "u-5", "a-90", "r-4", "a-180", "d-1"];
}
}
}//package levels.level3
Section 115
//FieldData4 (levels.level4.FieldData4)
package levels.level4 {
import levels.*;
public class FieldData4 extends FieldDataBase {
public function FieldData4(){
super();
}
override protected function setCustomData():void{
super.map = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [7, 2, 6, 1, 1, 5, 2, 6, 1, 1, 1, 1, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 5, 2, 6, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 9, 1, 9, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 9, 1, 9, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 9, 1, 9, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 9, 1, 9, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 9, 1, 9, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 9, 1, 9, 1, 1], [1, 1, 9, 1, 1, 9, 1, 9, 1, 9, 1, 9, 1, 1], [1, 1, 9, 1, 1, 9, 1, 4, 2, 3, 1, 8, 1, 1], [1, 1, 4, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
super.path = ["a-90", "r-2", "a-180", "d-10", "a-90", "r-3", "a-0", "u-10", "a-90", "r-2", "a-180", "d-9", "a-90", "r-2", "a-0", "u-8", "a-90", "r-2", "a-180", "d-8"];
}
}
}//package levels.level4
Section 116
//FieldData5 (levels.level5.FieldData5)
package levels.level5 {
import levels.*;
public class FieldData5 extends FieldDataBase {
public function FieldData5(){
super();
}
override protected function setCustomData():void{
super.map = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 5, 2, 2, 2, 6, 1, 1, 1, 1, 1, 1], [1, 1, 1, 9, 1, 1, 1, 9, 1, 5, 2, 2, 6, 1], [1, 1, 1, 9, 1, 1, 1, 9, 1, 9, 1, 1, 9, 1], [1, 1, 1, 8, 1, 1, 1, 9, 1, 9, 1, 1, 9, 1], [1, 1, 1, 1, 1, 1, 1, 4, 2, 3, 1, 1, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1], [1, 1, 1, 1, 1, 1, 5, 2, 2, 6, 1, 5, 3, 1], [1, 5, 2, 2, 6, 1, 9, 1, 1, 9, 1, 9, 1, 1], [1, 4, 2, 6, 9, 1, 4, 6, 1, 9, 1, 9, 1, 1], [1, 1, 1, 9, 4, 2, 2, 3, 1, 9, 1, 9, 1, 1], [7, 2, 2, 3, 1, 1, 1, 1, 1, 4, 2, 3, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
super.path = ["a-90", "r-3", "a-0", "u-2", "a--90", "l-2", "a-0", "u-1", "a-90", "r-3", "a-180", "d-2", "a-90", "r-3", "a-0", "u-1", "a--90", "l-1", "a-0", "u-2", "a-90", "r-3", "a-180", "d-4", "a-90", "r-2", "a-0", "u-4", "a-90", "r-1", "a-0", "u-6", "a--90", "l-3", "a-180", "d-3", "a--90", "l-2", "a-0", "u-4", "a--90", "l-4", "a-180", "d-3"];
}
}
}//package levels.level5
Section 117
//FieldData6 (levels.level6.FieldData6)
package levels.level6 {
import levels.*;
public class FieldData6 extends FieldDataBase {
public function FieldData6(){
super();
}
override protected function setCustomData():void{
super.map = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 1], [1, 1, 4, 2, 6, 1, 1, 1, 1, 1, 5, 2, 3, 1], [1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1], [1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1], [1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1], [7, 2, 2, 2, 3, 1, 1, 1, 1, 1, 9, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1], [1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1], [1, 1, 4, 2, 2, 2, 2, 6, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 8, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
super.path = ["a-90", "r-4", "a-0", "u-4", "a--90", "l-2", "a-0", "u-1", "a-90", "r-10", "a-180", "d-1", "a--90", "l-2", "a-180", "d-6", "a--90", "l-8", "a-180", "d-1", "a-90", "r-5", "a-180", "d-1"];
}
}
}//package levels.level6
Section 118
//FieldDataBase (levels.FieldDataBase)
package levels {
public class FieldDataBase {
public var map:Array;
public var path:Array;
public var castleCellX:Number;
public var castleCellY:Number;
public function FieldDataBase(){
super();
this.setCustomData();
}
protected function setCustomData():void{
this.map = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 5, 2, 2, 2, 6, 1, 5, 2, 6, 1, 1, 1], [1, 1, 9, 1, 1, 1, 9, 1, 9, 1, 9, 1, 1, 1], [1, 1, 9, 1, 1, 1, 9, 1, 9, 1, 9, 1, 1, 1], [1, 1, 9, 1, 1, 1, 4, 2, 3, 1, 9, 1, 1, 1], [1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1], [7, 2, 3, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 5, 2, 2, 3, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1], [1, 1, 1, 5, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1], [1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
this.path = ["a-90", "r-2", "a-0", "u-5", "a-90", "r-4", "a-180", "d-3", "a-90", "r-2", "a-0", "u-3", "a-90", "r-2", "a-180", "d-6", "a--90", "l-3", "a-180", "d-3", "a--90", "l-4", "a-180", "d-2"];
}
}
}//package levels
Section 119
//LevelBase (levels.LevelBase)
package levels {
public class LevelBase {
public var waves:Number;
public var wavesArray:Array;
public var goldAtStart:Number;
public function LevelBase(){
super();
this.configParams();
}
protected function configParams():void{
this.waves = 10;
this.goldAtStart = 100;
}
}
}//package levels
Section 120
//WaveBase (levels.WaveBase)
package levels {
public class WaveBase {
public var description:String;
public var name:String;
public var exp:Number;
public var speed:Number;
public var gold:Number;
public var minDamage:Number;
public var betweenInterval:Number;
public var maxDamage:Number;
public var hitpoints:Number;
public var totalAmount:Number;
public var skin:String;
public function WaveBase(){
super();
this.exp = 2;
this.configParams();
}
protected function configParams():void{
this.minDamage = 5;
this.maxDamage = 15;
this.name = "Simple Monster";
this.description = "Slow weak creatures";
this.speed = 1;
this.betweenInterval = 700;
this.totalAmount = 10;
this.skin = "skin1";
this.gold = 1;
this.hitpoints = 10;
}
}
}//package levels
Section 121
//SpellIcon (spells.SpellIcon)
package spells {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class SpellIcon extends MovieClip {
public var button:SimpleButton;
public var lockCover:Sprite;
private var _timeToRegenerate:Number;// = 5000
public var dt:TextField;
public var content:MovieClip;
public var restore:Sprite;
private var timeInterval:Number;
private var curRestoreFrame:Number;// = 0
private var totalRestoreFrames:Number;// = 0
public function SpellIcon(){
_timeToRegenerate = 5000;
curRestoreFrame = 0;
totalRestoreFrames = 0;
super();
SimpleToolTip.addToolTip(this.lockCover, "Unlock this ability \nbefore next level");
this.button.addEventListener(MouseEvent.CLICK, onClick);
this.restore.scaleY = 0;
this.dt.mouseEnabled = false;
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
public function get timeToRegenerate():Number{
return (_timeToRegenerate);
}
public function setDisable():void{
this.button.enabled = false;
this.lockCover.visible = true;
}
public function setToolTip(t:String, dx:Number=0):void{
SimpleToolTip.addToolTip(this.button, t, dx);
}
public function disableIconForTime():void{
}
public function setEnabled(l:Number):void{
switch (l){
case 0:
SimpleToolTip.addToolTip(this.lockCover, "Unlock this ability \nbefore next level");
this.setDisable();
return;
case 1:
this.dt.text = "I";
break;
case 2:
this.dt.text = "II";
break;
case 3:
this.dt.text = "III";
break;
case 4:
this.dt.text = "IV";
break;
};
this.button.enabled = true;
this.lockCover.visible = false;
}
private function tick(e:TimerEvent):void{
}
private function onAddedToStage(e:Event):void{
this.totalRestoreFrames = Math.floor((this._timeToRegenerate / this.stage.frameRate));
}
public function setContent(c:Sprite):void{
this.content.addChild(c);
}
private function onEnterFrame(e:Event):void{
var part:Number;
this.curRestoreFrame++;
part = (Math.floor((100 - ((this.curRestoreFrame / this.totalRestoreFrames) * 100))) / 100);
this.restore.scaleY = part;
if (this.curRestoreFrame >= this.totalRestoreFrames){
this.restore.scaleY = 0;
this.button.enabled = true;
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
this.curRestoreFrame = 0;
};
}
public function onClick(e:MouseEvent):void{
trace("spellIcon");
this.button.enabled = false;
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
if (this.curRestoreFrame == 0){
this.dispatchEvent(new Event("castSpell"));
};
}
public function set timeToRegenerate(value:Number):void{
_timeToRegenerate = value;
if (this.stage != null){
this.totalRestoreFrames = Math.floor((this._timeToRegenerate / this.stage.frameRate));
};
}
}
}//package spells
Section 122
//SpellIcons (spells.SpellIcons)
package spells {
import flash.display.*;
import flash.events.*;
import creeps.*;
public class SpellIcons extends MovieClip {
public var icon1:SpellIcon;
public var creepsContainer:CreepsContainer;
private var castleLayer:CastleLayer;
public var ionCannonArea:Sprite;
public var icon2:SpellIcon;
public var icon3:SpellIcon;
public var icon4:SpellIcon;
public var splashAnimation:MovieClip;
public function SpellIcons(){
super();
icon1.setContent(new SpellIcon1());
icon2.setContent(new SpellIcon2());
icon3.setContent(new SpellIcon3());
icon4.setContent(new SpellIcon4());
icon1.timeToRegenerate = 5000;
this.ionCannonArea = new IonCannonArea();
this.ionCannonArea.addEventListener(MouseEvent.CLICK, onIonCannonAreaClick);
this.splashAnimation = new IonCannonAreaSplashDamage();
}
private function castSpell2(e:Event):void{
trace("spells.SpellIcons.castSpell2");
this.castleLayer.castle.activateShield(Global.baseUpgradeData.upgrade2ExpValue[(Global.baseUpgradeData.upgrade2 - 1)]);
}
private function castSpell4(e:Event):void{
var i:Number;
var creep:Creep;
trace("spells.SpellIcons.castSpell4");
this.castleLayer.castle.doEmiAnimation();
i = 0;
while (i < this.creepsContainer.numChildren) {
creep = (this.creepsContainer.getChildAt(i) as Creep);
if (creep != null){
creep.doDamage(Global.baseUpgradeData.upgrade4ExpValue[(Global.baseUpgradeData.upgrade4 - 1)]);
};
i++;
};
}
private function castSpell3(e:Event):void{
var i:Number;
var creep:Creep;
trace("spells.SpellIcons.castSpell3");
this.castleLayer.castle.doEmiAnimation();
i = 0;
while (i < this.creepsContainer.numChildren) {
creep = (this.creepsContainer.getChildAt(i) as Creep);
if (creep != null){
creep.doFreeze(Global.baseUpgradeData.upgrade3ExpValue[(Global.baseUpgradeData.upgrade3 - 1)]);
};
i++;
};
}
private function press3(e:Event):void{
this.icon3.onClick(null);
}
private function press1(e:Event):void{
this.icon1.onClick(null);
}
private function press4(e:Event):void{
this.icon4.onClick(null);
}
private function press2(e:Event):void{
this.icon2.onClick(null);
}
public function setCastleLayer(c:CastleLayer):void{
this.castleLayer = c;
trace("spells.SpellIcons.setCastleLayer", this.castleLayer);
icon1.addEventListener("castSpell", castSpell1);
icon2.addEventListener("castSpell", castSpell2);
icon3.addEventListener("castSpell", castSpell3);
icon4.addEventListener("castSpell", castSpell4);
trace("====", Global.keyBoardManager);
Global.keyBoardManager.addEventListener("spell1", press1);
Global.keyBoardManager.addEventListener("spell2", press2);
Global.keyBoardManager.addEventListener("spell3", press3);
Global.keyBoardManager.addEventListener("spell4", press4);
trace("=====", Global.keyBoardManager);
}
private function castSpell1(e:Event):void{
trace("spells.SpellIcons.castSpell1");
this.addChild(this.ionCannonArea);
this.ionCannonArea.startDrag(true);
}
private function onIonCannonAreaClick(e:MouseEvent):void{
var areaX:Number;
var areaY:Number;
var dam:Number;
var i:Number;
var creep:Creep;
var d:Number;
this.ionCannonArea.stopDrag();
this.removeChild(this.ionCannonArea);
areaX = this.creepsContainer.mouseX;
areaY = this.creepsContainer.mouseY;
this.splashAnimation.x = this.mouseX;
this.splashAnimation.y = this.mouseY;
this.splashAnimation.play();
Global.soundManager.addUserWeaponSound("IonCannon");
dam = Global.baseUpgradeData.upgrade1ExpValue[(Global.baseUpgradeData.upgrade1 - 1)];
i = 0;
while (i < this.creepsContainer.numChildren) {
creep = (this.creepsContainer.getChildAt(i) as Creep);
if (creep != null){
d = Math.floor(Math.sqrt((((creep.x - areaX) * (creep.x - areaX)) + ((creep.y - areaY) * (creep.y - areaY)))));
if (d < 60){
trace("spells.SpellIcons.onIonCannonAreaClick", dam);
creep.doDamage(dam);
};
};
i++;
};
}
public function setCreepsContainer(c:CreepsContainer):void{
this.creepsContainer = c;
this.addChild(this.splashAnimation);
}
public function update():void{
icon1.setEnabled(Global.baseUpgradeData.upgrade1);
icon2.setEnabled(Global.baseUpgradeData.upgrade2);
icon3.setEnabled(Global.baseUpgradeData.upgrade3);
icon4.setEnabled(Global.baseUpgradeData.upgrade4);
}
public function updateToolTips():void{
icon1.setToolTip((((("Level " + Global.baseUpgradeData.upgrade1) + "\nDamage: ") + Global.baseUpgradeData.upgrade1ExpValue[Global.baseUpgradeData.upgrade1]) + "\nDamages all creeps in selected area"));
icon2.setToolTip((((("Level " + Global.baseUpgradeData.upgrade2) + "\nShield power: ") + Global.baseUpgradeData.upgrade2ExpValue[Global.baseUpgradeData.upgrade2]) + "\nReduce creeps damage for base"), -30);
icon3.setToolTip((((("Level " + Global.baseUpgradeData.upgrade3) + "\nFreeze power: ") + Global.baseUpgradeData.upgrade3ExpValue[Global.baseUpgradeData.upgrade3]) + "\nEMI - electro magnet\n impuls. Slow all creeps"), -80);
icon4.setToolTip((((("Level " + Global.baseUpgradeData.upgrade4) + "\nDamage: ") + Global.baseUpgradeData.upgrade4ExpValue[Global.baseUpgradeData.upgrade4]) + "\nExtra power EMI \nDamages all creeps on map"), -90);
}
}
}//package spells
Section 123
//CastleEMIAnimation_448 (td_fla.CastleEMIAnimation_448)
package td_fla {
import flash.display.*;
public dynamic class CastleEMIAnimation_448 extends MovieClip {
public function CastleEMIAnimation_448(){
super();
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package td_fla
Section 124
//gamesnow_girlgamesnow_bar_4 (td_fla.gamesnow_girlgamesnow_bar_4)
package td_fla {
import flash.display.*;
public dynamic class gamesnow_girlgamesnow_bar_4 extends MovieClip {
public function gamesnow_girlgamesnow_bar_4(){
super();
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package td_fla
Section 125
//InnerCreep2_508 (td_fla.InnerCreep2_508)
package td_fla {
import flash.display.*;
public dynamic class InnerCreep2_508 extends MovieClip {
public var attack:MovieClip;
public var damage:MovieClip;
public var death:MovieClip;
public var freeze:MovieClip;
public var mc:MovieClip;
public function InnerCreep2_508(){
super();
}
}
}//package td_fla
Section 126
//innerCreep22_516 (td_fla.innerCreep22_516)
package td_fla {
import flash.display.*;
public dynamic class innerCreep22_516 extends MovieClip {
public var attack:MovieClip;
public var damage:MovieClip;
public var death:MovieClip;
public var freeze:MovieClip;
public var mc:MovieClip;
public function innerCreep22_516(){
super();
}
}
}//package td_fla
Section 127
//innerCreep3_519 (td_fla.innerCreep3_519)
package td_fla {
import flash.display.*;
public dynamic class innerCreep3_519 extends MovieClip {
public var attack:MovieClip;
public var damage:MovieClip;
public var death:MovieClip;
public var freeze:MovieClip;
public var mc:MovieClip;
public function innerCreep3_519(){
super();
}
}
}//package td_fla
Section 128
//innerCreep4_522 (td_fla.innerCreep4_522)
package td_fla {
import flash.display.*;
public dynamic class innerCreep4_522 extends MovieClip {
public var attack:MovieClip;
public var damage:MovieClip;
public var death:MovieClip;
public var freeze:MovieClip;
public var mc:MovieClip;
public function innerCreep4_522(){
super();
}
}
}//package td_fla
Section 129
//innerCreep5_525 (td_fla.innerCreep5_525)
package td_fla {
import flash.display.*;
public dynamic class innerCreep5_525 extends MovieClip {
public var attack:MovieClip;
public var damage:MovieClip;
public var death:MovieClip;
public var freeze:MovieClip;
public var mc:MovieClip;
public function innerCreep5_525(){
super();
}
}
}//package td_fla
Section 130
//innerCreep6_528 (td_fla.innerCreep6_528)
package td_fla {
import flash.display.*;
public dynamic class innerCreep6_528 extends MovieClip {
public var attack:MovieClip;
public var damage:MovieClip;
public var death:MovieClip;
public var freeze:MovieClip;
public var mc:MovieClip;
public function innerCreep6_528(){
super();
}
}
}//package td_fla
Section 131
//innerCreep7_531 (td_fla.innerCreep7_531)
package td_fla {
import flash.display.*;
public dynamic class innerCreep7_531 extends MovieClip {
public var attack:MovieClip;
public var damage:MovieClip;
public var death:MovieClip;
public var freeze:MovieClip;
public var mc:MovieClip;
public function innerCreep7_531(){
super();
}
}
}//package td_fla
Section 132
//Range_Tower_Turret_506 (td_fla.Range_Tower_Turret_506)
package td_fla {
import flash.display.*;
public dynamic class Range_Tower_Turret_506 extends MovieClip {
public function Range_Tower_Turret_506(){
super();
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package td_fla
Section 133
//TowerDescription (tower_menu.TowerDescription)
package tower_menu {
import flash.display.*;
import towers.*;
import flash.text.*;
public class TowerDescription extends MovieClip {
public var speedDT:TextField;
public var costDT:TextField;
public var damageDT:TextField;
private var tower1:Tower;
private var tower2:Tower;
public var nameDT:TextField;
private var tower4:Tower;
private var tower3:Tower;
public var rangeDT:TextField;
public var descriptionDT:TextField;
public var cover:MovieClip;
public function TowerDescription(){
super();
this.tower1 = new Tower();
this.tower2 = new FreezeTower();
this.tower3 = new MissileTower();
this.tower4 = new RangeTower();
this.showCover();
}
public function showTowerDescription(index:Number):void{
var t:Tower;
var a:Number;
this.hideCover();
t = Tower(this[("tower" + index)]);
this.damageDT.text = t.info.damage.toString();
a = (t.info.shootingRate / 1000);
this.speedDT.text = a.toString();
this.rangeDT.text = t.info.r.toString();
this.nameDT.text = t.info.name;
this.costDT.text = t.info.gold.toString();
this.descriptionDT.text = t.description;
}
public function hideCover():void{
this.cover.visible = false;
}
public function showCover():void{
this.cover.visible = true;
}
}
}//package tower_menu
Section 134
//TowerMenuIcon (tower_menu.TowerMenuIcon)
package tower_menu {
import flash.display.*;
import flash.events.*;
public class TowerMenuIcon extends SimpleButton {
public function TowerMenuIcon(){
super();
trace("TowerMenuIcon");
this.addEventListener(MouseEvent.CLICK, onClick);
this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
}
private function onMouseOver(e:MouseEvent):void{
this.dispatchEvent(new Event("showDescription"));
}
private function onMouseOut(e:MouseEvent):void{
this.dispatchEvent(new Event("hideDescription"));
}
private function onClick(e:MouseEvent):void{
var selectTowerEvent:SelectTowerEvent;
this.dispatchEvent(new Event("newTower"));
selectTowerEvent = new SelectTowerEvent("selectTower");
selectTowerEvent.tower = null;
Global.gameManager.dispatchEvent(selectTowerEvent);
Global.selectedTowerInfo.showInfo(null);
}
}
}//package tower_menu
Section 135
//TowerMenuIcon2 (tower_menu.TowerMenuIcon2)
package tower_menu {
public class TowerMenuIcon2 extends TowerMenuIcon {
public function TowerMenuIcon2(){
super();
}
}
}//package tower_menu
Section 136
//TowerMenuIcon3 (tower_menu.TowerMenuIcon3)
package tower_menu {
public class TowerMenuIcon3 extends TowerMenuIcon {
public function TowerMenuIcon3(){
super();
}
}
}//package tower_menu
Section 137
//TowerMenuIcon4 (tower_menu.TowerMenuIcon4)
package tower_menu {
public class TowerMenuIcon4 extends TowerMenuIcon {
public function TowerMenuIcon4(){
super();
}
}
}//package tower_menu
Section 138
//TowersMenu (tower_menu.TowersMenu)
package tower_menu {
import flash.display.*;
import flash.events.*;
import towers.*;
public class TowersMenu extends MovieClip {
public var icon1:SimpleButton;
public var description:TowerDescription;
private var currentTower:Tower;
public var icon2:SimpleButton;
public var icon3:SimpleButton;
public var icon4:SimpleButton;
public function TowersMenu(){
super();
trace("TowersMenu");
this["icon1"].addEventListener("newTower", onNewTower);
this["icon2"].addEventListener("newTower", onNewTower2);
this["icon3"].addEventListener("newTower", onNewTower3);
this["icon4"].addEventListener("newTower", onNewTower4);
this["icon1"].addEventListener("showDescription", onShowDescription);
this["icon2"].addEventListener("showDescription", onShowDescription2);
this["icon3"].addEventListener("showDescription", onShowDescription3);
this["icon4"].addEventListener("showDescription", onShowDescription4);
this["icon1"].addEventListener("hideDescription", onHideDescription);
this["icon2"].addEventListener("hideDescription", onHideDescription);
this["icon3"].addEventListener("hideDescription", onHideDescription);
this["icon4"].addEventListener("hideDescription", onHideDescription);
}
private function onNewTower4(e:Event):void{
this.dispatchEvent(new Event("newTower4"));
}
private function onNewTower3(e:Event):void{
this.dispatchEvent(new Event("newTower3"));
}
private function onNewTower(e:Event):void{
this.dispatchEvent(new Event("newTower"));
}
private function onShowDescription4(e:Event):void{
this.description.showTowerDescription(4);
}
private function onShowDescription2(e:Event):void{
this.description.showTowerDescription(2);
}
private function onShowDescription3(e:Event):void{
this.description.showTowerDescription(3);
}
private function onHideDescription(e:Event):void{
this.description.showCover();
}
private function onShowDescription(e:Event):void{
this.description.showTowerDescription(1);
}
private function onNewTower2(e:Event):void{
this.dispatchEvent(new Event("newTower2"));
}
}
}//package tower_menu
Section 139
//FreezeTower (towers.FreezeTower)
package towers {
import flash.display.*;
import flash.events.*;
import creeps.*;
public class FreezeTower extends Tower {
private var curFrame:Number;// = 0
private var freezeAnimation:Sprite;
private var freezeAnimationFrames:Number;// = 5
public function FreezeTower(){
freezeAnimationFrames = 5;
curFrame = 0;
super();
this.freezeAnimation = new Sprite();
this.freezeAnimation.graphics.lineStyle(1, 0xFF);
this.addChild(this.freezeAnimation);
}
private function onFreezeAnimationEnterFrame(e:Event):void{
this.freezeAnimation.visible = true;
this.curFrame++;
if (this.curFrame > this.freezeAnimationFrames){
this.removeEventListener(Event.ENTER_FRAME, onFreezeAnimationEnterFrame);
this.curFrame = 0;
this.freezeAnimation.graphics.clear();
return;
};
this.freezeAnimation.graphics.clear();
trace("!");
this.freezeAnimation.graphics.lineStyle(1, 0xFF);
this.freezeAnimation.graphics.drawCircle(0, 0, Math.floor(((this.curFrame / this.freezeAnimationFrames) * this.info.r)));
}
override protected function tick(e:TimerEvent):void{
var i:Number;
var creep:Creep;
var d:Number;
if (Global.isDoubleSpeed == false){
if ((this.timer.currentCount % 2) == 0){
return;
};
};
i = 0;
while (i < this.creepsContainer.numChildren) {
creep = (this.creepsContainer.getChildAt(i) as Creep);
d = Math.floor(Math.sqrt((((creep.x - this.x) * (creep.x - this.x)) + ((creep.y - this.y) * (creep.y - this.y)))));
if (d < this.info.r){
creep.doFreeze(this.info.damage);
this.doFreezeAnimation();
};
i++;
};
}
private function doFreezeAnimation():void{
this.makeSound();
this.addEventListener(Event.ENTER_FRAME, onFreezeAnimationEnterFrame);
}
override protected function configParams():void{
this.towerName = "Freeze Tower";
this.description = "Freeze all enemies in area";
this.r = [60, 70, 80, 90];
this.shootingRate = [1200, 1000, 800, 700];
this.damage = [500, 700, 1000, 1300];
this.gold = [30, 60, 100, 200];
this.sellTowerFor = [20, 50, 80, 120];
}
override protected function makeSound():void{
Global.soundManager.addShootSound("FreezeShoot");
}
}
}//package towers
Section 140
//MissileTower (towers.MissileTower)
package towers {
public class MissileTower extends Tower {
public function MissileTower(){
super();
}
override protected function configParams():void{
this.towerName = "Sniper Tower";
this.description = "Big range and damage but slow firing rate tower";
this.r = [150, 160, 160, 170];
this.shootingRate = [2000, 1700, 1300, 1000];
this.damage = [20, 50, 90, 150];
this.gold = [50, 150, 350, 450];
this.sellTowerFor = [30, 100, 150, 200];
}
override protected function makeSound():void{
Global.soundManager.addShootSound("MissleShoot");
}
}
}//package towers
Section 141
//RangeTower (towers.RangeTower)
package towers {
import flash.display.*;
import flash.events.*;
import creeps.*;
public class RangeTower extends Tower {
private var curFrame:Number;// = 0
public var rangeTurret:MovieClip;
private var rangeAnimationFrames:Number;// = 5
private var rangeAnimation:Sprite;
public function RangeTower(){
rangeAnimationFrames = 5;
curFrame = 0;
super();
this.rangeAnimation = new Sprite();
this.rangeAnimation.graphics.lineStyle(1, 0xFF0000);
this.addChild(this.rangeAnimation);
}
private function doRangeDamageAnimation():void{
this.makeSound();
this.addEventListener(Event.ENTER_FRAME, doRangeDamageAnimationEnterFrame);
this.rangeTurret.play();
}
private function doRangeDamageAnimationEnterFrame(e:Event):void{
this.rangeAnimation.visible = true;
this.curFrame++;
if (this.curFrame > this.rangeAnimationFrames){
this.removeEventListener(Event.ENTER_FRAME, doRangeDamageAnimationEnterFrame);
this.curFrame = 0;
this.rangeAnimation.graphics.clear();
return;
};
this.rangeAnimation.graphics.clear();
trace("!");
this.rangeAnimation.graphics.lineStyle(1, 0xFF0000);
this.rangeAnimation.graphics.drawCircle(0, 0, Math.floor(((this.curFrame / this.rangeAnimationFrames) * this.info.r)));
}
override protected function tick(e:TimerEvent):void{
var i:Number;
var creep:Creep;
var d:Number;
if (Global.isDoubleSpeed == false){
if ((this.timer.currentCount % 2) == 0){
return;
};
};
i = 0;
while (i < this.creepsContainer.numChildren) {
creep = (this.creepsContainer.getChildAt(i) as Creep);
d = Math.floor(Math.sqrt((((creep.x - this.x) * (creep.x - this.x)) + ((creep.y - this.y) * (creep.y - this.y)))));
if (d < this.info.r){
creep.doDamage(this.info.damage);
this.doRangeDamageAnimation();
};
i++;
};
}
override protected function configParams():void{
this.towerName = "Wave Tower";
this.description = "Do damage to all enemies in area";
this.r = [50, 60, 70, 80];
this.shootingRate = [1200, 1000, 800, 700];
this.damage = [5, 15, 30, 50];
this.gold = [40, 100, 300, 500];
this.sellTowerFor = [20, 50, 200, 300];
}
override protected function makeSound():void{
Global.soundManager.addShootSound("RangeShoot");
}
}
}//package towers
Section 142
//Tower (towers.Tower)
package towers {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import creeps.*;
public class Tower extends MovieClip {
public var shootingRate:Array;
protected var bullet:Bullet;
public var description:String;
public var turret:Sprite;
protected var creepsContainer:CreepsContainer;
public var cellX:Number;
public var towerName:String;
public var cellY:Number;
protected var timer:Timer;
protected var isShootingAreaShown:Boolean;// = false
protected var bulletTimer:Timer;
private var selectedSprite;
public var damage:Array;
public var level:Number;// = 0
public var r:Array;
protected var shootingArea:Sprite;
public var unplaceable:Sprite;
public var gold:Array;
public var sellTowerFor:Array;
public var info:TowerInfo;
public var upgradesLabels:MovieClip;
public var upgradeInfo:TowerInfo;
public function Tower(){
info = new TowerInfo();
upgradeInfo = new TowerInfo();
level = 0;
isShootingAreaShown = false;
super();
this.shootingArea = new Sprite();
this.configParams();
this.updateInfo();
this.updateUpgradeInfo();
this.drawShootingArea();
this.unplaceable.visible = false;
this.selectedSprite = new TowerSelectedSprite();
if (Global.gameManager != null){
Global.gameManager.addEventListener("pauseGame", onPauseGame);
Global.gameManager.addEventListener("resumeGame", onResumeGame);
};
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.upgradesLabels.stop();
}
private function onPauseGame(e:Event):void{
if (this.timer != null){
this.timer.stop();
};
}
private function onResumeGame(e:Event):void{
if (this.timer != null){
this.timer.start();
};
}
public function sellMeNow():void{
if (this.timer != null){
this.timer.stop();
this.timer.removeEventListener(TimerEvent.TIMER, tick);
this.timer = null;
};
this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.removeEventListener(MouseEvent.CLICK, onClick);
this.dispatchEvent(new Event("ImSold_RemoveMeFromField"));
}
private function updateInfo():void{
trace("towers.Tower.updateInfo");
this.info.level = (this.level + 1);
this.info.description = this.description;
this.info.gold = this.gold[this.level];
this.info.sellTowerFor = this.sellTowerFor[this.level];
this.info.damage = this.damage[this.level];
this.info.r = this.r[this.level];
this.info.name = this.towerName;
this.info.shootingRate = this.shootingRate[this.level];
this.drawShootingArea();
}
public function hideShootingArea():void{
if (this.isShootingAreaShown){
if (this.parent != null){
this.parent.removeChild(this.shootingArea);
};
this.isShootingAreaShown = false;
};
}
private function drawShootingArea():void{
this.shootingArea.graphics.clear();
this.shootingArea.graphics.lineStyle(1, 0xFFFFFF);
this.shootingArea.graphics.drawCircle(0, 0, (this.info.r - 10));
this.shootingArea.mouseEnabled = false;
}
private function onSelectTower(e:SelectTowerEvent):void{
if (e.tower == this){
Global.selectedTowerInfo.showInfo(this);
return;
};
this.doDeselectTower();
}
public function showShootingArea():void{
if (!this.isShootingAreaShown){
this.parent.addChild(this.shootingArea);
this.shootingArea.x = this.x;
this.shootingArea.y = this.y;
this.isShootingAreaShown = true;
};
}
public function showUnplaceAbleState():void{
this.unplaceable.visible = true;
}
private function doShoot(cx:Number, cy:Number):void{
this.makeSound();
this.bullet = new Bullet();
this.bullet.addEventListener("removeBullet", removeBullet);
this.bullet.fireTarget((cx - this.x), (cy - this.y));
this.addChild(this.bullet);
}
private function updateUpgradeInfo():void{
if ((this.level + 2) > 4){
this.upgradeInfo = null;
} else {
this.upgradeInfo.level = ((this.level + 1) + 1);
this.upgradeInfo.description = this.description;
this.upgradeInfo.gold = this.gold[(this.level + 1)];
this.upgradeInfo.damage = this.damage[(this.level + 1)];
this.upgradeInfo.r = this.r[(this.level + 1)];
this.upgradeInfo.name = this.towerName;
this.upgradeInfo.shootingRate = this.shootingRate[(this.level + 1)];
};
}
public function placedOnField(creepsContainer:CreepsContainer):void{
this.creepsContainer = creepsContainer;
this.timer = new Timer((this.info.shootingRate / 2), 0);
this.timer.addEventListener(TimerEvent.TIMER, tick);
if (Global.gameManager.isPaused == false){
this.timer.start();
};
Global.topMenu.addGold(-(this.info.gold));
Global.soundManager.addSFXSound("TowerPlaced");
}
public function die():void{
Global.gameManager.removeEventListener("pauseGame", onPauseGame);
Global.gameManager.removeEventListener("resumeGame", onResumeGame);
this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.removeEventListener(MouseEvent.CLICK, onClick);
Global.gameManager.removeEventListener("selectTower", onSelectTower);
this.timer.removeEventListener(TimerEvent.TIMER, tick);
}
protected function tick(e:TimerEvent):void{
var i:Number;
var creep:Creep;
var d:Number;
var angel:Number;
if (Global.isDoubleSpeed == false){
if ((this.timer.currentCount % 2) == 0){
return;
};
};
i = 0;
while (i < this.creepsContainer.numChildren) {
creep = (this.creepsContainer.getChildAt(i) as Creep);
d = Math.floor(Math.sqrt((((creep.x - this.x) * (creep.x - this.x)) + ((creep.y - this.y) * (creep.y - this.y)))));
if (d < this.info.r){
creep.doDamage(this.info.damage);
this.doShoot(creep.x, creep.y);
if (this.turret != null){
angel = Math.asin(((creep.x - this.x) / d));
angel = Math.floor((57.2957 * angel));
if ((creep.y - this.y) > 0){
angel = (180 - angel);
};
this.turret.rotation = angel;
};
return;
};
i++;
};
}
protected function configParams():void{
this.towerName = "Cannon Tower";
this.description = "Firing with bullets.";
this.r = [60, 70, 80, 90];
this.shootingRate = [300, 280, 260, 240];
this.damage = [7, 12, 20, 35];
this.gold = [25, 50, 70, 150];
this.sellTowerFor = [10, 40, 60, 100];
}
private function removeBullet(e:Event):void{
if (this.contains(this.bullet)){
this.removeChild(this.bullet);
};
}
private function onAddedToStage(e:Event):void{
this.addEventListener(MouseEvent.CLICK, onClick);
if (Global.gameManager != null){
Global.gameManager.addEventListener("selectTower", onSelectTower);
};
if (this.turret != null){
this.turret.rotation = Math.floor((Math.random() * 360));
};
}
public function doDeselectTower(e:Event=null):void{
var e = e;
this.removeChild(this.selectedSprite);
//unresolved jump
var _slot1 = e;
this.hideShootingArea();
}
public function hideUnplaceAbleState():void{
this.unplaceable.visible = false;
}
protected function makeSound():void{
Global.soundManager.addShootSound("TowerShoot");
}
public function levelUp():void{
this.level++;
if (this.level > 3){
return;
};
this.upgradesLabels.gotoAndStop((this.upgradesLabels.currentFrame + 1));
this.updateInfo();
this.updateUpgradeInfo();
if (this.timer != null){
this.timer.stop();
this.timer.removeEventListener(TimerEvent.TIMER, tick);
this.timer = null;
};
this.timer = new Timer((this.info.shootingRate / 2), 0);
this.timer.addEventListener(TimerEvent.TIMER, tick);
if (Global.gameManager.isPaused == false){
this.timer.start();
};
}
private function onClick(e:MouseEvent):void{
var selectTowerEvent:SelectTowerEvent;
this.doTowerSelected();
if (Global.gameManager != null){
selectTowerEvent = new SelectTowerEvent("selectTower");
selectTowerEvent.tower = this;
Global.gameManager.dispatchEvent(selectTowerEvent);
};
}
override public function set y(value:Number):void{
super.y = value;
this.shootingArea.y = value;
}
override public function set x(value:Number):void{
super.x = value;
this.shootingArea.x = value;
}
private function doTowerSelected():void{
this.addChild(this.selectedSprite);
this.showShootingArea();
}
}
}//package towers
Section 143
//TowerInfo (towers.TowerInfo)
package towers {
public class TowerInfo {
public var gold:Number;
public var shootingRate:Number;
public var name:String;
public var r:Number;
public var level:Number;
public var damage:Number;
public var sellTowerFor:Number;
public var description:String;
public function TowerInfo(){
super();
}
}
}//package towers
Section 144
//Appear1 (Appear1)
package {
import flash.media.*;
public dynamic class Appear1 extends Sound {
public function Appear1(){
super();
}
}
}//package
Section 145
//Appear2 (Appear2)
package {
import flash.media.*;
public dynamic class Appear2 extends Sound {
public function Appear2(){
super();
}
}
}//package
Section 146
//Appear3 (Appear3)
package {
import flash.media.*;
public dynamic class Appear3 extends Sound {
public function Appear3(){
super();
}
}
}//package
Section 147
//Appear4 (Appear4)
package {
import flash.media.*;
public dynamic class Appear4 extends Sound {
public function Appear4(){
super();
}
}
}//package
Section 148
//Appear5 (Appear5)
package {
import flash.media.*;
public dynamic class Appear5 extends Sound {
public function Appear5(){
super();
}
}
}//package
Section 149
//Appear6 (Appear6)
package {
import flash.media.*;
public dynamic class Appear6 extends Sound {
public function Appear6(){
super();
}
}
}//package
Section 150
//Appear7 (Appear7)
package {
import flash.media.*;
public dynamic class Appear7 extends Sound {
public function Appear7(){
super();
}
}
}//package
Section 151
//Bar_Castle (Bar_Castle)
package {
import castle.*;
public dynamic class Bar_Castle extends Bar {
public function Bar_Castle(){
super();
}
}
}//package
Section 152
//BaseDamages (BaseDamages)
package {
import flash.media.*;
public dynamic class BaseDamages extends Sound {
public function BaseDamages(){
super();
}
}
}//package
Section 153
//BaseUpgradeButton_disabledSkin (BaseUpgradeButton_disabledSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_disabledSkin extends MovieClip {
public function BaseUpgradeButton_disabledSkin(){
super();
}
}
}//package
Section 154
//BaseUpgradeButton_downSkin (BaseUpgradeButton_downSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_downSkin extends MovieClip {
public function BaseUpgradeButton_downSkin(){
super();
}
}
}//package
Section 155
//BaseUpgradeButton_overSkin (BaseUpgradeButton_overSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_overSkin extends MovieClip {
public function BaseUpgradeButton_overSkin(){
super();
}
}
}//package
Section 156
//BaseUpgradeButton_selectedDisabledSkin (BaseUpgradeButton_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_selectedDisabledSkin extends MovieClip {
public function BaseUpgradeButton_selectedDisabledSkin(){
super();
}
}
}//package
Section 157
//BaseUpgradeButton_selectedDownSkin (BaseUpgradeButton_selectedDownSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_selectedDownSkin extends MovieClip {
public function BaseUpgradeButton_selectedDownSkin(){
super();
}
}
}//package
Section 158
//BaseUpgradeButton_selectedOverSkin (BaseUpgradeButton_selectedOverSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_selectedOverSkin extends MovieClip {
public function BaseUpgradeButton_selectedOverSkin(){
super();
}
}
}//package
Section 159
//BaseUpgradeButton_selectedUpSkin (BaseUpgradeButton_selectedUpSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_selectedUpSkin extends MovieClip {
public function BaseUpgradeButton_selectedUpSkin(){
super();
}
}
}//package
Section 160
//BaseUpgradeButton_upSkin (BaseUpgradeButton_upSkin)
package {
import flash.display.*;
public dynamic class BaseUpgradeButton_upSkin extends MovieClip {
public function BaseUpgradeButton_upSkin(){
super();
}
}
}//package
Section 161
//BaseUpgradeWindow (BaseUpgradeWindow)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class BaseUpgradeWindow extends Sprite {
public var upgradeCost:Array;
public var upgrade02:Button2;
public var upgrade04:Button2;
public var upgrade03:Button2;
public var upgrade01:Button2;
public var upgrade14:Button2;
public var upgrade11:Button2;
public var upgrade12:Button2;
public var upgrade13:Button2;
public var doneButton:SimpleButton;
public var upgrade23:Button2;
public var upgrade22:Button2;
public var upgrade21:Button2;
public var currentExpDT:TextField;
public var upgrade24:Button2;
public var upgrade32:Button2;
public var upgrade33:Button2;
public var upgrade34:Button2;
public var upgrade41:Button2;
public var upgrade42:Button2;
public var upgrade31:Button2;
public var upgrade44:Button2;
public var upgrade43:Button2;
public function BaseUpgradeWindow(){
var i:*;
var t:Number;
var bb:Button2;
upgradeCost = [[150, 250, 500, 1000], [150, 250, 500, 1000], [150, 250, 500, 1000], [150, 250, 500, 1000], [150, 250, 500, 1000]];
super();
doneButton.addEventListener(MouseEvent.CLICK, onDoneButonClick);
i = 0;
while (i <= 4) {
t = 1;
while (t <= 4) {
bb = this[(("upgrade" + i) + t)];
bb.upgradeN = i;
bb.levelN = t;
bb.addEventListener("update", update);
t++;
};
i++;
};
}
private function onDoneButonClick(e:MouseEvent):void{
Global.gameManager.hideBaseUpgradeWindow();
}
public function update(e:Event=null):void{
var i:*;
var lev:Number;
var t:Number;
var bb:Button2;
this.currentExpDT.text = Global.baseUpgradeData.currentExpirience.toString();
i = 0;
while (i <= 4) {
lev = Global.baseUpgradeData[("upgrade" + i)];
trace("BaseUpgradeWindow.update", i, lev);
t = 1;
while (t <= 4) {
bb = this[(("upgrade" + i) + t)];
bb.expCost = Global.baseUpgradeData[(("upgrade" + i) + "ExpCost")][(t - 1)];
if (t <= lev){
bb.selected = true;
bb.enabled = false;
};
if (t == (lev + 1)){
if (bb.expCost < Global.baseUpgradeData.currentExpirience){
bb.enabled = true;
};
};
if (t > (lev + 1)){
bb.enabled = false;
};
t++;
};
i++;
};
i = 0;
while (i <= 4) {
t = 1;
while (t <= 4) {
bb = this[(("upgrade" + i) + t)];
t++;
};
i++;
};
}
}
}//package
Section 162
//BG (BG)
package {
import flash.display.*;
public class BG extends Sprite {
public function BG(){
super();
trace("BG");
}
}
}//package
Section 163
//BGJupiter (BGJupiter)
package {
import flash.display.*;
public dynamic class BGJupiter extends MovieClip {
public function BGJupiter(){
super();
}
}
}//package
Section 164
//BGMars (BGMars)
package {
import flash.display.*;
public dynamic class BGMars extends MovieClip {
public function BGMars(){
super();
}
}
}//package
Section 165
//BGMercury (BGMercury)
package {
import flash.display.*;
public dynamic class BGMercury extends MovieClip {
public function BGMercury(){
super();
}
}
}//package
Section 166
//BGMoon (BGMoon)
package {
import flash.display.*;
public dynamic class BGMoon extends MovieClip {
public function BGMoon(){
super();
}
}
}//package
Section 167
//BGPluto (BGPluto)
package {
import flash.display.*;
public dynamic class BGPluto extends MovieClip {
public function BGPluto(){
super();
}
}
}//package
Section 168
//BGVenus (BGVenus)
package {
import flash.display.*;
public dynamic class BGVenus extends MovieClip {
public function BGVenus(){
super();
}
}
}//package
Section 169
//Bullet (Bullet)
package {
import flash.display.*;
import flash.events.*;
public class Bullet extends Sprite {
public var currentCount:Number;// = 0
public var maxCounts:Number;// = 3
private var targetY:Number;
private var targetX:Number;
public function Bullet(){
currentCount = 0;
maxCounts = 3;
super();
}
private function onBulletEnterFrame(e:Event):void{
var e = e;
this.currentCount++;
this.x = Math.floor(((targetX / this.maxCounts) * this.currentCount));
this.y = Math.floor(((targetY / this.maxCounts) * this.currentCount));
if (this.currentCount >= this.maxCounts){
this.removeEventListener(Event.ENTER_FRAME, onBulletEnterFrame);
this.dispatchEvent(new Event("removeBullet"));
};
if (this.currentCount >= this.maxCounts){
this.parent.removeChild(this);
//unresolved jump
var _slot1 = e;
};
}
public function fireTarget(tx:Number, ty:Number):void{
this.targetX = tx;
this.targetY = ty;
this.addEventListener(Event.ENTER_FRAME, onBulletEnterFrame);
}
}
}//package
Section 170
//Button_disabledSkin (Button_disabledSkin)
package {
import flash.display.*;
public dynamic class Button_disabledSkin extends MovieClip {
public function Button_disabledSkin(){
super();
}
}
}//package
Section 171
//Button_downSkin (Button_downSkin)
package {
import flash.display.*;
public dynamic class Button_downSkin extends MovieClip {
public function Button_downSkin(){
super();
}
}
}//package
Section 172
//Button_emphasizedSkin (Button_emphasizedSkin)
package {
import flash.display.*;
public dynamic class Button_emphasizedSkin extends MovieClip {
public function Button_emphasizedSkin(){
super();
}
}
}//package
Section 173
//Button_overSkin (Button_overSkin)
package {
import flash.display.*;
public dynamic class Button_overSkin extends MovieClip {
public function Button_overSkin(){
super();
}
}
}//package
Section 174
//Button_selectedDisabledSkin (Button_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDisabledSkin extends MovieClip {
public function Button_selectedDisabledSkin(){
super();
}
}
}//package
Section 175
//Button_selectedDownSkin (Button_selectedDownSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDownSkin extends MovieClip {
public function Button_selectedDownSkin(){
super();
}
}
}//package
Section 176
//Button_selectedOverSkin (Button_selectedOverSkin)
package {
import flash.display.*;
public dynamic class Button_selectedOverSkin extends MovieClip {
public function Button_selectedOverSkin(){
super();
}
}
}//package
Section 177
//Button_selectedUpSkin (Button_selectedUpSkin)
package {
import flash.display.*;
public dynamic class Button_selectedUpSkin extends MovieClip {
public function Button_selectedUpSkin(){
super();
}
}
}//package
Section 178
//Button_upSkin (Button_upSkin)
package {
import flash.display.*;
public dynamic class Button_upSkin extends MovieClip {
public function Button_upSkin(){
super();
}
}
}//package
Section 179
//Button2 (Button2)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class Button2 extends Sprite {
private var _enabled:Boolean;
public var button:Button;
private var _expCost:Number;
public var levelN:Number;
public var dt:TextField;
public var upgradeN:Number;
private var _selected:Boolean;
public function Button2(){
super();
this.dt.mouseEnabled = false;
this.configButton(this.button);
this.button.addEventListener(MouseEvent.CLICK, onClick);
__setProp_button_Button2_Layer1_1();
}
private function configButton(bb:Button):void{
bb.setStyle("upSkin", "BaseUpgradeButton_upSkin");
bb.setStyle("overSkin", "BaseUpgradeButton_overSkin");
bb.setStyle("downSkin", "BaseUpgradeButton_downSkin");
bb.setStyle("disabledSkin", "BaseUpgradeButton_disabledSkin");
bb.setStyle("selectedDisabledSkin", "BaseUpgradeButton_selectedDisabledSkin");
bb.setStyle("selectedUpSkin", "BaseUpgradeButton_selectedUpSkin");
bb.setStyle("selectedDownSkin", "BaseUpgradeButton_selectedDownSkin");
bb.setStyle("selectedOverSkin", "BaseUpgradeButton_selectedOverSkin");
bb.setStyle("focusRectSkin", null);
bb.toggle = true;
}
public function set expCost(value:Number):void{
_expCost = value;
this.dt.text = value.toString();
if (value > Global.baseUpgradeData.currentExpirience){
this.button.enabled = false;
};
}
public function set selected(value:Boolean):void{
_selected = value;
this.button.selected = value;
}
public function get enabled():Boolean{
return (_enabled);
}
function __setProp_button_Button2_Layer1_1(){
button["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
button.emphasized = false;
button.enabled = true;
button.label = "";
button.labelPlacement = "right";
button.selected = false;
button.toggle = true;
button.visible = true;
button["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function set enabled(value:Boolean):void{
_enabled = value;
this.button.enabled = value;
}
public function get expCost():Number{
return (_expCost);
}
public function get selected():Boolean{
return (_selected);
}
private function onClick(e:MouseEvent):void{
trace("Button2.onClick");
this.button.selected = true;
this.button.enabled = false;
var _local2 = Global.baseUpgradeData;
var _local3 = ("upgrade" + upgradeN);
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
Global.baseUpgradeData.currentExpirience = (Global.baseUpgradeData.currentExpirience - this._expCost);
this.dispatchEvent(new Event("update"));
}
}
}//package
Section 180
//CastleLayer (CastleLayer)
package {
import flash.display.*;
import castle.*;
public class CastleLayer extends MovieClip {
public var castle:Castle;
public function CastleLayer(){
super();
this.castle = new Castle();
Global.castle = this.castle;
this.addChild(castle);
}
public function setField(f:Field):void{
this.castle.x = (((f.targetPoint.x - 1) * 30) + f.x);
this.castle.y = (((f.targetPoint.y + 1) * 30) + f.y);
}
}
}//package
Section 181
//CellTypes (CellTypes)
package {
public class CellTypes {
public static const RIGHT_TO_DOWN:Number = 6;
public static const LEFT_TO_UP:Number = 4;
public static const START:Number = 7;
public static const ROAD_HORIZONTAL:Number = 2;
public static const TARGET:Number = 8;
public static const LEFT_TO_DOWN:Number = 5;
public static const ROAD_VERTICAL:Number = 10;
public static const FIELD:Number = 1;
public static const RIGHT_TO_UP:Number = 3;
public function CellTypes(){
super();
}
}
}//package
Section 182
//CheckBox_disabledIcon (CheckBox_disabledIcon)
package {
import flash.display.*;
public dynamic class CheckBox_disabledIcon extends MovieClip {
public function CheckBox_disabledIcon(){
super();
}
}
}//package
Section 183
//CheckBox_downIcon (CheckBox_downIcon)
package {
import flash.display.*;
public dynamic class CheckBox_downIcon extends MovieClip {
public function CheckBox_downIcon(){
super();
}
}
}//package
Section 184
//CheckBox_overIcon (CheckBox_overIcon)
package {
import flash.display.*;
public dynamic class CheckBox_overIcon extends MovieClip {
public function CheckBox_overIcon(){
super();
}
}
}//package
Section 185
//CheckBox_selectedDisabledIcon (CheckBox_selectedDisabledIcon)
package {
import flash.display.*;
public dynamic class CheckBox_selectedDisabledIcon extends MovieClip {
public function CheckBox_selectedDisabledIcon(){
super();
}
}
}//package
Section 186
//CheckBox_selectedDownIcon (CheckBox_selectedDownIcon)
package {
import flash.display.*;
public dynamic class CheckBox_selectedDownIcon extends MovieClip {
public function CheckBox_selectedDownIcon(){
super();
}
}
}//package
Section 187
//CheckBox_selectedOverIcon (CheckBox_selectedOverIcon)
package {
import flash.display.*;
public dynamic class CheckBox_selectedOverIcon extends MovieClip {
public function CheckBox_selectedOverIcon(){
super();
}
}
}//package
Section 188
//CheckBox_selectedUpIcon (CheckBox_selectedUpIcon)
package {
import flash.display.*;
public dynamic class CheckBox_selectedUpIcon extends MovieClip {
public function CheckBox_selectedUpIcon(){
super();
}
}
}//package
Section 189
//CheckBox_upIcon (CheckBox_upIcon)
package {
import flash.display.*;
public dynamic class CheckBox_upIcon extends MovieClip {
public function CheckBox_upIcon(){
super();
}
}
}//package
Section 190
//Consol (Consol)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class Consol extends MovieClip {
public var dt:TextField;
public function Consol(){
var tf:TextFormat;
super();
tf = new TextFormat();
this.dt.multiline = true;
this.dt.setTextFormat(tf);
this.dt.addEventListener(Event.CHANGE, onChange);
}
private function onChange(e:Event):void{
}
public function t(s:String, textColor:Number=0):void{
switch (textColor){
case 0:
this.dt.htmlText = (this.dt.htmlText + ((("<font color='#000000'>" + s) + "</font>") + "\n"));
break;
case 1:
this.dt.htmlText = (this.dt.htmlText + ((("<font color='#000066'>" + s) + "</font>") + "\n"));
break;
case 2:
this.dt.htmlText = (this.dt.htmlText + ((("<font color='#005114'>" + s) + "</font>") + "\n"));
break;
case 3:
this.dt.htmlText = (this.dt.htmlText + ((("<font color='#FFCC00'>" + s) + "</font>") + "\n"));
break;
};
this.dt.scrollV = this.dt.maxScrollV;
}
public function clear():void{
this.dt.text = "";
}
public function showWelcome(n:Number):void{
var text:String;
switch (n){
case 1:
text = " *** Welcome to <b>Moon</b>! Our scientists developed special weapon - Ion cannon. You can use it by mouse click or press '1' on keyboard.";
text = (text + " You can upgrade it after each level. But now, stop them! Protect colony from invaders.");
break;
case 2:
text = " *** In astronomy mythology, <b>Mars</b> was the Roman god of war and agriculture. It is time to take a gun, Martian Farmer !";
break;
case 3:
text = " *** This giant planet has no solid surface. All structes built on spesial platforms.";
break;
case 4:
text = " *** <b>Mercury</b> - the middle of war.";
break;
case 5:
text = " *** <b>Pluto</b>. Small and distant base. But very important tactical point.";
break;
case 6:
text = " *** <b>Venus</b>. Defend last base! Victory is almost ours";
break;
};
this.t(text, 1);
}
}
}//package
Section 191
//CreditsWindow (CreditsWindow)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class CreditsWindow extends Sprite {
public var sponsorButton:SimpleButton;
public var lionButton:SimpleButton;
public var backToGame:SimpleButton;
public function CreditsWindow(){
super();
this.backToGame.addEventListener(MouseEvent.CLICK, onBackClicked);
this.sponsorButton.addEventListener(MouseEvent.CLICK, goToSponsorSite);
this.lionButton.addEventListener(MouseEvent.CLICK, goToLionSite);
}
private function goToSponsorSite(e:MouseEvent):void{
var r:URLRequest;
r = new URLRequest("http://www.gamesnow.biz/");
navigateToURL(r, "_blank");
}
private function goToLionSite(e:MouseEvent):void{
var r:URLRequest;
r = new URLRequest("http://www.lion-games.com/");
navigateToURL(r, "_blank");
}
private function onBackClicked(e:MouseEvent):void{
Global.gameManager.hideCreditsWindow();
}
}
}//package
Section 192
//CreepsContainer (CreepsContainer)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import creeps.*;
public class CreepsContainer extends Sprite {
private var towersContainer:TowersContainer;
public var creeps:Array;
private var coinContainer:Sprite;
private var field:Field;
public function CreepsContainer(){
creeps = new Array();
super();
}
private function removeCoin(e:Event):void{
var s:Sprite;
s = (e.target as Sprite);
s.removeEventListener("removeMe", removeCoin);
this.coinContainer.removeChild(s);
}
public function removeAllCreaps():void{
var i:*;
trace("CreepsContainer.removeAllCreaps");
for (i in this.creeps) {
if (this.creeps[i] != null){
if (this.creeps[i].parent != null){
this.creeps[i].parent.removeChild(this.creeps[i]);
};
this.creeps[i].prepareToDie();
this.creeps[i] = null;
};
};
}
private function removeDeadAttackCreep(e:Event):void{
var s:Sprite;
var e = e;
s = (e.target as Sprite);
this.removeChild(s);
//unresolved jump
var _slot1 = e;
}
public function setTowersContainer(c:TowersContainer):void{
this.towersContainer = c;
}
public function setCoinsContainer(c:Sprite):void{
this.coinContainer = c;
}
public function setField(f:Field):void{
this.field = f;
}
private function removeDeadCreep(e:Event):void{
var s:Sprite;
var coin:CoinForDeath;
var e = e;
s = (e.target as Sprite);
coin = new CoinForDeath();
coin.x = (s.x + 15);
coin.y = (s.y + 15);
coin.addEventListener("removeMe", removeCoin);
this.coinContainer.addChild(coin);
this.removeChild(s);
//unresolved jump
var _slot1 = e;
}
public function addCreep():Creep{
var creepClassName:Class;
var creep:Creep;
creepClassName = (getDefinitionByName(("creeps." + Global.currentWave.skin)) as Class);
creep = new (creepClassName);
creep.x = this.field.getMovements()[0].x;
creep.y = this.field.getMovements()[0].y;
creep.creep.rotation = this.field.getMovements()[1];
creep.startMove(this.field.getMovements());
this.addChild(creep);
creep.addEventListener("ImDead", removeDeadCreep);
creep.addEventListener("ImAttack", removeDeadAttackCreep);
this.creeps.push(creep);
return (creep);
}
}
}//package
Section 193
//Die1 (Die1)
package {
import flash.media.*;
public dynamic class Die1 extends Sound {
public function Die1(){
super();
}
}
}//package
Section 194
//Die2 (Die2)
package {
import flash.media.*;
public dynamic class Die2 extends Sound {
public function Die2(){
super();
}
}
}//package
Section 195
//Die3 (Die3)
package {
import flash.media.*;
public dynamic class Die3 extends Sound {
public function Die3(){
super();
}
}
}//package
Section 196
//Die4 (Die4)
package {
import flash.media.*;
public dynamic class Die4 extends Sound {
public function Die4(){
super();
}
}
}//package
Section 197
//Die5 (Die5)
package {
import flash.media.*;
public dynamic class Die5 extends Sound {
public function Die5(){
super();
}
}
}//package
Section 198
//Die6 (Die6)
package {
import flash.media.*;
public dynamic class Die6 extends Sound {
public function Die6(){
super();
}
}
}//package
Section 199
//Die7 (Die7)
package {
import flash.media.*;
public dynamic class Die7 extends Sound {
public function Die7(){
super();
}
}
}//package
Section 200
//Die8 (Die8)
package {
import flash.media.*;
public dynamic class Die8 extends Sound {
public function Die8(){
super();
}
}
}//package
Section 201
//Die9 (Die9)
package {
import flash.media.*;
public dynamic class Die9 extends Sound {
public function Die9(){
super();
}
}
}//package
Section 202
//Field (Field)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import levels.*;
import flash.geom.*;
import levels.level2.*;
import levels.level4.*;
import levels.level5.*;
import levels.level6.*;
import levels.level3.*;
import levels.level1.*;
public class Field extends MovieClip {
public var fieldMask:Sprite;
private var movementsArray:Array;
private var fieldSkinManager:FieldSkinManager;
private var startPoint:Point;
public var targetPoint:Point;
public var fieldData:FieldDataBase;
public function Field(){
movementsArray = new Array();
super();
new FieldData1();
new FieldData2();
new FieldData3();
new FieldData4();
new FieldData5();
new FieldData6();
this.mask = fieldMask;
}
private function getFieldData(n:Number):FieldDataBase{
var fieldDataClass:Class;
fieldDataClass = (getDefinitionByName(((("levels.level" + n) + ".FieldData") + n)) as Class);
return (new (fieldDataClass));
}
public function reDraw(n:Number):void{
var y:Number;
var x:Number;
var type:Number;
var mapTile:MovieClip;
y = 0;
while (y < this.fieldData.map.length) {
x = 0;
while (x < this.fieldData.map[0].length) {
type = this.fieldData.map[y][x];
if (type == CellTypes.START){
this.startPoint = new Point(x, y);
trace("START POINT FOUND", this.startPoint);
};
if (type == CellTypes.TARGET){
this.targetPoint = new Point(x, y);
};
if (type != CellTypes.FIELD){
mapTile = this.fieldSkinManager.getElementByType(type, n);
this.addChild(mapTile);
mapTile.x = (x * 30);
mapTile.y = (y * 30);
};
x++;
};
y++;
};
}
public function buildMovementsArray():void{
var position:Point;
var i:Number;
var t:String;
var el:String;
var key:String;
var value:Number;
this.movementsArray = new Array();
this.movementsArray.push(new Point(this.startPoint.x, this.startPoint.y));
position = new Point(this.startPoint.x, this.startPoint.y);
i = 0;
while (i < this.fieldData.path.length) {
el = this.fieldData.path[i];
key = el.substr(0, 1);
value = parseInt(el.substr(2));
switch (key){
case "u":
position.y = (position.y - value);
this.movementsArray.push(new Point(position.x, position.y));
break;
case "d":
position.y = (position.y + value);
this.movementsArray.push(new Point(position.x, position.y));
break;
case "r":
position.x = (position.x + value);
this.movementsArray.push(new Point(position.x, position.y));
break;
case "l":
position.x = (position.x - value);
this.movementsArray.push(new Point(position.x, position.y));
break;
case "a":
this.movementsArray.push(value);
break;
};
i++;
};
for (t in this.movementsArray) {
if ((this.movementsArray[t] is Point)){
(this.movementsArray[t] as Point).x = ((this.movementsArray[t] as Point).x * 30);
(this.movementsArray[t] as Point).y = ((this.movementsArray[t] as Point).y * 30);
(this.movementsArray[t] as Point).x = ((this.movementsArray[t] as Point).x + 15);
(this.movementsArray[t] as Point).y = ((this.movementsArray[t] as Point).y + 15);
};
};
}
public function setGameManager(g:GameManager):void{
this.addEventListener(MouseEvent.CLICK, onClick);
}
public function drawLevel(n:Number):void{
while (this.numChildren) {
this.removeChildAt(0);
};
this.fieldData = this.getFieldData(n);
this.fieldSkinManager = new FieldSkinManager();
this.addChild(this.fieldSkinManager.getBackground(n));
this.reDraw(n);
this.buildMovementsArray();
}
private function onClick(e:MouseEvent):void{
var selectTowerEvent:SelectTowerEvent;
selectTowerEvent = new SelectTowerEvent("selectTower");
selectTowerEvent.tower = null;
Global.gameManager.dispatchEvent(selectTowerEvent);
Global.selectedTowerInfo.showInfo(null);
}
public function getMovements():Array{
return (this.movementsArray);
}
}
}//package
Section 203
//FieldSkinManager (FieldSkinManager)
package {
import flash.display.*;
import flash.utils.*;
public class FieldSkinManager {
private var skin1:Skin1;
private var skin2:Skin2;
private var skin3:Skin3;
private var skin4:Skin4;
private var skin5:Skin5;
private var skin6:Skin6;
public function FieldSkinManager(){
super();
this.skin1 = new Skin1();
this.skin2 = new Skin2();
this.skin3 = new Skin3();
this.skin4 = new Skin4();
this.skin5 = new Skin5();
this.skin6 = new Skin6();
}
public function getBackground(levelN:Number):Sprite{
switch (levelN){
case 1:
return (new BGMoon());
case 2:
return (new BGMars());
case 3:
return (new BGJupiter());
case 4:
return (new BGMercury());
case 5:
return (new BGPluto());
case 6:
return (new BGVenus());
};
return (new BGMars());
}
public function getElementByType(type:Number, levelN:Number):MovieClip{
var xml:XML;
var className:*;
var currentElement:MovieClip;
xml = describeType(this[("skin" + levelN)]);
className = getDefinitionByName(xml.@name);
currentElement = new (className);
currentElement.gotoAndStop(type);
return (currentElement);
}
}
}//package
Section 204
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
public function focusRectSkin(){
super();
}
}
}//package
Section 205
//FreezeShoot (FreezeShoot)
package {
import flash.media.*;
public dynamic class FreezeShoot extends Sound {
public function FreezeShoot(){
super();
}
}
}//package
Section 206
//GameIntroWindow (GameIntroWindow)
package {
import flash.display.*;
import flash.events.*;
public class GameIntroWindow extends MovieClip {
public var optionsButton:SimpleButton;
public var creditsButton:SimpleButton;
public var playButton:SimpleButton;
public var continueButton:SimpleButton;
public function GameIntroWindow(){
super();
trace("GameIntroWindow.GameIntroWindow");
this.y = -700;
this.playButton.addEventListener(MouseEvent.CLICK, onStartButtonClick);
this.optionsButton.addEventListener(MouseEvent.CLICK, onOptionsClick);
this.creditsButton.addEventListener(MouseEvent.CLICK, onCreditsClick);
this.continueButton.addEventListener(MouseEvent.CLICK, onContinue);
}
private function onOptionsClick(e:MouseEvent):void{
Global.gameManager.showSettingsWindow();
}
private function onContinue(e:MouseEvent):void{
Global.gameManager.hideGameIntroWindow();
Global.gameManager.showIntroMovieWindow();
}
public function setContinueButtonDisable():void{
trace("GameIntroWindow.setContinueButtonDisable");
this.continueButton.enabled = false;
this.continueButton.alpha = 0.6;
this.continueButton.removeEventListener(MouseEvent.CLICK, onContinue);
}
private function onCreditsClick(e:MouseEvent):void{
Global.gameManager.showCreditsWindow();
}
private function onStartButtonClick(e:MouseEvent):void{
Global.gameManager.hideGameIntroWindow();
Global.gameManager.showIntroMovieWindow();
}
}
}//package
Section 207
//GameManager (GameManager)
package {
import flash.display.*;
import flash.events.*;
import caurina.transitions.*;
import castle.*;
public class GameManager extends EventDispatcher {
private var castleWindow:CastleWindow;
private var creditsWindow:CreditsWindow;
public var gameIntroWindow:GameIntroWindow;
private var introMovieWindow:IntroMovieWindow;
private var mainMenuWindow:MainMenuWindow;
private var levelsWindow:LevelsWindow;
private var lostLevelWindow:LostLevelWindow;
private var baseUpgradeWindow:BaseUpgradeWindow;
private var settingsWindow:SettingsWindow;
public var isPaused:Boolean;// = false
public function GameManager(){
isPaused = false;
super();
}
public function setCreditsWindow(c:CreditsWindow):void{
this.creditsWindow = c;
this.creditsWindow.y = -700;
}
public function setCastleWindow(c:CastleWindow):void{
this.castleWindow = c;
this.castleWindow.y = -700;
}
public function hideGameIntroWindow():void{
this.animateOut(this.gameIntroWindow);
}
public function animateIn(o:Sprite):void{
o.stage.addChild(o);
o.y = -700;
Tweener.addTween(o, {y:0, time:1, transition:"easeIn"});
}
public function hideIntroMovieWindow():void{
this.resumeGame();
this.animateOut(this.introMovieWindow);
}
public function setBaseUpgradeWindow(u:BaseUpgradeWindow):void{
this.baseUpgradeWindow = u;
this.baseUpgradeWindow.y = -700;
}
public function hideLevelsWindow():void{
this.resumeGame();
this.animateOut(this.levelsWindow);
}
public function showCastleWindow():void{
this.strictPauseGame();
this.animateIn(this.castleWindow);
}
public function showMainMenuWindow():void{
this.strictPauseGame();
this.animateIn(this.mainMenuWindow);
}
public function showCreditsWindow():void{
this.strictPauseGame();
this.animateIn(this.creditsWindow);
}
public function pauseGame():void{
trace("pauseGame", this.isPaused);
if (!this.isPaused){
this.isPaused = true;
this.dispatchEvent(new Event("pauseGame"));
} else {
this.resumeGame();
};
}
public function hideBaseUpgradeWindow():void{
this.animateOut(this.baseUpgradeWindow);
}
public function animateOut(o:Sprite):void{
o.y = 0;
Tweener.addTween(o, {y:-700, time:1, transition:"easeOut"});
}
public function setIntroMovieWindow(i:IntroMovieWindow):void{
this.introMovieWindow = i;
this.introMovieWindow.y = -700;
}
public function resumeGame():void{
trace("resumeGame");
if (this.isPaused){
this.isPaused = false;
this.dispatchEvent(new Event("resumeGame"));
};
}
public function hideCreditsWindow():void{
this.resumeGame();
this.animateOut(this.creditsWindow);
}
public function hideMainMenuWindow():void{
this.resumeGame();
this.animateOut(this.mainMenuWindow);
}
public function strictPauseGame():void{
trace("strictPauseGame");
if (!this.isPaused){
this.isPaused = true;
this.dispatchEvent(new Event("pauseGame"));
};
}
public function hideSettingsWindow():void{
this.resumeGame();
this.animateOut(this.settingsWindow);
}
public function showSettingsWindow():void{
this.strictPauseGame();
this.animateIn(this.settingsWindow);
}
public function showIntroMovieWindow():void{
this.strictPauseGame();
this.introMovieWindow.y = 0;
}
public function setMainMenuWindow(m:MainMenuWindow):void{
this.mainMenuWindow = m;
this.mainMenuWindow.y = -700;
}
public function showBaseUpgradeWindow():void{
this.baseUpgradeWindow.update();
this.animateIn(this.baseUpgradeWindow);
}
public function showLooseLevel():void{
trace("LOOSE LEVEL");
this.strictPauseGame();
this.lostLevelWindow.parent.addChild(this.lostLevelWindow);
this.lostLevelWindow.visible = true;
}
public function hideCastleWindow():void{
this.resumeGame();
this.animateOut(this.castleWindow);
}
public function showLevelsWindow():void{
this.strictPauseGame();
this.levelsWindow.updateLockedLevels();
this.animateIn(this.levelsWindow);
}
public function showGameIntroWindow():void{
}
public function setLevelsWindow(l:LevelsWindow):void{
this.levelsWindow = l;
}
public function setLostLevelVindow(l:LostLevelWindow):void{
this.lostLevelWindow = l;
this.lostLevelWindow.visible = false;
}
public function setSettingsWindow(s:SettingsWindow):void{
this.settingsWindow = s;
this.settingsWindow.y = -700;
}
public function setGameIntroWindow(i:GameIntroWindow):void{
this.gameIntroWindow = i;
this.gameIntroWindow.y = 0;
}
}
}//package
Section 208
//GamesNowPreloader (GamesNowPreloader)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import CPMStar.*;
import flash.net.*;
public dynamic class GamesNowPreloader extends MovieClip {
private var ad:DisplayObject;
public var button:SimpleButton;
public var loaderbar:MovieClip;
private var isGameLoaded:Boolean;// = false
private var showAdsTimer:Timer;
public var adBox:MovieClip;
private var isTimerComplete:Boolean;// = false
public function GamesNowPreloader(){
var stepp:*;
var stepdelay:*;
var CPMStarPoolID:Number;
var CPMStarSubPoolID:Number;
var CPMStarContentSpotID:String;
isTimerComplete = false;
isGameLoaded = false;
super();
stepp = 0;
stepdelay = 0;
CPMStarPoolID = 5237;
CPMStarSubPoolID = 2;
CPMStarContentSpotID = "417QEE89E20E";
this.ad = new AdLoader(CPMStarContentSpotID);
adBox.addChild(ad);
addEventListener(Event.ENTER_FRAME, Update);
button.addEventListener(MouseEvent.CLICK, onButtonClick);
this.showAdsTimer = new Timer(10000, 1);
this.showAdsTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
this.showAdsTimer.start();
}
private function onButtonClick(e:MouseEvent):void{
var r:URLRequest;
r = new URLRequest("http://www.gamesnow.biz/");
navigateToURL(r, "_blank");
}
private function doStart():void{
if (this.isGameLoaded == false){
return;
};
if (this.isTimerComplete == false){
return;
};
(this.parent as MovieClip).play();
this.removeChild(this.adBox);
}
private function timerComplete(e:TimerEvent):void{
this.isTimerComplete = true;
this.doStart();
}
public function Update(e:Event):void{
var bytesLoaded:Number;
var bytesTotal:Number;
var s:String;
var percent:Number;
bytesLoaded = stage.loaderInfo.bytesLoaded;
bytesTotal = stage.loaderInfo.bytesTotal;
s = "";
percent = 0;
if (bytesTotal > 0){
percent = Math.floor(((bytesLoaded / bytesTotal) * 100));
};
this.loaderbar.gotoAndStop((percent + 1));
if ((((bytesLoaded == bytesTotal)) || ((bytesTotal == 0)))){
removeEventListener(Event.ENTER_FRAME, Update);
trace("PARENT++++", this.parent);
this.isGameLoaded = true;
this.doStart();
};
}
}
}//package
Section 209
//Global (Global)
package {
import castle.*;
import levels.*;
public class Global {
public static var level:Number = 0;
public static var currentLevel:LevelBase;
public static var nextWave:WaveBase;
public static var consol:Consol;
public static var wave:Number = 0;
public static var currentWave:WaveBase;
public static var topMenu:TopMenu;
public static var baseUpgradeData:BaseUpgradeData;
public static var lockedLevels:Array;
public static var gameManager:GameManager;
public static var soundManager:SoundManager;
public static var gold:Number = 0;
public static var keyBoardManager:KeyBoardManager;
public static var isDoubleSpeed:Boolean = false;
public static var selectedTowerInfo:SelectedTowerInfo;
public static var castle:Castle;
public function Global(){
super();
}
}
}//package
Section 210
//IntroMovieWindow (IntroMovieWindow)
package {
import flash.display.*;
import flash.events.*;
public class IntroMovieWindow extends Sprite {
public var skipButton:SimpleButton;
public var myMask:MovieClip;
public function IntroMovieWindow(){
super();
this.skipButton.addEventListener(MouseEvent.CLICK, onSkipClick);
}
private function onSkipClick(e:MouseEvent):void{
Global.gameManager.hideIntroMovieWindow();
Global.gameManager.showLevelsWindow();
}
}
}//package
Section 211
//IonCannon (IonCannon)
package {
import flash.media.*;
public dynamic class IonCannon extends Sound {
public function IonCannon(){
super();
}
}
}//package
Section 212
//IonCannonArea (IonCannonArea)
package {
import flash.display.*;
public dynamic class IonCannonArea extends MovieClip {
public function IonCannonArea(){
super();
}
}
}//package
Section 213
//IonCannonAreaSplashDamage (IonCannonAreaSplashDamage)
package {
import flash.display.*;
public dynamic class IonCannonAreaSplashDamage extends MovieClip {
public function IonCannonAreaSplashDamage(){
super();
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 214
//KeyBoardManager (KeyBoardManager)
package {
import flash.display.*;
import flash.events.*;
import fl.managers.*;
public class KeyBoardManager extends EventDispatcher {
private var linkToStage:Stage;
private var fm:FocusManager;
public function KeyBoardManager(){
super();
}
private function onKeyDown(e:KeyboardEvent):void{
trace(("keyDownHandler: " + e.keyCode));
switch (e.keyCode){
case 49:
this.dispatchEvent(new Event("spell1"));
break;
case 50:
this.dispatchEvent(new Event("spell2"));
break;
case 51:
this.dispatchEvent(new Event("spell3"));
break;
case 52:
this.dispatchEvent(new Event("spell4"));
break;
};
}
public function setLinkToStage(linkTostage:Stage):void{
this.linkToStage = linkTostage;
this.linkToStage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
this.fm = new FocusManager(Global.consol.stage);
}
}
}//package
Section 215
//LevelButton_disabledSkin (LevelButton_disabledSkin)
package {
import flash.display.*;
public dynamic class LevelButton_disabledSkin extends MovieClip {
public function LevelButton_disabledSkin(){
super();
}
}
}//package
Section 216
//LevelButton_downSkin (LevelButton_downSkin)
package {
import flash.display.*;
public dynamic class LevelButton_downSkin extends MovieClip {
public function LevelButton_downSkin(){
super();
}
}
}//package
Section 217
//LevelButton_overSkin (LevelButton_overSkin)
package {
import flash.display.*;
public dynamic class LevelButton_overSkin extends MovieClip {
public function LevelButton_overSkin(){
super();
}
}
}//package
Section 218
//LevelButton_selectedDisabledSkin (LevelButton_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class LevelButton_selectedDisabledSkin extends MovieClip {
public function LevelButton_selectedDisabledSkin(){
super();
}
}
}//package
Section 219
//LevelButton_selectedDownSkin (LevelButton_selectedDownSkin)
package {
import flash.display.*;
public dynamic class LevelButton_selectedDownSkin extends MovieClip {
public function LevelButton_selectedDownSkin(){
super();
}
}
}//package
Section 220
//LevelButton_selectedOverSkin (LevelButton_selectedOverSkin)
package {
import flash.display.*;
public dynamic class LevelButton_selectedOverSkin extends MovieClip {
public function LevelButton_selectedOverSkin(){
super();
}
}
}//package
Section 221
//LevelButton_selectedUpSkin (LevelButton_selectedUpSkin)
package {
import flash.display.*;
public dynamic class LevelButton_selectedUpSkin extends MovieClip {
public function LevelButton_selectedUpSkin(){
super();
}
}
}//package
Section 222
//LevelButton_upSkin (LevelButton_upSkin)
package {
import flash.display.*;
public dynamic class LevelButton_upSkin extends MovieClip {
public function LevelButton_upSkin(){
super();
}
}
}//package
Section 223
//LevelsWindow (LevelsWindow)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
public class LevelsWindow extends MovieClip {
public var level2Button:Button;
public var level6Button:Button;
public var startLevelButton:SimpleButton;
public var level3Button:Button;
public var upgradeButton:SimpleButton;
public var level4Button:Button;
public var level5Button:Button;
public var level1Button:Button;
public function LevelsWindow(){
var i:Number;
var bb:Button;
super();
startLevelButton.addEventListener(MouseEvent.CLICK, onStartLevelClick);
upgradeButton.addEventListener(MouseEvent.CLICK, upgradeBaseButton);
i = 1;
while (i <= 6) {
bb = this[(("level" + i) + "Button")];
this.configLevelButton(bb);
bb.addEventListener(MouseEvent.CLICK, onLevelButtonClick);
i++;
};
__setProp_level4Button_LevelsWindow_content_1();
__setProp_level5Button_LevelsWindow_content_1();
__setProp_level6Button_LevelsWindow_content_1();
__setProp_level2Button_LevelsWindow_content_1();
__setProp_level3Button_LevelsWindow_content_1();
__setProp_level1Button_LevelsWindow_content_1();
}
public function getSelectedLevel():Number{
var i:Number;
var bb:Button;
i = 1;
while (i <= 6) {
bb = this[(("level" + i) + "Button")];
if (bb.selected == true){
return (i);
};
i++;
};
return (1);
}
function __setProp_level4Button_LevelsWindow_content_1(){
level4Button["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
level4Button.emphasized = false;
level4Button.enabled = true;
level4Button.label = "";
level4Button.labelPlacement = "right";
level4Button.selected = false;
level4Button.toggle = true;
level4Button.visible = true;
level4Button["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function configLevelButton(bb:Button):void{
bb.toggle = true;
bb.setStyle("upSkin", "LevelButton_upSkin");
bb.setStyle("overSkin", "LevelButton_overSkin");
bb.setStyle("downSkin", "LevelButton_downSkin");
bb.setStyle("disabledSkin", "LevelButton_disabledSkin");
bb.setStyle("selectedDisabledSkin", "LevelButton_selectedDisabledSkin");
bb.setStyle("selectedUpSkin", "LevelButton_selectedUpSkin");
bb.setStyle("selectedDownSkin", "LevelButton_selectedDownSkin");
bb.setStyle("selectedOverSkin", "LevelButton_selectedOverSkin");
bb.setStyle("focusRectSkin", null);
}
private function onLevelButtonClick(e:MouseEvent):void{
var i:Number;
var bb:Button;
trace(e.target.name, e.target.selected);
if (e.target.selected == false){
e.target.selected = true;
};
if (e.target.selected == true){
i = 1;
while (i <= 6) {
bb = this[(("level" + i) + "Button")];
bb.selected = false;
i++;
};
e.target.selected = true;
};
}
function __setProp_level6Button_LevelsWindow_content_1(){
level6Button["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
level6Button.emphasized = false;
level6Button.enabled = true;
level6Button.label = "";
level6Button.labelPlacement = "right";
level6Button.selected = false;
level6Button.toggle = true;
level6Button.visible = true;
level6Button["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onStartLevelClick(e:MouseEvent):void{
Global.gameManager.hideLevelsWindow();
this.dispatchEvent(new Event("startLevel"));
}
function __setProp_level1Button_LevelsWindow_content_1(){
level1Button["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
level1Button.emphasized = false;
level1Button.enabled = true;
level1Button.label = " ";
level1Button.labelPlacement = "right";
level1Button.selected = false;
level1Button.toggle = true;
level1Button.visible = true;
level1Button["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function upgradeBaseButton(e:MouseEvent):void{
Global.gameManager.showBaseUpgradeWindow();
}
function __setProp_level3Button_LevelsWindow_content_1(){
level3Button["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
level3Button.emphasized = false;
level3Button.enabled = true;
level3Button.label = "";
level3Button.labelPlacement = "right";
level3Button.selected = false;
level3Button.toggle = true;
level3Button.visible = true;
level3Button["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function updateLockedLevels():void{
var i:Number;
var bb:Button;
var flag:Boolean;
i = 1;
while (i <= 6) {
bb = this[(("level" + i) + "Button")];
if (Global.lockedLevels[(i - 1)] == 0){
flag = true;
} else {
flag = false;
};
bb.enabled = flag;
bb.selected = false;
i++;
};
this.level1Button.selected = true;
}
function __setProp_level5Button_LevelsWindow_content_1(){
level5Button["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
level5Button.emphasized = false;
level5Button.enabled = true;
level5Button.label = "";
level5Button.labelPlacement = "right";
level5Button.selected = false;
level5Button.toggle = true;
level5Button.visible = true;
level5Button["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
function __setProp_level2Button_LevelsWindow_content_1(){
level2Button["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
level2Button.emphasized = false;
level2Button.enabled = true;
level2Button.label = "";
level2Button.labelPlacement = "right";
level2Button.selected = false;
level2Button.toggle = true;
level2Button.visible = true;
level2Button["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
}
}//package
Section 224
//LocalSaver (LocalSaver)
package {
import flash.utils.*;
import com.hurlant.crypto.symmetric.*;
import com.hurlant.crypto.prng.*;
import com.hurlant.crypto.*;
import flash.net.*;
public class LocalSaver {
public function LocalSaver(){
super();
}
public function encryptedSave(ll0:Number, ll1:Number, ll2:Number, ll3:Number, ll4:Number, ll5:Number, expirience:Number, u0:Number, u1:Number, u2:Number, u3:Number, u4:Number):void{
var so:SharedObject;
var key:ByteArray;
var random:Random;
var cleartextBytes:ByteArray;
var aes:ICipher;
var dataToStore:ByteArray;
so = SharedObject.getLocal("SBD");
key = new ByteArray();
random = new Random();
random.nextBytes(key, 16);
cleartextBytes = new ByteArray();
cleartextBytes.writeUTF(ll0.toString(10));
cleartextBytes.writeUTF(ll1.toString(10));
cleartextBytes.writeUTF(ll2.toString(10));
cleartextBytes.writeUTF(ll3.toString(10));
cleartextBytes.writeUTF(ll4.toString(10));
cleartextBytes.writeUTF(ll5.toString(10));
cleartextBytes.writeUTF(expirience.toString(10));
cleartextBytes.writeUTF(u0.toString(10));
cleartextBytes.writeUTF(u1.toString(10));
cleartextBytes.writeUTF(u2.toString(10));
cleartextBytes.writeUTF(u3.toString(10));
cleartextBytes.writeUTF(u4.toString(10));
aes = Crypto.getCipher("aes-ecb", key, Crypto.getPad("pkcs5"));
aes.encrypt(cleartextBytes);
dataToStore = new ByteArray();
dataToStore.writeBytes(key);
dataToStore.writeBytes(cleartextBytes);
so.data.ws_creds = dataToStore;
so.flush();
}
public function encryptedLoad():Object{
var so:SharedObject;
var dataToLoad:ByteArray;
var key:ByteArray;
var encryptedBytes:ByteArray;
var aes:ICipher;
var ll0:Number;
var ll1:Number;
var ll2:Number;
var ll3:Number;
var ll4:Number;
var ll5:Number;
var expirience:Number;
var u0:Number;
var u1:Number;
var u2:Number;
var u3:Number;
var u4:Number;
var lockedLevel:Array;
var upgrades:Array;
so = SharedObject.getLocal("SBD");
dataToLoad = so.data.ws_creds;
key = new ByteArray();
if (dataToLoad == null){
return ({level:1, score:0});
};
dataToLoad.readBytes(key, 0, 16);
encryptedBytes = new ByteArray();
dataToLoad.readBytes(encryptedBytes);
aes = Crypto.getCipher("aes-ecb", key, Crypto.getPad("pkcs5"));
aes.decrypt(encryptedBytes);
encryptedBytes.position = 0;
ll0 = parseInt(encryptedBytes.readUTF());
ll1 = parseInt(encryptedBytes.readUTF());
ll2 = parseInt(encryptedBytes.readUTF());
ll3 = parseInt(encryptedBytes.readUTF());
ll4 = parseInt(encryptedBytes.readUTF());
ll5 = parseInt(encryptedBytes.readUTF());
expirience = parseInt(encryptedBytes.readUTF());
u0 = parseInt(encryptedBytes.readUTF());
u1 = parseInt(encryptedBytes.readUTF());
u2 = parseInt(encryptedBytes.readUTF());
u3 = parseInt(encryptedBytes.readUTF());
u4 = parseInt(encryptedBytes.readUTF());
lockedLevel = new Array();
lockedLevel.push(ll0);
lockedLevel.push(ll1);
lockedLevel.push(ll2);
lockedLevel.push(ll3);
lockedLevel.push(ll4);
lockedLevel.push(ll5);
upgrades = new Array();
upgrades.push(u0);
upgrades.push(u1);
upgrades.push(u2);
upgrades.push(u3);
upgrades.push(u4);
if (isNaN(ll0)){
return (null);
};
return ({lockedLevels:lockedLevel, exp:expirience, upgrades:upgrades});
}
}
}//package
Section 225
//LostLevelWindow (LostLevelWindow)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
public class LostLevelWindow extends Sprite {
public var tryAnotherButton:Button;
public function LostLevelWindow(){
super();
this.tryAnotherButton.addEventListener(MouseEvent.CLICK, onClick);
__setProp_tryAnotherButton_LostLevelWindow_Layer2_1();
}
function __setProp_tryAnotherButton_LostLevelWindow_Layer2_1(){
tryAnotherButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
tryAnotherButton.emphasized = false;
tryAnotherButton.enabled = true;
tryAnotherButton.label = "Upgrade and try again";
tryAnotherButton.labelPlacement = "right";
tryAnotherButton.selected = false;
tryAnotherButton.toggle = false;
tryAnotherButton.visible = true;
tryAnotherButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onClick(e:MouseEvent):void{
Global.gameManager.showLevelsWindow();
Global.gameManager.showBaseUpgradeWindow();
this.visible = false;
}
}
}//package
Section 226
//Main (Main)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import castle.*;
import tower_menu.*;
import spells.*;
import flash.net.*;
public class Main extends MovieClip {
public var gameIntroWindow:GameIntroWindow;
public var lostWindow:LostLevelWindow;
public var levelsWindow:LevelsWindow;
public var waveData:WaveData;
public var __setPropDict:Dictionary;
public var castleLayer_mc:CastleLayer;
public var topMenu:TopMenu;
public var __id0_:Button;
public var showTip:SimpleButton;
public var moreGames:SimpleButton;
public var creditsButton:SimpleButton;
public var mainMenu:Button;
public var consol:Consol;
public var mainMenuWindow:MainMenuWindow;
public var spellIcons:SpellIcons;
public var sponsorButton:SimpleButton;
public var doubleSpeed:RadioButton;
private var coinContainer:Sprite;
public var field:Field;
public var castleWindow:CastleWindow;
public var towersMenu:TowersMenu;
public var towersContainer:TowersContainer;
private var creepsContainer:CreepsContainer;
public var creditsWindow:CreditsWindow;
public var settingsButton:SimpleButton;
public var tips:Tips;
private var castleLayer:CastleLayer;
public var introMovieWindow:IntroMovieWindow;
public var _mochiads_game_id:String;// = "45853db77358865a"
public var gameSpeed:Button;
public var startWaveButton:Button;
public var normalSpeed:RadioButton;
public var selectedTowerInfo_mc:SelectedTowerInfo;
private var keyboardManager:KeyBoardManager;
public var wavesPreview:WavesPreview;
private var temp:Timer;
public var baseUpgradeWindow:BaseUpgradeWindow;
public var improvementsButton:Button;
private var localSaver:LocalSaver;
public var settingsWindow:SettingsWindow;
public function Main(){
__setPropDict = new Dictionary(true);
_mochiads_game_id = "45853db77358865a";
localSaver = new LocalSaver();
coinContainer = new Sprite();
tips = new Tips();
super();
addFrameScript(0, frame1, 2, frame3);
}
private function onMainMenuClick(e:MouseEvent):void{
Global.gameManager.showMainMenuWindow();
}
function __setProp_normalSpeed_Scene1_Layer29_3(){
normalSpeed["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
normalSpeed.enabled = true;
normalSpeed.groupName = "RadioButtonGroup";
normalSpeed.label = "x1";
normalSpeed.labelPlacement = "right";
normalSpeed.selected = true;
normalSpeed.value = "";
normalSpeed.visible = true;
normalSpeed["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function startLevel(n:Number):void{
if (Global.baseUpgradeData.upgrade0 >= 1){
Global.castle.totalHP = (Global.castle.totalHP + Global.baseUpgradeData.upgrade0ExpValue[(Global.baseUpgradeData.upgrade0 - 1)]);
};
Global.castle.currentHP = Global.castle.totalHP;
Global.castle.update();
Global.castle.addEventListener("save", doSave);
this.creepsContainer.removeAllCreaps();
this.field.drawLevel(n);
this.castleLayer_mc.setField(this.field);
this.creepsContainer.setField(this.field);
this.addChild(this.towersContainer);
this.addChild(this.creepsContainer);
this.addChild(this.spellIcons);
this.addChild(this.coinContainer);
this.creepsContainer.x = this.field.x;
this.creepsContainer.y = this.field.y;
Global.topMenu.setGold(Global.currentLevel.goldAtStart);
this.waveData.setCreepsContainer(this.creepsContainer);
this.waveData.startLevel(n);
this.spellIcons.update();
this.spellIcons.updateToolTips();
this.spellIcons.setCreepsContainer(creepsContainer);
this.spellIcons.setCastleLayer(this.castleLayer_mc);
this.towersContainer.removeAllTowers();
this.wavesPreview.reset();
Global.consol.clear();
Global.consol.showWelcome(n);
this.doSave();
}
function frame3(){
if ((((__setPropDict[startWaveButton] == undefined)) || (!((int(__setPropDict[startWaveButton]) == 3))))){
__setPropDict[startWaveButton] = currentFrame;
__setProp_startWaveButton_Scene1_Layer1_3();
};
if ((((__setPropDict[improvementsButton] == undefined)) || (!((int(__setPropDict[improvementsButton]) == 3))))){
__setPropDict[improvementsButton] = currentFrame;
__setProp_improvementsButton_Scene1_Layer1_3();
};
if ((((__setPropDict[normalSpeed] == undefined)) || (!((int(__setPropDict[normalSpeed]) == 3))))){
__setPropDict[normalSpeed] = currentFrame;
__setProp_normalSpeed_Scene1_Layer29_3();
};
if ((((__setPropDict[__id0_] == undefined)) || (!((int(__setPropDict[__id0_]) == 3))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_Layer1_3();
};
if ((((__setPropDict[mainMenu] == undefined)) || (!((int(__setPropDict[mainMenu]) == 3))))){
__setPropDict[mainMenu] = currentFrame;
__setProp_mainMenu_Scene1_Layer1_3();
};
if ((((__setPropDict[doubleSpeed] == undefined)) || (!((int(__setPropDict[doubleSpeed]) == 3))))){
__setPropDict[doubleSpeed] = currentFrame;
__setProp_doubleSpeed_Scene1_Layer29_3();
};
if ((((__setPropDict[gameSpeed] == undefined)) || (!((int(__setPropDict[gameSpeed]) == 3))))){
__setPropDict[gameSpeed] = currentFrame;
__setProp_gameSpeed_Scene1_Layer1_3();
};
stop();
init0();
}
function frame1(){
stop();
}
private function onStartLevelClick(e:Event):void{
var l:Number;
l = levelsWindow.getSelectedLevel();
trace("Main.onStartLevelClick", l);
this.startLevel(l);
}
private function onCreditsClick(e:MouseEvent):void{
trace("!!!!!!!");
Global.gameManager.showCreditsWindow();
}
function __setProp_startWaveButton_Scene1_Layer1_3(){
startWaveButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
startWaveButton.emphasized = false;
startWaveButton.enabled = true;
startWaveButton.label = "";
startWaveButton.labelPlacement = "right";
startWaveButton.selected = false;
startWaveButton.toggle = false;
startWaveButton.visible = true;
startWaveButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function doSave(e:Event=null):void{
trace("!!!!!!!!!!!!!!! DO SAVE");
this.localSaver.encryptedSave(Global.lockedLevels[0], Global.lockedLevels[1], Global.lockedLevels[2], Global.lockedLevels[3], Global.lockedLevels[4], Global.lockedLevels[5], Global.baseUpgradeData.currentExpirience, Global.baseUpgradeData.upgrade0, Global.baseUpgradeData.upgrade1, Global.baseUpgradeData.upgrade2, Global.baseUpgradeData.upgrade3, Global.baseUpgradeData.upgrade4);
}
private function onGameSpeedClick(e:MouseEvent):void{
if (this.gameSpeed.selected){
this.stage.frameRate = 24;
this.gameSpeed.label = "x2";
} else {
this.stage.frameRate = 50;
this.gameSpeed.label = "x1";
};
}
function __setProp_mainMenu_Scene1_Layer1_3(){
mainMenu["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
mainMenu.emphasized = false;
mainMenu.enabled = true;
mainMenu.label = "Main Menu";
mainMenu.labelPlacement = "right";
mainMenu.selected = false;
mainMenu.toggle = false;
mainMenu.visible = true;
mainMenu["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onImprovementsClick(e:MouseEvent):void{
Global.gameManager.showCastleWindow();
}
function __setProp_gameSpeed_Scene1_Layer1_3(){
gameSpeed["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
gameSpeed.emphasized = false;
gameSpeed.enabled = true;
gameSpeed.label = "x2";
gameSpeed.labelPlacement = "right";
gameSpeed.selected = false;
gameSpeed.toggle = true;
gameSpeed.visible = true;
gameSpeed["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function init0():void{
trace("Main");
this.configGlobal();
this.configButtons();
this.field.setGameManager(Global.gameManager);
this.creepsContainer = new CreepsContainer();
this.creepsContainer.setCoinsContainer(this.coinContainer);
this.towersContainer = new TowersContainer();
this.creepsContainer.setTowersContainer(this.towersContainer);
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.keyboardManager = new KeyBoardManager();
this.towersContainer.setKeyboardManager(this.keyboardManager);
this.towersContainer.setCreepsContainer(this.creepsContainer);
trace(this.towersContainer);
trace(this.towersMenu);
this.towersContainer.setTowersMenu(this.towersMenu);
this.towersContainer.setField(this.field);
this.startWaveButton.addEventListener(MouseEvent.CLICK, onStartWaveClick);
this.waveData.setCreepsContainer(this.creepsContainer);
this.waveData.setWavesPreview(this.wavesPreview);
this.waveData.addEventListener("save", doSave);
levelsWindow.addEventListener("startLevel", onStartLevelClick);
this.settingsButton.addEventListener(MouseEvent.CLICK, onSettingsButton);
this.showTip.addEventListener(MouseEvent.CLICK, onShowTip);
this.improvementsButton.addEventListener(MouseEvent.CLICK, onImprovementsClick);
this.mainMenu.addEventListener(MouseEvent.CLICK, onMainMenuClick);
this.gameSpeed.addEventListener(MouseEvent.CLICK, onGameSpeedClick);
this.normalSpeed.addEventListener(Event.CHANGE, onGameSpeedChange);
this.creditsButton.addEventListener(MouseEvent.CLICK, onCreditsClick);
SimpleToolTip.addToolTip(this.gameSpeed, "Slow/increase game time");
SimpleToolTip.addToolTip(this.settingsButton, "Open game settings window");
SimpleToolTip.addToolTip(this.startWaveButton, "Start new wave");
SimpleToolTip.addToolTip(this.showTip, "Show game tips in console window");
onAddedToStage(null);
this.sponsorButton.addEventListener(MouseEvent.CLICK, goToSponsorSite);
this.moreGames.addEventListener(MouseEvent.CLICK, goToSponsorSite);
}
private function onSettingsButton(e:MouseEvent):void{
Global.gameManager.showSettingsWindow();
}
function __setProp___id0__Scene1_Layer1_3(){
__id0_["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
__id0_.emphasized = false;
__id0_.enabled = true;
__id0_.label = "Start Level";
__id0_.labelPlacement = "right";
__id0_.selected = false;
__id0_.toggle = false;
__id0_.visible = true;
__id0_["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onShowTip(e:MouseEvent):void{
Global.consol.t(tips.getTip());
}
private function configGlobal():void{
var data:Object;
Global.consol = consol;
Global.gameManager = new GameManager();
Global.topMenu = this.topMenu;
Global.selectedTowerInfo = selectedTowerInfo_mc;
Global.gameManager.setCastleWindow(castleWindow);
Global.gameManager.setGameIntroWindow(gameIntroWindow);
Global.gameManager.setSettingsWindow(settingsWindow);
Global.gameManager.setMainMenuWindow(mainMenuWindow);
Global.gameManager.setCreditsWindow(creditsWindow);
Global.gameManager.setIntroMovieWindow(introMovieWindow);
Global.gameManager.setLevelsWindow(levelsWindow);
Global.gameManager.setBaseUpgradeWindow(baseUpgradeWindow);
Global.gameManager.setLostLevelVindow(lostWindow);
Global.baseUpgradeData = new BaseUpgradeData();
Global.soundManager = new SoundManager();
data = this.localSaver.encryptedLoad();
if (data.lockedLevels == undefined){
gameIntroWindow.setContinueButtonDisable();
Global.lockedLevels = [0, 1, 1, 1, 1, 1];
} else {
Global.lockedLevels = data.lockedLevels;
Global.baseUpgradeData.currentExpirience = data.exp;
Global.baseUpgradeData.upgrade0 = data.upgrades[0];
Global.baseUpgradeData.upgrade1 = data.upgrades[1];
Global.baseUpgradeData.upgrade2 = data.upgrades[2];
Global.baseUpgradeData.upgrade3 = data.upgrades[3];
Global.baseUpgradeData.upgrade4 = data.upgrades[4];
trace("locked", data.lockedLevels);
trace("exp", data.exp);
trace("upgrades", data.upgrades);
};
Global.topMenu.setExp(Global.baseUpgradeData.currentExpirience);
}
function __setProp_doubleSpeed_Scene1_Layer29_3(){
doubleSpeed["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
doubleSpeed.enabled = true;
doubleSpeed.groupName = "RadioButtonGroup";
doubleSpeed.label = "x2";
doubleSpeed.labelPlacement = "right";
doubleSpeed.selected = false;
doubleSpeed.value = "";
doubleSpeed.visible = true;
doubleSpeed["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onAddedToStage(e:Event):void{
this.keyboardManager.setLinkToStage(this.stage);
Global.keyBoardManager = this.keyboardManager;
}
private function onGameSpeedChange(e:Event):void{
if (this.normalSpeed.selected){
this.stage.frameRate = 24;
this.gameSpeed.label = "x2";
Global.isDoubleSpeed = false;
} else {
this.stage.frameRate = 48;
this.gameSpeed.label = "x1";
Global.isDoubleSpeed = true;
};
}
private function onStartWaveClick(e:MouseEvent):void{
this.waveData.startWave();
}
function __setProp_improvementsButton_Scene1_Layer1_3(){
improvementsButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
improvementsButton.emphasized = false;
improvementsButton.enabled = true;
improvementsButton.label = "improvements";
improvementsButton.labelPlacement = "right";
improvementsButton.selected = false;
improvementsButton.toggle = false;
improvementsButton.visible = true;
improvementsButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function configButtons():void{
Styler.setStyleToButton(startWaveButton);
}
private function goToSponsorSite(e:MouseEvent):void{
var r:URLRequest;
r = new URLRequest("http://www.gamesnow.biz/");
navigateToURL(r, "_blank");
}
}
}//package
Section 227
//MainMenuWindow (MainMenuWindow)
package {
import flash.display.*;
import flash.events.*;
public class MainMenuWindow extends MovieClip {
public var backToGame:SimpleButton;
public function MainMenuWindow(){
super();
backToGame.addEventListener(MouseEvent.CLICK, onBackToGameClick);
}
private function onBackToGameClick(e:MouseEvent):void{
Global.gameManager.hideMainMenuWindow();
}
}
}//package
Section 228
//MissleShoot (MissleShoot)
package {
import flash.media.*;
public dynamic class MissleShoot extends Sound {
public function MissleShoot(){
super();
}
}
}//package
Section 229
//Music1 (Music1)
package {
import flash.media.*;
public dynamic class Music1 extends Sound {
public function Music1(){
super();
}
}
}//package
Section 230
//Music2 (Music2)
package {
import flash.media.*;
public dynamic class Music2 extends Sound {
public function Music2(){
super();
}
}
}//package
Section 231
//Music3 (Music3)
package {
import flash.media.*;
public dynamic class Music3 extends Sound {
public function Music3(){
super();
}
}
}//package
Section 232
//RadioButton_disabledIcon (RadioButton_disabledIcon)
package {
import flash.display.*;
public dynamic class RadioButton_disabledIcon extends MovieClip {
public function RadioButton_disabledIcon(){
super();
}
}
}//package
Section 233
//RadioButton_downIcon (RadioButton_downIcon)
package {
import flash.display.*;
public dynamic class RadioButton_downIcon extends MovieClip {
public function RadioButton_downIcon(){
super();
}
}
}//package
Section 234
//RadioButton_overIcon (RadioButton_overIcon)
package {
import flash.display.*;
public dynamic class RadioButton_overIcon extends MovieClip {
public function RadioButton_overIcon(){
super();
}
}
}//package
Section 235
//RadioButton_selectedDisabledIcon (RadioButton_selectedDisabledIcon)
package {
import flash.display.*;
public dynamic class RadioButton_selectedDisabledIcon extends MovieClip {
public function RadioButton_selectedDisabledIcon(){
super();
}
}
}//package
Section 236
//RadioButton_selectedDownIcon (RadioButton_selectedDownIcon)
package {
import flash.display.*;
public dynamic class RadioButton_selectedDownIcon extends MovieClip {
public function RadioButton_selectedDownIcon(){
super();
}
}
}//package
Section 237
//RadioButton_selectedOverIcon (RadioButton_selectedOverIcon)
package {
import flash.display.*;
public dynamic class RadioButton_selectedOverIcon extends MovieClip {
public function RadioButton_selectedOverIcon(){
super();
}
}
}//package
Section 238
//RadioButton_selectedUpIcon (RadioButton_selectedUpIcon)
package {
import flash.display.*;
public dynamic class RadioButton_selectedUpIcon extends MovieClip {
public function RadioButton_selectedUpIcon(){
super();
}
}
}//package
Section 239
//RadioButton_upIcon (RadioButton_upIcon)
package {
import flash.display.*;
public dynamic class RadioButton_upIcon extends MovieClip {
public function RadioButton_upIcon(){
super();
}
}
}//package
Section 240
//RangeShoot (RangeShoot)
package {
import flash.media.*;
public dynamic class RangeShoot extends Sound {
public function RangeShoot(){
super();
}
}
}//package
Section 241
//RestoreHP10 (RestoreHP10)
package {
import flash.display.*;
public dynamic class RestoreHP10 extends MovieClip {
public function RestoreHP10(){
super();
}
}
}//package
Section 242
//SelectedTowerInfo (SelectedTowerInfo)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import towers.*;
import flash.text.*;
public class SelectedTowerInfo extends MovieClip {
public var currentTower:Tower;
public var upgrade:SelectedTowerInfo_upgrade;
public var bbb:Button;
public var sellButton:Button;
public var sellDT:TextField;
public var upgradeButton:Button;
public var cover:SelectedTowerInfo_Cover;
public var main:SelectedTowerInfo_main;
public function SelectedTowerInfo(){
super();
this.upgrade.visible = false;
this.sellDT.visible = false;
SimpleToolTip.addToolTip(this.upgrade, "Deselect tower to see next wave details");
this.upgradeButton.addEventListener(MouseEvent.MOUSE_OVER, onUpgradeOver);
this.upgradeButton.addEventListener(MouseEvent.MOUSE_OUT, onUpgradeOut);
this.upgradeButton.addEventListener(MouseEvent.CLICK, onUpgradeClick);
this.sellButton.addEventListener(MouseEvent.MOUSE_OVER, onSellOver);
this.sellButton.addEventListener(MouseEvent.MOUSE_OUT, onSellOut);
this.sellButton.addEventListener(MouseEvent.CLICK, onSellClick);
__setProp_upgradeButton_SelectedTowerInfo_Layer3_1();
__setProp_bbb_SelectedTowerInfo_Layer3_1();
__setProp_sellButton_SelectedTowerInfo_Layer3_1();
}
function __setProp_bbb_SelectedTowerInfo_Layer3_1(){
bbb["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
bbb.emphasized = false;
bbb.enabled = true;
bbb.label = "UPGRADE";
bbb.labelPlacement = "right";
bbb.selected = false;
bbb.toggle = false;
bbb.visible = true;
bbb["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function hideInfo():void{
cover.visible = true;
this.updateWaveInfo();
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function updateWaveInfo():void{
cover.nameDT.htmlText = (("<font color='#0000FF'><b>" + Global.currentWave.name) + "</b></font>");
cover.descriptionDT.htmlText = (("<b>" + Global.currentWave.description) + "</b>");
cover.descriptionDT.htmlText = (cover.descriptionDT.htmlText + ((((((((((("\n(N:" + "<b>") + Global.currentWave.totalAmount) + "</b> Damage:<b>") + Global.currentWave.minDamage) + "-") + Global.currentWave.maxDamage) + "</b> Speed:<b>") + Global.currentWave.speed) + "</b> Hitpoints:<b>") + Global.currentWave.hitpoints) + "</b>)"));
if (((!((Global.nextWave == null))) && ((Global.wave == 0)))){
};
}
private function onSellClick(e:MouseEvent):void{
this.bbb.setFocus();
Global.consol.t((((("You sold " + this.currentTower.info.name) + " for ") + this.currentTower.info.sellTowerFor) + " "));
Global.topMenu.setGold((Global.topMenu.gold + this.currentTower.info.sellTowerFor));
this.hideInfo();
this.currentTower.sellMeNow();
}
private function onSellOver(e:MouseEvent):void{
this.main.visible = false;
this.upgrade.visible = false;
this.sellDT.visible = true;
this.sellDT.text = ("Sell for " + this.currentTower.info.sellTowerFor.toString());
}
private function onUpgradeClick(e:MouseEvent):void{
if (Global.topMenu.gold < this.currentTower.upgradeInfo.gold){
Global.consol.t("Not enough gold to upgrade");
} else {
Global.topMenu.setGold((Global.topMenu.gold - this.currentTower.upgradeInfo.gold));
this.currentTower.levelUp();
this.upgrade.showInfo(this.currentTower);
this.main.showInfo(this.currentTower);
};
}
public function showInfo(t:Tower):void{
if (t == null){
this.hideInfo();
} else {
this.currentTower = t;
this.upgradeButton.visible = true;
if (this.currentTower.upgradeInfo == null){
this.upgradeButton.visible = false;
};
cover.visible = false;
main.showInfo(t);
};
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
function __setProp_sellButton_SelectedTowerInfo_Layer3_1(){
sellButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
sellButton.emphasized = false;
sellButton.enabled = true;
sellButton.label = "SELL";
sellButton.labelPlacement = "right";
sellButton.selected = false;
sellButton.toggle = false;
sellButton.visible = true;
sellButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onUpgradeOver(e:MouseEvent):void{
this.main.visible = false;
this.upgrade.visible = true;
this.upgrade.showInfo(this.currentTower);
}
private function onEnterFrame(e:Event):void{
if (this.currentTower == null){
return;
};
if (this.currentTower.upgradeInfo != null){
if (Global.topMenu.gold <= this.currentTower.upgradeInfo.gold){
this.upgradeButton.enabled = false;
} else {
this.upgradeButton.enabled = true;
};
} else {
this.upgradeButton.visible = false;
};
}
private function onSellOut(e:MouseEvent):void{
this.main.visible = true;
this.upgrade.visible = false;
this.sellDT.visible = false;
}
function __setProp_upgradeButton_SelectedTowerInfo_Layer3_1(){
upgradeButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
upgradeButton.emphasized = false;
upgradeButton.enabled = true;
upgradeButton.label = "UPGRADE";
upgradeButton.labelPlacement = "right";
upgradeButton.selected = false;
upgradeButton.toggle = false;
upgradeButton.visible = true;
upgradeButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onUpgradeOut(e:MouseEvent):void{
this.main.visible = true;
this.upgrade.visible = false;
}
}
}//package
Section 243
//SelectedTowerInfo_Cover (SelectedTowerInfo_Cover)
package {
import flash.display.*;
import flash.text.*;
public class SelectedTowerInfo_Cover extends Sprite {
public var nameDT:TextField;
public var descriptionDT:TextField;
public function SelectedTowerInfo_Cover(){
super();
}
}
}//package
Section 244
//SelectedTowerInfo_main (SelectedTowerInfo_main)
package {
import flash.display.*;
import towers.*;
import flash.text.*;
public class SelectedTowerInfo_main extends MovieClip {
public var speedDT:TextField;
public var costDT:TextField;
public var damageDT:TextField;
public var nameDT:TextField;
public var rangeDT:TextField;
public var descriptionDT:TextField;
public function SelectedTowerInfo_main(){
super();
}
private function hideInfo():void{
}
public function showInfo(t:Tower):void{
var a:Number;
if (t == null){
this.hideInfo();
} else {
costDT.text = t.info.gold.toString();
nameDT.text = ((t.info.name + " Lv. ") + t.info.level.toString());
damageDT.text = t.info.damage.toString();
a = (t.info.shootingRate / 1000);
speedDT.text = a.toString();
rangeDT.text = t.info.r.toString();
};
}
}
}//package
Section 245
//SelectedTowerInfo_upgrade (SelectedTowerInfo_upgrade)
package {
import flash.display.*;
import towers.*;
import flash.text.*;
public class SelectedTowerInfo_upgrade extends MovieClip {
public var speedDT:TextField;
public var costDT:TextField;
public var damageDT:TextField;
public var nameDT:TextField;
public var dt:TextField;
public var rangeDT:TextField;
public var descriptionDT:TextField;
public function SelectedTowerInfo_upgrade(){
super();
}
public function showInfo(t:Tower):void{
var a:Number;
trace("SelectedTowerInfo_upgrade.showInfo", t);
if (t.upgradeInfo == null){
this.dt.text = "Fully upgraded";
} else {
this.dt.text = ("Upgrade to level " + t.upgradeInfo.level);
this.costDT.text = t.upgradeInfo.gold.toString();
this.damageDT.text = t.upgradeInfo.damage.toString();
a = (t.upgradeInfo.shootingRate / 1000);
this.speedDT.text = a.toString();
this.rangeDT.text = t.upgradeInfo.r.toString();
};
}
}
}//package
Section 246
//SelectTowerEvent (SelectTowerEvent)
package {
import flash.events.*;
import towers.*;
public class SelectTowerEvent extends Event {
public var tower:Tower;
public function SelectTowerEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function toString():String{
return (formatToString("SelectTowerEvent", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new SelectTowerEvent(type, bubbles, cancelable));
}
}
}//package
Section 247
//SettingsWindow (SettingsWindow)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
public class SettingsWindow extends MovieClip {
public var hq:RadioButton;
public var soundsSlider:Slider;
public var musicSlider:Slider;
public var lq:RadioButton;
public var toolTipsCheckBox:CheckBox;
public var mq:RadioButton;
public var backToGame:SimpleButton;
public function SettingsWindow(){
super();
backToGame.addEventListener(MouseEvent.CLICK, onBackToGameClick);
hq.selected = true;
hq.addEventListener(Event.CHANGE, onQualityChange);
mq.addEventListener(Event.CHANGE, onQualityChange);
lq.addEventListener(Event.CHANGE, onQualityChange);
musicSlider.minimum = 0;
musicSlider.maximum = 100;
soundsSlider.minimum = 0;
soundsSlider.maximum = 100;
musicSlider.value = 50;
soundsSlider.value = 100;
musicSlider.addEventListener(Event.CHANGE, onMusicVolumeChange);
soundsSlider.addEventListener(Event.CHANGE, onSoundVolumeChange);
toolTipsCheckBox.selected = true;
toolTipsCheckBox.addEventListener(Event.CHANGE, onToolTipChange);
__setProp_lq_SettingsWindow_Layer4_1();
__setProp_mq_SettingsWindow_Layer4_1();
__setProp_hq_SettingsWindow_Layer4_1();
__setProp_toolTipsCheckBox_SettingsWindow_Layer4_1();
}
private function onSoundVolumeChange(e:Event):void{
Global.soundManager.setSoundVolume((soundsSlider.value / soundsSlider.maximum));
}
function __setProp_hq_SettingsWindow_Layer4_1(){
hq["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
hq.enabled = true;
hq.groupName = "RadioButtonGroup";
hq.label = "";
hq.labelPlacement = "right";
hq.selected = false;
hq.value = "";
hq.visible = true;
hq["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onMusicVolumeChange(e:Event):void{
Global.soundManager.setMusicVolume((this.musicSlider.value / this.musicSlider.maximum));
}
private function onBackToGameClick(e:MouseEvent):void{
Global.gameManager.hideSettingsWindow();
}
function __setProp_toolTipsCheckBox_SettingsWindow_Layer4_1(){
toolTipsCheckBox["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
toolTipsCheckBox.enabled = true;
toolTipsCheckBox.label = "";
toolTipsCheckBox.labelPlacement = "right";
toolTipsCheckBox.selected = true;
toolTipsCheckBox.visible = true;
toolTipsCheckBox["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
function __setProp_lq_SettingsWindow_Layer4_1(){
lq["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
lq.enabled = true;
lq.groupName = "RadioButtonGroup";
lq.label = "";
lq.labelPlacement = "right";
lq.selected = false;
lq.value = "";
lq.visible = true;
lq["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
function __setProp_mq_SettingsWindow_Layer4_1(){
mq["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
mq.enabled = true;
mq.groupName = "RadioButtonGroup";
mq.label = "";
mq.labelPlacement = "right";
mq.selected = false;
mq.value = "";
mq.visible = true;
mq["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function onToolTipChange(e:Event):void{
SimpleToolTip.enabled = this.toolTipsCheckBox.selected;
}
private function onQualityChange(e:Event):void{
if (this.stage != null){
if (hq.selected){
this.stage.quality = StageQuality.BEST;
};
if (mq.selected){
this.stage.quality = StageQuality.MEDIUM;
};
if (lq.selected){
this.stage.quality = StageQuality.LOW;
};
};
}
}
}//package
Section 248
//SimpleTipBackground (SimpleTipBackground)
package {
import flash.display.*;
public dynamic class SimpleTipBackground extends MovieClip {
public function SimpleTipBackground(){
super();
}
}
}//package
Section 249
//SimpleToolTip (SimpleToolTip)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.geom.*;
import flash.text.*;
public class SimpleToolTip {
public static const DELAY:Number = 600;
public static var enabled:Boolean = true;
private static var timer:Timer;
private static var lastTarget:DisplayObject;
private static var currentTip:Sprite;
public static var Y_MARGIN:Number = 0;
public static var X_MARGIN:Number = 0;
private static var tooledObjects:Dictionary = new Dictionary();
public function SimpleToolTip(){
super();
}
private static function tick(e:TimerEvent):void{
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, tick);
timer = null;
showToolTip(null);
}
private static function showToolTip(e:MouseEvent):void{
var target:DisplayObject;
var tf:TextField;
var bg:Sprite;
var stageCoordinates:Point;
var higestDO:*;
var e = e;
if (!enabled){
return;
};
if (e == null){
target = lastTarget;
};
tf = new TextField();
if (tooledObjects[target] == null){
return;
};
if (tooledObjects[target].string == ""){
return;
};
tf.htmlText = tooledObjects[target].string;
tf.width = (tf.textWidth + 30);
tf.height = (tf.textHeight + 10);
tf.autoSize = TextFieldAutoSize.LEFT;
tf.width = 100;
tf.multiline = true;
currentTip = new Sprite();
bg = new Sprite();
bg = new SimpleTipBackground();
currentTip.addChild(bg);
currentTip.mouseEnabled = false;
currentTip.mouseChildren = false;
bg.width = (tf.width + 10);
bg.height = tf.height;
currentTip.addChild(tf);
tf.x = 5;
if (currentTip == null){
return;
};
target.stage.addChild(currentTip);
//unresolved jump
var _slot1 = e;
return;
currentTip.x = ((target.x + X_MARGIN) + tooledObjects[target].dx);
currentTip.y = ((target.y - currentTip.height) + Y_MARGIN);
if ((currentTip.x + currentTip.width) > target.stage.stageWidth){
currentTip.x = (target.stage.stageWidth - currentTip.width);
};
if (currentTip.x < 0){
currentTip.x = 0;
};
if (currentTip.y < 0){
currentTip.y = 0;
};
if ((currentTip.localToGlobal(new Point(0, 0)).x + currentTip.width) > currentTip.stage.stageWidth){
currentTip.x = (currentTip.stage.stageWidth - currentTip.width);
};
if ((currentTip.y + currentTip.height) > currentTip.stage.stageHeight){
currentTip.y = (currentTip.stage.stageHeight - currentTip.height);
};
stageCoordinates = target.parent.localToGlobal(new Point(currentTip.x, currentTip.y));
currentTip.x = stageCoordinates.x;
if (tooledObjects[target] != null){
currentTip.x = (currentTip.x + tooledObjects[target].dx);
};
currentTip.y = stageCoordinates.y;
if (currentTip.y < 0){
currentTip.y = 0;
};
higestDO = target.stage.getChildAt((target.stage.numChildren - 1));
target.stage.swapChildren(higestDO, currentTip);
}
private static function mouseOver(e:MouseEvent):void{
trace("SimpleToolTip.mouseOver");
lastTarget = DisplayObject(e.target);
timer = new Timer(DELAY, 1);
timer.addEventListener(TimerEvent.TIMER, tick);
timer.start();
}
public static function addToolTip(tooledObject:DisplayObject, tipText:String, dx:Number=0):void{
tipText = unescape(tipText);
tipText = tipText.replace(new RegExp("000d", "g"), "\n");
if (tipText == null){
tipText = "Add <b>your</b> <i>text</i> <u>here</u>";
};
tooledObject.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
tooledObject.addEventListener(MouseEvent.MOUSE_OUT, removeToolTip);
tooledObjects[tooledObject] = new Object();
tooledObjects[tooledObject].string = tipText;
tooledObjects[tooledObject].dx = dx;
}
private static function removeToolTip(e:MouseEvent=null):void{
var e = e;
if (timer != null){
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, tick);
timer = null;
};
e.target.stage.removeChild(currentTip);
//unresolved jump
var _slot1 = e;
}
}
}//package
Section 250
//Skin (Skin)
package {
import flash.display.*;
import flash.utils.*;
public class Skin extends MovieClip {
public function Skin(){
super();
}
public function getElementByType(type:Number):MovieClip{
var xml:XML;
xml = describeType(this);
trace(xml.toXMLString());
return (null);
}
}
}//package
Section 251
//Skin1 (Skin1)
package {
public class Skin1 extends Skin {
public function Skin1(){
super();
}
}
}//package
Section 252
//Skin2 (Skin2)
package {
public class Skin2 extends Skin {
public function Skin2(){
super();
}
}
}//package
Section 253
//Skin3 (Skin3)
package {
public class Skin3 extends Skin {
public function Skin3(){
super();
}
}
}//package
Section 254
//Skin4 (Skin4)
package {
public class Skin4 extends Skin {
public function Skin4(){
super();
}
}
}//package
Section 255
//Skin5 (Skin5)
package {
public class Skin5 extends Skin {
public function Skin5(){
super();
}
}
}//package
Section 256
//Skin6 (Skin6)
package {
public class Skin6 extends Skin {
public function Skin6(){
super();
}
}
}//package
Section 257
//SliderThumb_disabledSkin (SliderThumb_disabledSkin)
package {
import flash.display.*;
public dynamic class SliderThumb_disabledSkin extends MovieClip {
public function SliderThumb_disabledSkin(){
super();
}
}
}//package
Section 258
//SliderThumb_downSkin (SliderThumb_downSkin)
package {
import flash.display.*;
public dynamic class SliderThumb_downSkin extends MovieClip {
public function SliderThumb_downSkin(){
super();
}
}
}//package
Section 259
//SliderThumb_overSkin (SliderThumb_overSkin)
package {
import flash.display.*;
public dynamic class SliderThumb_overSkin extends MovieClip {
public function SliderThumb_overSkin(){
super();
}
}
}//package
Section 260
//SliderThumb_upSkin (SliderThumb_upSkin)
package {
import flash.display.*;
public dynamic class SliderThumb_upSkin extends MovieClip {
public function SliderThumb_upSkin(){
super();
}
}
}//package
Section 261
//SliderTick_skin (SliderTick_skin)
package {
import flash.display.*;
public dynamic class SliderTick_skin extends MovieClip {
public function SliderTick_skin(){
super();
}
}
}//package
Section 262
//SliderTrack_disabledSkin (SliderTrack_disabledSkin)
package {
import flash.display.*;
public dynamic class SliderTrack_disabledSkin extends MovieClip {
public function SliderTrack_disabledSkin(){
super();
}
}
}//package
Section 263
//SliderTrack_skin (SliderTrack_skin)
package {
import flash.display.*;
public dynamic class SliderTrack_skin extends MovieClip {
public function SliderTrack_skin(){
super();
}
}
}//package
Section 264
//SoundManager (SoundManager)
package {
import flash.events.*;
import flash.utils.*;
import flash.media.*;
public class SoundManager extends EventDispatcher {
private var sfxSoundTransform:SoundTransform;
private var appearArray:Array;
private var musicSoundTransform:SoundTransform;
private var dieChannel:SoundChannel;
private var shootChannel:SoundChannel;
private var musicChannel:SoundChannel;
private var music2:Sound;
private var appearChannel:SoundChannel;
private var music1:Sound;
private var music3:Sound;
private var userWeaponChannel:SoundChannel;
private var appearIndex:Number;// = -1
private var sfxChannel:SoundChannel;
public function SoundManager(){
appearIndex = -1;
appearArray = ["Appear1", "Appear2", "Appear3", "Appear4", "Appear5", "Appear6", "Appear7"];
sfxSoundTransform = new SoundTransform();
musicSoundTransform = new SoundTransform();
super();
this.music1 = new Music1();
this.music2 = new Music2();
this.music3 = new Music3();
this.musicChannel = this.music1.play();
this.setMusicVolume(0.5);
if (this.musicChannel != null){
this.musicChannel.addEventListener(Event.SOUND_COMPLETE, onMusicComplete);
};
}
public function addBaseDamageSound():void{
}
public function addSFXSound(className:String):void{
var soundClass:Class;
var sound:Sound;
soundClass = (getDefinitionByName(className) as Class);
sound = new (soundClass);
this.sfxChannel = sound.play();
if (this.sfxChannel != null){
this.sfxChannel.soundTransform = this.sfxSoundTransform;
};
}
public function setSoundVolume(v:Number):void{
var st:SoundTransform;
st = new SoundTransform();
st.volume = v;
if (this.sfxChannel != null){
this.sfxChannel.soundTransform = st;
};
if (this.appearChannel != null){
this.appearChannel.soundTransform = st;
};
if (this.shootChannel != null){
this.shootChannel.soundTransform = st;
};
if (this.userWeaponChannel != null){
this.userWeaponChannel.soundTransform = st;
};
if (this.dieChannel != null){
this.dieChannel.soundTransform = st;
};
this.sfxSoundTransform = st;
}
public function addAppearSound():void{
var className:String;
var soundClass:Class;
var sound:Sound;
this.appearIndex++;
if (this.appearIndex == this.appearArray.length){
this.appearIndex = 0;
};
className = this.appearArray[this.appearIndex];
soundClass = (getDefinitionByName(className) as Class);
sound = new (soundClass);
this.appearChannel = sound.play();
if (this.appearChannel != null){
this.appearChannel.soundTransform = this.sfxSoundTransform;
};
}
public function setMusicVolume(v:Number):void{
var st:SoundTransform;
st = new SoundTransform();
st.volume = v;
if (this.musicChannel != null){
this.musicChannel.soundTransform = st;
};
this.musicSoundTransform = st;
}
private function onMusicComplete(e:Event):void{
var chance:Number;
chance = Math.floor((Math.random() * 100));
trace("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!CHANCE", chance);
if (chance < 33){
this.musicChannel = this.music1.play();
} else {
if (chance < 66){
this.musicChannel = this.music2.play();
} else {
this.musicChannel = this.music3.play();
};
};
this.musicChannel.soundTransform = this.musicSoundTransform;
this.musicChannel.addEventListener(Event.SOUND_COMPLETE, onMusicComplete);
}
public function addUserWeaponSound(className:String):void{
var soundClass:Class;
var sound:Sound;
soundClass = (getDefinitionByName(className) as Class);
sound = new (soundClass);
this.userWeaponChannel = sound.play();
if (this.userWeaponChannel != null){
this.userWeaponChannel.soundTransform = this.sfxSoundTransform;
};
}
public function addDieSound(className:String):void{
var soundClass:Class;
var sound:Sound;
soundClass = (getDefinitionByName(className) as Class);
sound = new (soundClass);
this.dieChannel = sound.play();
if (this.dieChannel != null){
this.dieChannel.soundTransform = sfxSoundTransform;
};
}
public function addShootSound(className:String):void{
var soundClass:Class;
var sound:Sound;
soundClass = (getDefinitionByName(className) as Class);
sound = new (soundClass);
this.shootChannel = sound.play();
if (this.shootChannel != null){
this.shootChannel.soundTransform = this.sfxSoundTransform;
};
}
}
}//package
Section 265
//Sounds (Sounds)
package {
import flash.display.*;
public dynamic class Sounds extends MovieClip {
public function Sounds(){
super();
}
}
}//package
Section 266
//SpellIcon1 (SpellIcon1)
package {
import flash.display.*;
public dynamic class SpellIcon1 extends MovieClip {
public function SpellIcon1(){
super();
}
}
}//package
Section 267
//SpellIcon2 (SpellIcon2)
package {
import flash.display.*;
public dynamic class SpellIcon2 extends MovieClip {
public function SpellIcon2(){
super();
}
}
}//package
Section 268
//SpellIcon3 (SpellIcon3)
package {
import flash.display.*;
public dynamic class SpellIcon3 extends MovieClip {
public function SpellIcon3(){
super();
}
}
}//package
Section 269
//SpellIcon4 (SpellIcon4)
package {
import flash.display.*;
public dynamic class SpellIcon4 extends MovieClip {
public function SpellIcon4(){
super();
}
}
}//package
Section 270
//StartWave_Disabled (StartWave_Disabled)
package {
import flash.display.*;
public dynamic class StartWave_Disabled extends MovieClip {
public function StartWave_Disabled(){
super();
}
}
}//package
Section 271
//StartWave_Over (StartWave_Over)
package {
import flash.display.*;
public dynamic class StartWave_Over extends MovieClip {
public function StartWave_Over(){
super();
}
}
}//package
Section 272
//StartWave_Up (StartWave_Up)
package {
import flash.display.*;
public dynamic class StartWave_Up extends MovieClip {
public function StartWave_Up(){
super();
}
}
}//package
Section 273
//Styler (Styler)
package {
import fl.controls.*;
public class Styler {
public function Styler(){
super();
}
public static function setStyleToButton(bb:Button):void{
switch (bb.name){
case "startWaveButton":
bb.setStyle("upSkin", "StartWave_Up");
bb.setStyle("overSkin", "StartWave_Over");
bb.setStyle("downSkin", "StartWave_Over");
bb.setStyle("disabledSkin", "StartWave_Disabled");
bb.setStyle("focusRectSkin", null);
break;
};
}
}
}//package
Section 274
//Tips (Tips)
package {
public class Tips {
private var array:Array;
private var index:Number;// = -1
public function Tips(){
array = new Array();
index = -1;
super();
array.push("*** Each dead bug gives you experience points");
array.push("*** Your progress automaticly saved before and after each level");
array.push("*** Try to play easy levels several times to earn more experience");
}
public function getTip():String{
this.index++;
if (this.index >= this.array.length){
this.index = 0;
};
return (this.array[this.index]);
}
}
}//package
Section 275
//TopMenu (TopMenu)
package {
import flash.display.*;
import flash.text.*;
public class TopMenu extends MovieClip {
public var exp:Number;// = 0
public var expDT:TextField;
public var gold:Number;// = 0
public var goldDT:TextField;
public function TopMenu(){
gold = 0;
exp = 0;
super();
this.addGold(100);
}
public function setExp(e:Number):void{
this.exp = e;
if (Global.baseUpgradeData != null){
};
this.expDT.text = this.exp.toString();
}
public function addGold(g:Number):void{
gold = (gold + g);
this.goldDT.text = gold.toString();
}
public function addExp(e:Number){
this.exp = (this.exp + e);
if (Global.baseUpgradeData != null){
Global.baseUpgradeData.currentExpirience = this.exp;
};
this.expDT.text = this.exp.toString();
}
public function setGold(g:Number):void{
gold = g;
this.goldDT.text = gold.toString();
}
}
}//package
Section 276
//TowerPlaced (TowerPlaced)
package {
import flash.media.*;
public dynamic class TowerPlaced extends Sound {
public function TowerPlaced(){
super();
}
}
}//package
Section 277
//TowersContainer (TowersContainer)
package {
import flash.display.*;
import flash.events.*;
import tower_menu.*;
import towers.*;
public class TowersContainer extends Sprite {
private var draggingTower:Tower;
private var towersMenu:TowersMenu;
private var creepsContainer:CreepsContainer;
private var towers:Array;
private var keyboardManager:KeyBoardManager;
private var field:Field;
public function TowersContainer(){
super();
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.towers = new Array();
}
public function setKeyboardManager(m:KeyBoardManager):void{
this.keyboardManager = m;
this.keyboardManager.addEventListener("stopDragTower", doStopDrag);
}
private function doStopDrag(e:Event=null):void{
this.draggingTower.hideShootingArea();
this.removeChild(this.draggingTower);
this.draggingTower = null;
this.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
private function removeTowerFromField(e:Event):void{
var i:*;
for (i in this.towers) {
if (this.towers[i] == e.target){
this.towers[i].hideShootingArea();
this.towers[i].showUnplaceAbleState();
this.removeChild(this.towers[i]);
this.towers[i].removeEventListener("ImSold_RemoveMeFromField", removeTowerFromField);
this.towers[i] = null;
trace(("removeTowerFromField " + this.towers.length));
this.towers.splice(i, 1);
trace(("removeTowerFromField " + this.towers.length));
break;
};
};
}
private function onNewTower4(e:Event):void{
this.draggingTower = new RangeTower();
if (!this.isGoldEnough(this.draggingTower)){
this.draggingTower = null;
return;
};
this.addChild(this.draggingTower);
this.doStartDrag();
}
public function setTowersMenu(m:TowersMenu):void{
this.towersMenu = m;
this.towersMenu.addEventListener("newTower", onNewTower);
this.towersMenu.addEventListener("newTower2", onNewTower2);
this.towersMenu.addEventListener("newTower3", onNewTower3);
this.towersMenu.addEventListener("newTower4", onNewTower4);
}
public function onNewTower(e:Event):void{
this.draggingTower = new Tower();
if (!this.isGoldEnough(this.draggingTower)){
this.draggingTower = null;
return;
};
this.addChild(this.draggingTower);
this.doStartDrag();
}
public function removeAllTowers():void{
var t:*;
for (t in towers) {
this.towers[t].doDeselectTower();
this.removeChild(this.towers[t]);
this.towers[t].die();
this.towers[t] = null;
};
this.towers = new Array();
}
private function doStartDrag():void{
this.draggingTower.x = this.mouseX;
this.draggingTower.y = this.mouseY;
this.stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
public function setCreepsContainer(c:CreepsContainer):void{
this.creepsContainer = c;
}
private function onAddedToStage(e:Event):void{
this.addEventListener(MouseEvent.CLICK, onClick);
}
private function isGoldEnough(t:Tower):Boolean{
if (Global.topMenu.gold < t.info.gold){
Global.consol.t("Not enough gold");
return (false);
};
return (true);
}
public function setField(f:Field):void{
this.field = f;
this.x = this.field.x;
this.y = this.field.y;
trace("TowersContainer.setField", this.field.x, this.field.y);
}
private function onClick(e:MouseEvent):void{
var cellX:Number;
var cellY:Number;
var i:*;
if (this.draggingTower != null){
if ((((((0 < this.field.mouseX)) && ((this.field.mouseX < this.field.width)))) && ((((0 < this.field.mouseY)) && ((this.field.mouseY < this.field.height)))))){
cellX = Math.floor((this.mouseX / 30));
cellY = Math.floor((this.mouseY / 30));
if (this.field.fieldData.map[cellY][cellX] != CellTypes.FIELD){
Global.consol.t("You cant place tower on road");
} else {
for (i in this.towers) {
if ((((this.towers[i].cellX == this.draggingTower.cellX)) && ((this.towers[i].cellY == this.draggingTower.cellY)))){
Global.consol.t("You cant place tower on another tower");
return;
};
};
this.towers.push(this.draggingTower);
this.draggingTower.placedOnField(this.creepsContainer);
this.draggingTower.addEventListener("ImSold_RemoveMeFromField", removeTowerFromField);
this.draggingTower = null;
this.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
};
} else {
this.doStopDrag();
};
};
}
private function onNewTower3(e:Event):void{
this.draggingTower = new MissileTower();
if (!this.isGoldEnough(this.draggingTower)){
this.draggingTower = null;
return;
};
this.addChild(this.draggingTower);
this.doStartDrag();
}
private function onNewTower2(e:Event):void{
this.draggingTower = new FreezeTower();
if (!this.isGoldEnough(this.draggingTower)){
this.draggingTower = null;
return;
};
this.addChild(this.draggingTower);
this.doStartDrag();
}
private function onMouseMove(e:MouseEvent):void{
var i:*;
var cellX:Number;
var cellY:Number;
if (this.draggingTower != null){
Global.selectedTowerInfo.showInfo(this.draggingTower);
};
if ((((((0 < this.field.mouseX)) && ((this.field.mouseX < this.field.width)))) && ((((0 < this.field.mouseY)) && ((this.field.mouseY < this.field.height)))))){
cellX = Math.floor((this.mouseX / 30));
cellY = Math.floor((this.mouseY / 30));
this.draggingTower.x = ((cellX * 30) + 15);
this.draggingTower.y = ((cellY * 30) + 15);
this.draggingTower.cellX = cellX;
this.draggingTower.cellY = cellY;
this.draggingTower.showShootingArea();
this.draggingTower.hideUnplaceAbleState();
if (this.field.fieldData.map[cellY][cellX] != CellTypes.FIELD){
this.draggingTower.hideShootingArea();
this.draggingTower.showUnplaceAbleState();
};
} else {
this.draggingTower.x = this.mouseX;
this.draggingTower.y = this.mouseY;
this.draggingTower.hideShootingArea();
this.draggingTower.showUnplaceAbleState();
};
for (i in this.towers) {
if ((((this.towers[i].cellX == this.draggingTower.cellX)) && ((this.towers[i].cellY == this.draggingTower.cellY)))){
this.draggingTower.hideShootingArea();
this.draggingTower.showUnplaceAbleState();
break;
};
};
}
}
}//package
Section 278
//TowerSelectedSprite (TowerSelectedSprite)
package {
import flash.display.*;
public dynamic class TowerSelectedSprite extends MovieClip {
public function TowerSelectedSprite(){
super();
}
}
}//package
Section 279
//TowerShoot (TowerShoot)
package {
import flash.media.*;
public dynamic class TowerShoot extends Sound {
public function TowerShoot(){
super();
}
}
}//package
Section 280
//WaveData (WaveData)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import creeps.*;
import levels.level1.*;
import flash.text.*;
public class WaveData extends Sprite {
private var creepsContainer:CreepsContainer;
private var currentMapLevel:Number;
private var timer:Timer;
public var waveDT:TextField;
private var creepsAlive:Number;// = 0
private var creeps:Array;
public var creepsDT:TextField;
private var wavesPreview:WavesPreview;
public var levelsKoeff:Array;
public function WaveData(){
levelsKoeff = [0, 1, (46 / 29), (89 / 29), (57 / 29), (60 / 29), (46 / 29)];
creeps = new Array();
creepsAlive = 0;
super();
new Wave1();
new Wave2();
Global.currentLevel = new Level1();
}
public function setWavesPreview(p:WavesPreview):void{
this.wavesPreview = p;
}
public function startWave():void{
var waveClassName:Class;
var nn:Number;
var nextWaveClassName:Class;
if (this.timer != null){
if (this.timer.running){
return;
};
};
Global.wave++;
waveClassName = (getDefinitionByName(("levels.level1.Wave" + Global.wave)) as Class);
Global.currentWave = new (waveClassName);
if ((Global.wave + 1) <= Global.currentLevel.waves){
nn = (Global.wave + 1);
nextWaveClassName = (getDefinitionByName(("levels.level1.Wave" + nn)) as Class);
Global.nextWave = new (nextWaveClassName);
Global.currentWave.hitpoints = Math.floor((Global.currentWave.hitpoints * this.levelsKoeff[this.currentMapLevel]));
Global.currentWave.hitpoints = Math.floor((Global.currentWave.hitpoints * (1 + ((this.currentMapLevel - 1) / 6))));
} else {
Global.nextWave = null;
};
this.waveDT.text = ((Global.wave.toString() + "/") + Global.currentLevel.waves.toString());
if (Global.isDoubleSpeed == false){
this.timer = new Timer(Global.currentWave.betweenInterval, Global.currentWave.totalAmount);
} else {
this.timer = new Timer((Global.currentWave.betweenInterval / 2), Global.currentWave.totalAmount);
};
this.timer.addEventListener(TimerEvent.TIMER, tick);
this.timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
this.timer.start();
this.creepsAlive = (this.creepsAlive + Global.currentWave.totalAmount);
this.creepsDT.text = this.creepsAlive.toString();
this.wavesPreview.nextLevel();
Global.selectedTowerInfo.updateWaveInfo();
Global.soundManager.addAppearSound();
}
public function startLevel(n:Number):void{
var waveClassName:Class;
this.currentMapLevel = n;
Global.wave = 0;
this.creeps = new Array();
this.creepsAlive = 0;
this.wavesPreview.startLevel();
waveClassName = (getDefinitionByName(((("levels.level" + 1) + ".Wave") + 1)) as Class);
Global.currentWave = new (waveClassName);
Global.currentWave.hitpoints = Math.floor((Global.currentWave.hitpoints * this.levelsKoeff[this.currentMapLevel]));
Global.currentWave.hitpoints = Math.floor((Global.currentWave.hitpoints * (1 + ((this.currentMapLevel - 1) / 6))));
Global.selectedTowerInfo.hideInfo();
}
private function tick(e:TimerEvent):void{
var creep:Creep;
creep = this.creepsContainer.addCreep();
creep.speed = Global.currentWave.speed;
creep.gold = Global.currentWave.gold;
creep.totalHitpoints = Global.currentWave.hitpoints;
creep.hitpoints = Global.currentWave.hitpoints;
creep.exp = Global.currentWave.exp;
creep.addEventListener("ImDead", creepDie);
creep.addEventListener("ImAttack", creepAttack);
creep.damageToCastle = (Math.floor(((Global.currentWave.maxDamage - Global.currentWave.minDamage) * Math.random())) + Global.currentWave.minDamage);
this.creeps.push(creep);
}
public function setCreepsContainer(c:CreepsContainer){
this.creepsContainer = c;
}
private function creepAttack(e:Event):void{
this.creepsAlive--;
this.creepsDT.text = this.creepsAlive.toString();
if (Global.wave == Global.currentLevel.waves){
if (this.creepsAlive == 0){
Global.gameManager.showLevelsWindow();
this.dispatchEvent(new Event("save"));
};
};
}
private function creepDie(e:Event):void{
var creep:Creep;
var l:Number;
creep = (e.target as Creep);
Global.topMenu.addGold(creep.gold);
Global.topMenu.addExp(creep.exp);
this.creepsAlive--;
this.creepsDT.text = this.creepsAlive.toString();
if (Global.wave == Global.currentLevel.waves){
if (this.creepsAlive == 0){
l = this.currentMapLevel;
if (l < Global.lockedLevels.length){
Global.lockedLevels[this.currentMapLevel] = 0;
};
Global.gameManager.showLevelsWindow();
this.dispatchEvent(new Event("save"));
};
};
}
public function startSingleCreep():void{
var creep:Creep;
creep = this.creepsContainer.addCreep();
creep.addEventListener("ImDead", creepDie);
this.creeps.push(creep);
}
private function onTimerComplete(e:TimerEvent):void{
this.timer.stop();
}
}
}//package
Section 281
//WavePreviewIcon (WavePreviewIcon)
package {
import flash.display.*;
import levels.*;
import flash.text.*;
public class WavePreviewIcon extends MovieClip {
public var dt:TextField;
public function WavePreviewIcon(){
super();
}
public function setInfo(waveData:WaveBase, waveNumber:Number):void{
SimpleToolTip.addToolTip(this, ((("N:" + waveData.totalAmount) + "\n") + waveData.description));
this.dt.text = waveNumber.toString();
this.dt.mouseEnabled = false;
}
public function setNumber(n:Number):void{
}
}
}//package
Section 282
//WavesPreview (WavesPreview)
package {
import flash.display.*;
import flash.events.*;
import caurina.transitions.*;
import flash.utils.*;
public class WavesPreview extends MovieClip {
public var bg:MovieClip;
private var introTimer:Timer;
private var level:Number;// = 0
public var waveIcons:Array;
public function WavesPreview(){
level = 0;
super();
}
public function nextLevel():void{
var i:Number;
this.level++;
this.removeChild(this.waveIcons[(this.level - 1)]);
i = this.level;
while (i <= Global.currentLevel.waves) {
Tweener.addTween(this.waveIcons[(i - 1)], {y:(18 * ((i - this.level) - 1)), time:0.3, transition:"easeIn"});
i++;
};
}
public function reset():void{
this.level = 0;
}
private function tick(e:TimerEvent):void{
var i:Number;
i = (this.introTimer.currentCount - 1);
Tweener.addTween(this.waveIcons[i], {y:(18 * i), time:0.2, transition:"easeIn"});
}
public function startLevel():void{
var i:Number;
var icon:WavePreviewIcon;
trace("WavesPreview.startLevel");
if (this.waveIcons != null){
i = 0;
while (i < this.waveIcons.length) {
if (this.waveIcons[i]["parent"] != null){
this.removeChild(this.waveIcons[i]);
};
this.waveIcons[i] = null;
i++;
};
};
this.waveIcons = new Array();
i = 1;
while (i <= Global.currentLevel.waves) {
icon = new WavePreviewIcon();
icon.setInfo(Global.currentLevel.wavesArray[(i - 1)], i);
this.addChild(icon);
icon.y = this.stage.stageHeight;
icon.y = 500;
this.waveIcons.push(icon);
i++;
};
this.introTimer = new Timer(50, (Global.currentLevel.waves + 1));
this.introTimer.addEventListener(TimerEvent.TIMER, tick);
this.introTimer.start();
}
}
}//package