Section 1
//ExplosionLoop_49 (OmegaTowerDefense_fla.ExplosionLoop_49)
package OmegaTowerDefense_fla {
import flash.display.*;
public dynamic class ExplosionLoop_49 extends MovieClip {
public var s:Number;
public function ExplosionLoop_49(){
addFrameScript(0, frame1, 20, frame21);
}
function frame1(){
gotoAndPlay(Math.floor((Math.random() * 10)));
}
function frame21(){
gotoAndPlay(1);
this.rotation = (this.rotation + (Math.random() * 500));
s = ((Math.random() * 3) - 1.5);
this.scaleX = s;
this.scaleY = s;
}
}
}//package OmegaTowerDefense_fla
Section 2
//PauseBtn_37 (OmegaTowerDefense_fla.PauseBtn_37)
package OmegaTowerDefense_fla {
import flash.display.*;
import flash.text.*;
public dynamic class PauseBtn_37 extends MovieClip {
public var label:TextField;
public var bg:MovieClip;
}
}//package OmegaTowerDefense_fla
Section 3
//SellBtn_7 (OmegaTowerDefense_fla.SellBtn_7)
package OmegaTowerDefense_fla {
import flash.display.*;
import flash.text.*;
public dynamic class SellBtn_7 extends MovieClip {
public var label:TextField;
public var highlight:MovieClip;
}
}//package OmegaTowerDefense_fla
Section 4
//UpgradeBtn_3 (OmegaTowerDefense_fla.UpgradeBtn_3)
package OmegaTowerDefense_fla {
import flash.display.*;
import flash.text.*;
public dynamic class UpgradeBtn_3 extends MovieClip {
public var label:TextField;
public var highlight:MovieClip;
}
}//package OmegaTowerDefense_fla
Section 5
//Arial (Arial)
package {
import flash.text.*;
public dynamic class Arial extends Font {
}
}//package
Section 6
//BgMusic (BgMusic)
package {
import flash.media.*;
public dynamic class BgMusic extends Sound {
}
}//package
Section 7
//Blade (Blade)
package {
import flash.display.*;
public dynamic class Blade extends Sprite {
}
}//package
Section 8
//BladeImg (BladeImg)
package {
import flash.display.*;
public dynamic class BladeImg extends Sprite {
}
}//package
Section 9
//BladeLauncher (BladeLauncher)
package {
import flash.display.*;
public dynamic class BladeLauncher extends Sprite {
}
}//package
Section 10
//Bomb (Bomb)
package {
import flash.display.*;
public dynamic class Bomb extends Sprite {
}
}//package
Section 11
//Creep (Creep)
package {
import flash.display.*;
public class Creep extends Sprite {
public var life:Number;
public var fullLife:Number;
public var speed:Number;
public var dead:Boolean;// = false
public var speedMultiplier:Number;
public var moneyValue:int;
public var spr:Sprite;
public var targetCheckPoint:int;
public function Creep(){
dead = false;
super();
targetCheckPoint = 1;
}
}
}//package
Section 12
//Creep_4Ball (Creep_4Ball)
package {
import flash.display.*;
public dynamic class Creep_4Ball extends Sprite {
}
}//package
Section 13
//Creep_Biter (Creep_Biter)
package {
import flash.display.*;
public dynamic class Creep_Biter extends Sprite {
}
}//package
Section 14
//Creep_Brain (Creep_Brain)
package {
import flash.display.*;
public dynamic class Creep_Brain extends Sprite {
}
}//package
Section 15
//Creep_Bubble (Creep_Bubble)
package {
import flash.display.*;
public dynamic class Creep_Bubble extends Sprite {
}
}//package
Section 16
//Creep_Eye (Creep_Eye)
package {
import flash.display.*;
public dynamic class Creep_Eye extends Sprite {
}
}//package
Section 17
//Creep_Flyer (Creep_Flyer)
package {
import flash.display.*;
public dynamic class Creep_Flyer extends Sprite {
}
}//package
Section 18
//Creep_PodMonster (Creep_PodMonster)
package {
import flash.display.*;
public dynamic class Creep_PodMonster extends Sprite {
}
}//package
Section 19
//Creep_Segment (Creep_Segment)
package {
import flash.display.*;
public dynamic class Creep_Segment extends Sprite {
}
}//package
Section 20
//Creep_Skull (Creep_Skull)
package {
import flash.display.*;
public dynamic class Creep_Skull extends Sprite {
}
}//package
Section 21
//Creep_Spider (Creep_Spider)
package {
import flash.display.*;
public dynamic class Creep_Spider extends Sprite {
}
}//package
Section 22
//Creep_Spiker (Creep_Spiker)
package {
import flash.display.*;
public dynamic class Creep_Spiker extends Sprite {
}
}//package
Section 23
//Creep_WormBody (Creep_WormBody)
package {
import flash.display.*;
public dynamic class Creep_WormBody extends Sprite {
}
}//package
Section 24
//Creep_WormHead (Creep_WormHead)
package {
import flash.display.*;
public dynamic class Creep_WormHead extends Sprite {
}
}//package
Section 25
//Explosion (Explosion)
package {
import flash.display.*;
public dynamic class Explosion extends MovieClip {
public function Explosion(){
addFrameScript(7, frame8);
}
function frame8(){
stop();
}
}
}//package
Section 26
//GameBg (GameBg)
package {
import flash.display.*;
public dynamic class GameBg extends Sprite {
}
}//package
Section 27
//GameMenu (GameMenu)
package {
import flash.display.*;
public dynamic class GameMenu extends Sprite {
public var moreGamesBtn:SimpleButton;
public var highScoresBtn:SimpleButton;
public var playNowBtn:SimpleButton;
}
}//package
Section 28
//GameOverScreen (GameOverScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class GameOverScreen extends Sprite {
public var finalScoreTxt:TextField;
public var continueBtn:SimpleButton;
public var submitScoreBtn:SimpleButton;
public var highScoreNameTxt:TextField;
}
}//package
Section 29
//HighScoresScreen (HighScoresScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class HighScoresScreen extends Sprite {
public var backBtn:SimpleButton;
public var namesTxt:TextField;
public var statusTxt:TextField;
public var scoresTxt:TextField;
}
}//package
Section 30
//LaserPirateHighScoreService (LaserPirateHighScoreService)
package {
import flash.events.*;
import flash.net.*;
public class LaserPirateHighScoreService {
public var successCallback:Function;
public var errorCallback:Function;
var gameCode:String;
public function LaserPirateHighScoreService(_arg1:String){
this.gameCode = _arg1;
}
private function openHandler(_arg1:Event):void{
}
private function securityErrorHandler(_arg1:SecurityErrorEvent):void{
errorCallback("security error");
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
errorCallback("io error");
}
private function completeHandler(_arg1:Event):void{
var scores:Array;
var i:*;
var xml:XML;
var event = _arg1;
try {
xml = new XML(URLLoader(event.target).data);
} catch(e) {
errorCallback(("completeHandler try failed" + e.toString()));
return;
};
scores = new Array();
for each (i in xml.children()) {
scores.push({name:i.name, score:i.score});
};
successCallback(scores);
}
private function httpStatusHandler(_arg1:HTTPStatusEvent):void{
}
public function getScores(_arg1:Function, _arg2:Function):void{
var loader:URLLoader;
var request:URLRequest;
var successCallback = _arg1;
var errorCallback = _arg2;
this.successCallback = successCallback;
this.errorCallback = errorCallback;
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(Event.OPEN, openHandler);
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
try {
request = new URLRequest(("http://www.laserpirate.com/generic_high_scores/get_scores.php?game_code=" + gameCode));
request.method = URLRequestMethod.POST;
loader.load(request);
} catch(e) {
errorCallback("getScore try failed");
};
}
public function submitScore(_arg1:String, _arg2:int, _arg3:Function, _arg4:Function):void{
var loader:URLLoader;
var request:URLRequest;
var urlVars:URLVariables;
var name = _arg1;
var score = _arg2;
var successCallback = _arg3;
var errorCallback = _arg4;
this.successCallback = successCallback;
this.errorCallback = errorCallback;
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(Event.OPEN, openHandler);
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
try {
request = new URLRequest("http://www.laserpirate.com/generic_high_scores/submit_score.php");
urlVars = new URLVariables();
urlVars.game_code = gameCode;
urlVars.name = name;
urlVars.score = score;
request.data = urlVars;
request.method = URLRequestMethod.POST;
loader.load(request);
} catch(e) {
errorCallback("submitScore try failed");
};
}
private function progressHandler(_arg1:ProgressEvent):void{
}
}
}//package
Section 31
//LightArtillery (LightArtillery)
package {
import flash.display.*;
public dynamic class LightArtillery extends Sprite {
}
}//package
Section 32
//MenuBar (MenuBar)
package {
import flash.display.*;
public dynamic class MenuBar extends Sprite {
public var bg:TowerDialogBg;
public var smallSlowTowerBtn:SmallSlowTower;
public var bombBtn:Bomb;
public var exitBtn:SimpleButton;
public var shockTowerBtn:ShockTower;
public var lightArtilleryBtn:LightArtillery;
public var moneyTowerBtn:MoneyTower;
public var pauseBtn:MovieClip;
public var smallLaserTowerBtn:SmallLaserTower;
public var launcherBtn:BladeLauncher;
public var smallMissileTowerBtn:SmallMissileTower;
}
}//package
Section 33
//Missile (Missile)
package {
import flash.display.*;
public class Missile extends Sprite {
public var dead:Boolean;// = false
public var damage:int;
public var vx:Number;// = 0
public var vy:Number;// = 0
public var splashRadius:Number;
public function Missile(){
vx = 0;
vy = 0;
dead = false;
super();
}
}
}//package
Section 34
//MochiAd (MochiAd)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.2");
}
public static function showTimedAd(_arg1:Object):void{
MochiAd.showInterLevelAd(_arg1);
}
public static function _allowDomains(_arg1:String):String{
var _local2:String;
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function load(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var depth:Number;
var mc:MovieClip;
var wh:Array;
var lv:URLVariables;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var f:Function;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
DEFAULTS = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
lv = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
f = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
mc._mochiad_ctr_failed = true;
};
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function sendHighScore(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["sendHighScore", _arg1], _arg2, _arg3);
return (true);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local3:Object;
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
_local3 = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _cleanup(_arg1:Object):void{
var idx:Number;
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
idx = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = _local1.loaderInfo.bytesTotal;
if ((((_local4 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
_local3 = true;
};
};
};
if ((((_local2 > chk.ad_msec)) || (this.parent._mochiad_ctr_failed))){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local3:Object;
var _local4:Number;
var _local5:Number;
var _local6:Array;
_local3 = _arg2.getBounds(_arg2.root);
_local4 = 0;
_local5 = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip;
_local4 = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _loadCommunicator(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var clipname:String;
var server:String;
var depth:Number;
var mc:MovieClip;
var lv:URLVariables;
var k:String;
var lc:LocalConnection;
var name:String;
var req:URLRequest;
var loader:Loader;
var options = _arg1;
DEFAULTS = {com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
clipname = ("_mochiad_com_" + options.id);
if (!MochiAd._isNetworkAvailable()){
return (null);
};
if (clip[clipname]){
return (clip[clipname]);
};
server = (options.com_server + options.id);
MochiAd._allowDomains(server);
delete options.id;
delete options.com_server;
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, clipname, depth);
lv = new URLVariables();
for (k in options) {
lv[k] = options[k];
};
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.name = name;
mc.lc = lc;
lv.lc = name;
mc._id = 0;
mc._queue = [];
mc.rpcResult = function (_arg1:Object):void{
var _local3:Array;
var _local4:Array;
var _local5:Number;
var _local6:Object;
var _local7:Object;
_arg1 = parseInt(_arg1.toString());
_local3 = mc._callbacks[_arg1];
if (typeof(_local3) == "undefined"){
return;
};
delete mc._callbacks[_arg1];
_local4 = [];
_local5 = 2;
while (_local5 < _local3.length) {
_local4.push(_local3[_local5]);
_local5++;
};
_local5 = 1;
while (_local5 < arguments.length) {
_local4.push(arguments[_local5]);
_local5++;
};
_local6 = _local3[1];
_local7 = _local3[0];
if (((_local7) && ((typeof(_local6) == "string")))){
_local6 = _local7[_local6];
};
if (typeof(_local6) == "function"){
_local6.apply(_local7, _local4);
};
};
mc._didConnect = function (_arg1:String):void{
var _local2:Array;
var _local3:Function;
var _local4:Number;
var _local5:Array;
mc._endpoint = _arg1;
_local2 = mc._queue;
delete mc._queue;
_local3 = mc.doSend;
_local4 = 0;
while (_local4 < _local2.length) {
_local5 = _local2[_local4];
_local3.apply(this, _local5);
_local4++;
};
};
mc.doSend = function (_arg1:Array, _arg2:Object, _arg3:Object):void{
var _local5:Number;
var _local6:LocalConnection;
var _local7:Array;
var _local8:Number;
if (mc._endpoint == null){
_local7 = [];
_local8 = 0;
while (_local8 < arguments.length) {
_local7.push(arguments[_local8]);
_local8++;
};
mc._queue.push(_local7);
return;
};
mc._id = (mc._id + 1);
_local5 = mc._id;
mc._callbacks[_local5] = [_arg2, ((_arg3) || (_arg2))];
_local6 = new LocalConnection();
_local6.send(mc._endpoint, "rpc", _local5, _arg1);
};
mc._callbacks = {};
mc._callbacks[0] = [mc, "_didConnect"];
lv.st = getTimer();
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader = new Loader();
loader.load(req);
mc.addChild(loader);
mc._mochiad_com = loader;
return (mc);
}
public static function showPreGameAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var bar:MovieClip;
var bar_color:Number;
var bar_background:Number;
var bar_outline:Number;
var backing_mc:MovieClip;
var backing:Object;
var inside_mc:MovieClip;
var inside:Object;
var outline_mc:MovieClip;
var outline:Object;
var complete:Boolean;
var unloaded:Boolean;
var f:Function;
var r:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
var fn:Function;
MochiAd._cleanup(mc);
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
bar = createEmptyMovieClip(chk, "_mochiad_bar", 4);
bar.x = 10;
bar.y = (h - 20);
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
f = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Object;
var _local10:Number;
var _local11:Number;
if (!this.parent.parent){
delete this["onEnterFrame"];
return;
};
_local1 = this.parent.parent.root;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
_local7 = ((100 * _local6) / _local5);
_local8 = ((100 * _local3) / chk.ad_msec);
_local9 = this._mochiad_bar._inside;
_local10 = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
if (!chk.showing){
_local11 = _local2.loaderInfo.bytesTotal;
if ((((_local11 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local3 > chk.ad_timeout){
_local4 = true;
};
};
};
if ((((_local3 > chk.ad_msec)) || (this.parent._mochiad_ctr_failed))){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
MochiAd.showPreGameAd(_arg1);
}
public static function fetchHighScores(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["fetchHighScores", _arg1], _arg2, _arg3);
return (true);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var f:Function;
var mc = _arg1;
f = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 35
//MoneyTower (MoneyTower)
package {
import flash.display.*;
public dynamic class MoneyTower extends Sprite {
}
}//package
Section 36
//MusicBtn (MusicBtn)
package {
import flash.display.*;
public dynamic class MusicBtn extends SimpleButton {
}
}//package
Section 37
//OmegaTowerDefense (OmegaTowerDefense)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.media.*;
import flash.net.*;
import flash.filters.*;
import flash.geom.*;
import flash.ui.*;
public class OmegaTowerDefense extends Sprite {
var towerDialogRangeUpgrader:StatUpgrader;
public var bgMusicChannel:SoundChannel;
var laserCanvas:Sprite;
public var upgradeSinTable:Array;
public var drawMouseOverTowerAlphaTarget:Number;// = 0
var missiles:Array;
var draggingTowerRadius:Number;
var menuBar:MenuBar;
public var towerData:Object;
var creepWaveData:Array;
var gameMenu:GameMenu;
var towerDialogDamageUpgrader:StatUpgrader;
var scoreTxt:TextField;
var creepContainer:Sprite;
var towers:Array;
var highScoreService:LaserPirateHighScoreService;
var score:Number;
var shockCanvas:Sprite;
var particleContainer:Sprite;
var fmt:TextFormat;
var towerDialogReloadUpgrader:StatUpgrader;
var creepsToSpawnThisWave:int;
var particles:Array;
var highScoresScreen:HighScoresScreen;
var waveTxt:TextField;
public var drawMouseOverTowerRangeTarget:Number;// = 0
var CREEP_DIST_TO_REACH_CHECKPOINT:Number;// = 5
var framesUntilSpawnCreep:int;
var finalScore:int;
var creepPath:Array;
var money:int;
public var upgradeCosTable:Array;
var textContainer2:Sprite;
public var bgMusicOn:Boolean;
public var bgMusic:BgMusic;
var creepPathCavas:Sprite;
var rangeCanvas:Sprite;
var draggingTower:Boolean;// = false
var life:int;
var infoTxt:TextField;
var paused:Boolean;// = false
var BOMB_EXPLODE_RANGE:Number;// = 50
var draggingTowerType:String;
var draggingTowerTypeCostToBuy:int;
var gameOn:Boolean;// = false
var draggingTowerPreview:Sprite;
var towerContainer:Sprite;
var particleCanvas:Sprite;
var currCreepWave:int;
var moneyTxt:TextField;
var creeps:Array;
var dialogTargetTower:Tower;
public var drawMouseOverTowerRangeCurr:Number;// = 0
var towerDialogIsOpen:Boolean;// = false
public var drawMouseOverTowerRangeY:Number;// = 0
var towerDialog:TowerDialog;
var adContainer:MochiContainer;
var frameCounter:int;// = 0
public var drawMouseOverTowerRangeX:Number;// = 0
var lifeTxt:TextField;
var lifebarCanvas:Sprite;
var gameBg:GameBg;
var textContainer:Sprite;
var sellValueFrac:Number;// = 0.9
var gameOverScreen:GameOverScreen;
public var musicBtn:MusicBtn;
public var drawMouseOverTowerAlpha:Number;// = 0
var effectTime:Number;// = 0
public static const EXPLOSION_PARTICLE_PARTICLE_MAX_AGE:int = 8;
public static const STAGE_WIDTH:int = 640;
public static const STAGE_HEIGHT:int = 480;
public static const BLADE_PARTICLE_EXPLDOE_DIST:int = 20;
public static const BLADE_PARTICLE:int = 1;
public static const HIGH_SCORE_GAME_CODE:String = "omega_defense";
public static const EXPLOSION_PARTICLE:int = 0;
public static const TEXT_PARTICLE:int = 2;
public static const TEXT_PARTICLE_PARTICLE_MAX_AGE:int = 15;
public static const BLADE_PARTICLE_INIT_ANIM_DURATION:int = 20;
public function OmegaTowerDefense(){
fmt = new TextFormat();
gameOn = false;
paused = false;
draggingTower = false;
towers = new Array();
creepPath = [{x:150, y:1}, {x:149, y:16}, {x:148, y:33}, {x:140, y:48}, {x:136, y:68}, {x:143, y:91}, {x:152, y:104}, {x:163, y:114}, {x:171, y:126}, {x:175, y:141}, {x:184, y:147}, {x:196, y:154}, {x:199, y:169}, {x:194, y:181}, {x:186, y:195}, {x:176, y:202}, {x:162, y:205}, {x:150, y:208}, {x:137, y:214}, {x:129, y:224}, {x:128, y:234}, {x:120, y:248}, {x:117, y:259}, {x:112, y:272}, {x:113, y:284}, {x:116, y:296}, {x:130, y:301}, {x:144, y:306}, {x:158, y:307}, {x:170, y:317}, {x:186, y:319}, {x:203, y:316}, {x:214, y:312}, {x:228, y:306}, {x:248, y:303}, {x:264, y:304}, {x:277, y:307}, {x:290, y:311}, {x:299, y:324}, {x:302, y:337}, {x:299, y:349}, {x:298, y:363}, {x:297, y:381}, {x:304, y:395}, {x:308, y:404}, {x:316, y:414}, {x:327, y:423}, {x:345, y:430}, {x:361, y:430}, {x:385, y:431}, {x:402, y:427}, {x:423, y:416}, {x:436, y:404}, {x:450, y:396}, {x:455, y:379}, {x:459, y:362}, {x:460, y:346}, {x:460, y:327}, {x:458, y:310}, {x:452, y:297}, {x:448, y:281}, {x:446, y:270}, {x:457, y:262}, {x:471, y:259}, {x:487, y:0x0101}, {x:505, y:259}, {x:520, y:261}, {x:537, y:264}, {x:552, y:259}, {x:566, y:249}, {x:577, y:240}, {x:585, y:228}, {x:590, y:216}, {x:593, y:200}, {x:594, y:179}, {x:592, y:165}, {x:593, y:148}, {x:590, y:125}, {x:588, y:109}, {x:601, y:100}, {x:610, y:82}, {x:603, y:60}, {x:586, y:46}, {x:575, y:36}, {x:575, y:27}, {x:575, y:7}, {x:575, y:2}];
creeps = new Array();
frameCounter = 0;
effectTime = 0;
missiles = new Array();
particles = new Array();
BOMB_EXPLODE_RANGE = 50;
CREEP_DIST_TO_REACH_CHECKPOINT = 5;
creepWaveData = [{spriteClass:Creep_Biter, life:5, speed:2, spawnFrameDelay:30, numCreepsInWave:35, moneyValue:5}, {spriteClass:Creep_Flyer, life:5, speed:3, spawnFrameDelay:20, numCreepsInWave:30, moneyValue:5}, {spriteClass:Creep_Bubble, life:6, speed:1, spawnFrameDelay:40, numCreepsInWave:20, moneyValue:5}, {spriteClass:Creep_Skull, life:10, speed:2, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:10}, {spriteClass:Creep_Segment, life:7, speed:2, spawnFrameDelay:5, numCreepsInWave:10, moneyValue:5}, {spriteClass:Creep_WormHead, life:15, speed:2, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:25}, {spriteClass:Creep_WormBody, life:8, speed:2, spawnFrameDelay:5, numCreepsInWave:10, moneyValue:5}, {spriteClass:Creep_Skull, life:20, speed:2.1, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:30}, {spriteClass:Creep_Segment, life:10, speed:2.1, spawnFrameDelay:5, numCreepsInWave:25, moneyValue:5}, {spriteClass:Creep_Spider, life:12, speed:3, spawnFrameDelay:30, numCreepsInWave:10, moneyValue:6}, {spriteClass:Creep_Skull, life:13, speed:2, spawnFrameDelay:30, numCreepsInWave:10, moneyValue:6}, {spriteClass:Creep_4Ball, life:13, speed:2.5, spawnFrameDelay:11, numCreepsInWave:35, moneyValue:10}, {spriteClass:Creep_Brain, life:60, speed:1, spawnFrameDelay:70, numCreepsInWave:3, moneyValue:25}, {spriteClass:Creep_Eye, life:15, speed:2, spawnFrameDelay:30, numCreepsInWave:15, moneyValue:6}, {spriteClass:Creep_Spiker, life:20, speed:2, spawnFrameDelay:30, numCreepsInWave:25, moneyValue:6}, {spriteClass:Creep_PodMonster, life:100, speed:1, spawnFrameDelay:70, numCreepsInWave:3, moneyValue:50}, {spriteClass:Creep_Biter, life:20, speed:2, spawnFrameDelay:30, numCreepsInWave:20, moneyValue:7, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Flyer, life:21, speed:3, spawnFrameDelay:20, numCreepsInWave:20, moneyValue:7, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Bubble, life:22, speed:1, spawnFrameDelay:40, numCreepsInWave:15, moneyValue:7, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Skull, life:50, speed:2, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:30, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Segment, life:25, speed:2, spawnFrameDelay:5, numCreepsInWave:10, moneyValue:7, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_WormHead, life:70, speed:2, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:30, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_WormBody, life:25, speed:2, spawnFrameDelay:5, numCreepsInWave:10, moneyValue:7, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Skull, life:80, speed:2.1, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:50, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Segment, life:20, speed:2.1, spawnFrameDelay:5, numCreepsInWave:25, moneyValue:7, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Spider, life:20, speed:3, spawnFrameDelay:30, numCreepsInWave:10, moneyValue:8, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Skull, life:26, speed:2, spawnFrameDelay:30, numCreepsInWave:10, moneyValue:8, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_4Ball, life:25, speed:3, spawnFrameDelay:10, numCreepsInWave:35, moneyValue:8, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Brain, life:40, speed:1, spawnFrameDelay:70, numCreepsInWave:3, moneyValue:75, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Eye, life:30, speed:2, spawnFrameDelay:30, numCreepsInWave:15, moneyValue:9, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Spiker, life:31, speed:2, spawnFrameDelay:30, numCreepsInWave:25, moneyValue:9, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_PodMonster, life:250, speed:1, spawnFrameDelay:70, numCreepsInWave:3, moneyValue:100, tint:{r:50, g:0, b:0}}, {spriteClass:Creep_Biter, life:32, speed:2.5, spawnFrameDelay:30, numCreepsInWave:30, moneyValue:10, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Flyer, life:33, speed:3.5, spawnFrameDelay:20, numCreepsInWave:30, moneyValue:10, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Bubble, life:34, speed:1.5, spawnFrameDelay:40, numCreepsInWave:45, moneyValue:10, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Skull, life:100, speed:2.5, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:30, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Segment, life:35, speed:2.5, spawnFrameDelay:5, numCreepsInWave:20, moneyValue:10, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_WormHead, life:150, speed:2.5, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:30, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_WormBody, life:35, speed:2.5, spawnFrameDelay:5, numCreepsInWave:20, moneyValue:10, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Skull, life:200, speed:2.1, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:40, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Segment, life:50, speed:2.1, spawnFrameDelay:5, numCreepsInWave:35, moneyValue:10, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Spider, life:60, speed:3.5, spawnFrameDelay:30, numCreepsInWave:20, moneyValue:11, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Skull, life:70, speed:2.5, spawnFrameDelay:30, numCreepsInWave:20, moneyValue:11, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_4Ball, life:80, speed:3.5, spawnFrameDelay:10, numCreepsInWave:45, moneyValue:11, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Brain, life:100, speed:1.5, spawnFrameDelay:70, numCreepsInWave:5, moneyValue:120, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Eye, life:90, speed:2.5, spawnFrameDelay:30, numCreepsInWave:25, moneyValue:11, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Spiker, life:100, speed:2.5, spawnFrameDelay:30, numCreepsInWave:35, moneyValue:11, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_PodMonster, life:250, speed:1.5, spawnFrameDelay:70, numCreepsInWave:5, moneyValue:150, tint:{r:0, g:60, b:0}}, {spriteClass:Creep_Biter, life:110, speed:4, spawnFrameDelay:30, numCreepsInWave:40, moneyValue:12, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Flyer, life:120, speed:5, spawnFrameDelay:20, numCreepsInWave:40, moneyValue:12, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Bubble, life:130, speed:3, spawnFrameDelay:40, numCreepsInWave:55, moneyValue:13, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Skull, life:200, speed:4, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:40, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Segment, life:140, speed:4, spawnFrameDelay:5, numCreepsInWave:30, moneyValue:13, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_WormHead, life:250, speed:4, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:40, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_WormBody, life:150, speed:4, spawnFrameDelay:5, numCreepsInWave:30, moneyValue:14, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Skull, life:300, speed:4.5, spawnFrameDelay:-95, numCreepsInWave:1, moneyValue:50, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Segment, life:160, speed:4.5, spawnFrameDelay:5, numCreepsInWave:55, moneyValue:14, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Spider, life:175, speed:5, spawnFrameDelay:30, numCreepsInWave:30, moneyValue:14, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Skull, life:200, speed:4, spawnFrameDelay:30, numCreepsInWave:30, moneyValue:14, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_4Ball, life:250, speed:5, spawnFrameDelay:10, numCreepsInWave:55, moneyValue:14, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Brain, life:300, speed:3, spawnFrameDelay:70, numCreepsInWave:5, moneyValue:150, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Eye, life:500, speed:4, spawnFrameDelay:30, numCreepsInWave:35, moneyValue:15, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_Spiker, life:600, speed:4, spawnFrameDelay:30, numCreepsInWave:50, moneyValue:15, tint:{r:-50, g:-50, b:-60}}, {spriteClass:Creep_PodMonster, life:10000, speed:4.5, spawnFrameDelay:20, numCreepsInWave:1000, moneyValue:50, tint:{r:-50, g:-50, b:-60}}];
towerData = {artillery:{price:100, range:70, maxRange:110, rangeUpgradeCost:15, reloadTime:20, minReloadTime:10, reloadUpgradeCost:20, damage:1, maxDamage:2, damageUpgradeCost:20, radius:10, name:"Light Artillery", desc:"Light Artillery - Does a small amount of damage to a single nearby target."}, shock:{radius:16, price:700, range:90, maxRange:130, rangeUpgradeCost:100, reloadTime:30, minReloadTime:15, reloadUpgradeCost:125, damage:1, maxDamage:2, damageUpgradeCost:125, name:"Shock Tower", desc:"Shock Tower - Damages all creeps within range."}, bomb:{price:100, range:100, maxRange:140, rangeUpgradeCost:10, reloadTime:-1, damage:10, maxDamage:50, damageUpgradeCost:50, name:"Bomb", desc:"Bomb - Explodes only once, but does a lot of damage. There is a short delay before the explosion. Use bombs to stop creeps that would otherwise get through."}, laser:{price:200, range:90, maxRange:130, rangeUpgradeCost:25, reloadTime:50, minReloadTime:25, reloadUpgradeCost:40, damage:5, maxDamage:10, damageUpgradeCost:40, name:"Laser Turret", desc:"Laser Turret - Shoots a concentrated photon beam a single nearby creep."}, slow:{price:700, range:90, maxRange:130, rangeUpgradeCost:100, reloadTime:-1, damage:-1, name:"Slow Field Generator", desc:"Slow Field Generator - Decreases the rate of movement of creeps within range."}, missile:{price:350, range:110, maxRange:150, rangeUpgradeCost:50, reloadTime:25, minReloadTime:10, reloadUpgradeCost:60, damage:4, maxDamage:10, damageUpgradeCost:60, splashRadius:20, name:"Heavy Artillery", desc:"Heavy Artillery - Shoots missiles that damage everything within the explosion."}, money:{price:100, range:100, maxRange:140, rangeUpgradeCost:10, reloadTime:-1, damage:-1, name:"Money Booster", desc:"Money Tower - Gain one extra unit of money for each creep killed within this tower's range."}, launcher:{price:1000, range:150, maxRange:200, rangeUpgradeCost:140, reloadTime:10, minReloadTime:5, reloadUpgradeCost:140, damage:2, maxDamage:20, damageUpgradeCost:500, name:"Blade Launcher", desc:"Launches flying blades that seek creeps."}};
towerDialogIsOpen = false;
sellValueFrac = 0.9;
upgradeSinTable = new Array();
upgradeCosTable = new Array();
drawMouseOverTowerRangeTarget = 0;
drawMouseOverTowerRangeCurr = 0;
drawMouseOverTowerRangeX = 0;
drawMouseOverTowerRangeY = 0;
drawMouseOverTowerAlpha = 0;
drawMouseOverTowerAlphaTarget = 0;
super();
showMochiAd();
}
function sellBtnOver(_arg1):void{
towerDialog.sellBtn.highlight.visible = true;
}
public function showInfoForTowerType(_arg1:String):void{
var _local2:String;
_local2 = (((towerData[_arg1].desc + "\nPrice: ") + towerData[_arg1].price) + " ");
if (towerData[_arg1].damage > 0){
_local2 = (_local2 + (("Damage: " + towerData[_arg1].damage) + " "));
};
if (towerData[_arg1].range > 0){
_local2 = (_local2 + (("Range: " + towerData[_arg1].range) + " "));
};
if (towerData[_arg1].reloadTime > 0){
_local2 = (_local2 + (("Reload Time: " + towerData[_arg1].reloadTime) + " "));
};
if (towerData[_arg1].splashRadius > 0){
_local2 = (_local2 + (("Splash: " + towerData[_arg1].splashRadius) + " "));
};
infoTxt.text = _local2;
}
public function smallLaserTowerBtnOver(_arg1):void{
showInfoForTowerType("laser");
}
public function shootGuns():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:Number;
var _local10:Boolean;
var _local11:int;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Missile;
laserCanvas.graphics.clear();
_local4 = 0;
while (_local4 < towers.length) {
towers[_local4].framesLeftInUpgrade--;
if (towers[_local4].framesLeftInUpgrade > 0){
} else {
towers[_local4].framesUntilFire--;
switch (towers[_local4].type){
case "slow":
_local5 = 0;
while (_local5 < creeps.length) {
_local1 = (towers[_local4].x - creeps[_local5].x);
_local2 = (towers[_local4].y - creeps[_local5].y);
_local3 = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
if (_local3 < towers[_local4].range){
creeps[_local5].speedMultiplier = (creeps[_local5].speedMultiplier * towers[_local4].slowdownCoef);
};
_local5++;
};
_local9 = (((frameCounter - towers[_local4].createdFrameCounter) % 150) / 150);
laserCanvas.graphics.lineStyle(3, 11184895, (0.5 - (0.5 * _local9)));
laserCanvas.graphics.drawCircle(towers[_local4].x, towers[_local4].y, (towers[_local4].range * _local9));
break;
case "bomb":
towers[_local4].bombCounter--;
towers[_local4].spr.transform.colorTransform = new ColorTransform(1, 1, 1, 1, ((towers[_local4].bombCounter % 30) * 3), 0, 0, 0);
if (towers[_local4].bombCounter <= 0){
towers[_local4].dead = true;
makeParticleExplosion(towers[_local4].x, towers[_local4].y, 1, 5, 0);
_local5 = 0;
while (_local5 < creeps.length) {
_local1 = (towers[_local4].x - creeps[_local5].x);
_local2 = (towers[_local4].y - creeps[_local5].y);
_local3 = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
if (_local3 < towers[_local4].range){
damageCreep(_local5, towers[_local4].damage);
};
_local5++;
};
};
break;
case "shock":
_local10 = false;
_local5 = 0;
while (_local5 < creeps.length) {
_local1 = (towers[_local4].x - creeps[_local5].x);
_local2 = (towers[_local4].y - creeps[_local5].y);
_local3 = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
if (_local3 < towers[_local4].range){
if (towers[_local4].framesUntilFire <= 0){
_local10 = true;
damageCreep(_local5, 2);
};
shockCanvas.graphics.lineStyle(1, 11206570, 0.75);
_local15 = towers[_local4].x;
_local16 = towers[_local4].y;
shockCanvas.graphics.moveTo(creeps[_local5].x, creeps[_local5].y);
_local17 = 0;
while (_local17 <= 1) {
_local15 = ((((_local17 * towers[_local4].x) + ((1 - _local17) * creeps[_local5].x)) + (Math.random() * 12)) - 6);
_local16 = ((((_local17 * towers[_local4].y) + ((1 - _local17) * creeps[_local5].y)) + (Math.random() * 12)) - 6);
shockCanvas.graphics.lineTo(_local15, _local16);
_local17 = (_local17 + 0.2);
};
};
_local5++;
};
if (_local10){
towers[_local4].framesUntilFire = towers[_local4].reloadTime;
};
break;
case "money":
_local9 = (((frameCounter - towers[_local4].createdFrameCounter) % 150) / 150);
laserCanvas.graphics.lineStyle(3, 16764074, (0.3 - (0.3 * _local9)));
laserCanvas.graphics.drawCircle(towers[_local4].x, towers[_local4].y, (towers[_local4].range * _local9));
break;
case "artillery":
case "laser":
_local8 = -1;
if (towers[_local4].type == "laser"){
_local9 = (towers[_local4].framesUntilFire / towers[_local4].reloadTime);
towers[_local4].spr.glow.alpha = (0.8 * (1 - Math.min(1, Math.max(0, _local9))));
towers[_local4].spr.glow.rotation = (frameCounter * 3);
};
_local5 = 0;
while (_local5 < creeps.length) {
_local1 = (towers[_local4].x - creeps[_local5].x);
_local2 = (towers[_local4].y - creeps[_local5].y);
_local3 = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
if (_local3 > towers[_local4].range){
} else {
if ((((_local8 == -1)) || ((_local5 < _local8)))){
_local8 = _local5;
if (towers[_local4].type == "artillery"){
_local13 = (_local1 / _local3);
_local14 = (_local2 / _local3);
towers[_local4].spr.rotation = (180 + ((360 * Math.atan2(_local2, _local1)) / (Math.PI * 2)));
};
};
};
_local5++;
};
_local11 = 8;
_local12 = 3;
if (towers[_local4].type == "artillery"){
_local11 = 1;
_local12 = 1;
};
if (((!((_local8 == -1))) && ((towers[_local4].framesUntilFire < _local11)))){
particleCanvas.graphics.lineStyle(_local12, 16755370, 0.5);
particleCanvas.graphics.moveTo(towers[_local4].x, towers[_local4].y);
particleCanvas.graphics.lineTo(creeps[_local8].x, creeps[_local8].y);
if (towers[_local4].framesUntilFire <= 0){
towers[_local4].framesUntilFire = towers[_local4].reloadTime;
damageCreep(_local8, towers[_local4].damage);
};
};
break;
case "missile":
_local8 = -1;
_local5 = 0;
while (_local5 < creeps.length) {
_local1 = (towers[_local4].x - creeps[_local5].x);
_local2 = (towers[_local4].y - creeps[_local5].y);
_local3 = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
if (_local3 > towers[_local4].range){
} else {
if ((((_local8 == -1)) || ((_local5 < _local8)))){
_local8 = _local5;
_local13 = (_local1 / _local3);
_local14 = (_local2 / _local3);
towers[_local4].spr.turret.rotation = (180 + ((360 * Math.atan2(_local2, _local1)) / (Math.PI * 2)));
};
};
_local5++;
};
if (((!((_local8 == -1))) && ((towers[_local4].framesUntilFire <= 0)))){
_local18 = new Missile();
_local18.x = towers[_local4].x;
_local18.y = towers[_local4].y;
_local18.vx = (-(_local13) * 15);
_local18.vy = (-(_local14) * 15);
_local18.splashRadius = towers[_local4].splashRadius;
_local18.damage = towers[_local4].damage;
missiles.push(_local18);
addChild(_local18);
towers[_local4].framesUntilFire = towers[_local4].reloadTime;
};
break;
case "launcher":
_local8 = -1;
_local5 = 0;
while (_local5 < creeps.length) {
_local1 = (towers[_local4].x - creeps[_local5].x);
_local2 = (towers[_local4].y - creeps[_local5].y);
_local3 = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
if (_local3 > towers[_local4].range){
} else {
if ((((_local8 == -1)) || ((_local5 < _local8)))){
_local8 = _local5;
};
};
_local5++;
};
if (((!((_local8 == -1))) && ((towers[_local4].framesUntilFire <= 0)))){
makeBladeParticle(_local4, _local8);
towers[_local4].framesUntilFire = towers[_local4].reloadTime;
};
break;
};
};
_local4++;
};
}
function killDraggingTower():void{
if (draggingTower){
towerContainer.removeChild(draggingTowerPreview);
draggingTower = false;
};
}
public function updateTextParticle(_arg1:int):void{
if (particles[_arg1].age > TEXT_PARTICLE_PARTICLE_MAX_AGE){
particles[_arg1].dead = true;
return;
};
particles[_arg1].vy = (particles[_arg1].vy - 0.5);
particles[_arg1].spr.y = (particles[_arg1].spr.y + particles[_arg1].vy);
particles[_arg1].spr.alpha = (1 - (particles[_arg1].age / TEXT_PARTICLE_PARTICLE_MAX_AGE));
}
public function spawnCreep():void{
var _local1:Creep;
if (creepsToSpawnThisWave <= 0){
currCreepWave++;
if (currCreepWave >= creepWaveData.length){
gameOver(score);
return;
};
creepsToSpawnThisWave = creepWaveData[currCreepWave].numCreepsInWave;
framesUntilSpawnCreep = (framesUntilSpawnCreep + 100);
return;
};
framesUntilSpawnCreep--;
if (framesUntilSpawnCreep > 0){
return;
};
framesUntilSpawnCreep = creepWaveData[currCreepWave].spawnFrameDelay;
creepsToSpawnThisWave--;
_local1 = new Creep();
_local1.spr = new creepWaveData[currCreepWave].spriteClass();
if (creepWaveData[currCreepWave].tint){
_local1.spr.transform.colorTransform = new ColorTransform(1, 1, 1, 1, creepWaveData[currCreepWave].tint.r, creepWaveData[currCreepWave].tint.g, creepWaveData[currCreepWave].tint.b, 0);
};
_local1.addChild(_local1.spr);
creepContainer.addChild(_local1);
creeps.push(_local1);
_local1.x = creepPath[0].x;
_local1.y = creepPath[0].y;
_local1.life = creepWaveData[currCreepWave].life;
_local1.fullLife = _local1.life;
_local1.speed = creepWaveData[currCreepWave].speed;
_local1.moneyValue = creepWaveData[currCreepWave].moneyValue;
_local1.mouseEnabled = true;
_local1.mouseChildren = false;
_local1.addEventListener(MouseEvent.MOUSE_OVER, creepMouseOver, false, 0, true);
_local1.addEventListener(MouseEvent.MOUSE_OUT, creepMouseOut, false, 0, true);
}
public function submitScoreBtnHandler(_arg1:MouseEvent):void{
submitScore(gameOverScreen.highScoreNameTxt.text, finalScore);
}
function towerClickHandler(_arg1:MouseEvent):void{
var _local2:Number;
if (draggingTower){
return;
};
if (towerDialogIsOpen){
towerDialogClose();
};
towerDialogIsOpen = true;
dialogTargetTower = (_arg1.target as Tower);
towerDialog = new TowerDialog();
addChild(towerDialog);
towerDialog.sellBtn.label.text = ("Sell for " + int((dialogTargetTower.sellValue * sellValueFrac)));
towerDialog.sellBtn.buttonMode = true;
towerDialog.sellBtn.useHandCursor = true;
towerDialog.sellBtn.mouseChildren = false;
towerDialog.sellBtn.highlight.visible = false;
towerDialog.closeBtn.addEventListener(MouseEvent.CLICK, towerDialogClose, false, 0, true);
towerDialog.sellBtn.addEventListener(MouseEvent.CLICK, sellTower, false, 0, true);
towerDialog.sellBtn.addEventListener(MouseEvent.MOUSE_OVER, sellBtnOver, false, 0, true);
towerDialog.sellBtn.addEventListener(MouseEvent.MOUSE_OUT, sellBtnOut, false, 0, true);
towerDialogRangeUpgrader = new StatUpgrader();
towerDialog.addChild(towerDialogRangeUpgrader);
towerDialogRangeUpgrader.x = 1;
towerDialogRangeUpgrader.y = 5;
towerDialogRangeUpgrader.minTxt.text = ("" + dialogTargetTower.minRange);
towerDialogRangeUpgrader.maxTxt.text = ("" + dialogTargetTower.maxRange);
towerDialogRangeUpgrader.bar.scaleX = ((dialogTargetTower.range - dialogTargetTower.minRange) / (dialogTargetTower.maxRange - dialogTargetTower.minRange));
towerDialogRangeUpgrader.upgradeBtn.highlight.visible = false;
towerDialogRangeUpgrader.upgradeBtn.mouseChildren = false;
if (dialogTargetTower.numRangeUpgrades < 4){
towerDialogRangeUpgrader.upgradeBtn.buttonMode = true;
towerDialogRangeUpgrader.upgradeBtn.useHandCursor = true;
towerDialogRangeUpgrader.upgradeBtn.label.text = ("Upgrade for " + dialogTargetTower.rangeUpgradeCost);
towerDialogRangeUpgrader.upgradeBtn.addEventListener(MouseEvent.MOUSE_OVER, upgradeBtnOver, false, 0, true);
towerDialogRangeUpgrader.upgradeBtn.addEventListener(MouseEvent.MOUSE_OUT, upgradeBtnOut, false, 0, true);
towerDialogRangeUpgrader.upgradeBtn.addEventListener(MouseEvent.CLICK, upgradeRange, false, 0, true);
} else {
towerDialogRangeUpgrader.upgradeBtn.label.text = "MAX";
};
_local2 = ((towerDialogRangeUpgrader.y + towerDialogRangeUpgrader.height) + 8);
if (dialogTargetTower.maxDamage){
towerDialogDamageUpgrader = new StatUpgrader();
towerDialogDamageUpgrader.labelTxt.text = "Damage";
towerDialog.addChild(towerDialogDamageUpgrader);
towerDialogDamageUpgrader.x = 1;
towerDialogDamageUpgrader.y = ((towerDialogRangeUpgrader.y + towerDialogRangeUpgrader.height) + 4);
towerDialogDamageUpgrader.minTxt.text = ("" + dialogTargetTower.minDamage);
towerDialogDamageUpgrader.maxTxt.text = ("" + dialogTargetTower.maxDamage);
towerDialogDamageUpgrader.bar.scaleX = ((dialogTargetTower.damage - dialogTargetTower.minDamage) / (dialogTargetTower.maxDamage - dialogTargetTower.minDamage));
towerDialogDamageUpgrader.upgradeBtn.highlight.visible = false;
towerDialogDamageUpgrader.upgradeBtn.mouseChildren = false;
if (dialogTargetTower.numDamageUpgrades < 4){
towerDialogDamageUpgrader.upgradeBtn.buttonMode = true;
towerDialogDamageUpgrader.upgradeBtn.useHandCursor = true;
towerDialogDamageUpgrader.upgradeBtn.label.text = ("Upgrade for " + dialogTargetTower.damageUpgradeCost);
towerDialogDamageUpgrader.upgradeBtn.addEventListener(MouseEvent.MOUSE_OVER, upgradeBtnOver, false, 0, true);
towerDialogDamageUpgrader.upgradeBtn.addEventListener(MouseEvent.MOUSE_OUT, upgradeBtnOut, false, 0, true);
towerDialogDamageUpgrader.upgradeBtn.addEventListener(MouseEvent.CLICK, upgradeDamage, false, 0, true);
} else {
towerDialogDamageUpgrader.upgradeBtn.label.text = "MAX";
};
_local2 = ((towerDialogDamageUpgrader.y + towerDialogDamageUpgrader.height) + 8);
};
if (dialogTargetTower.minReloadTime){
towerDialogReloadUpgrader = new StatUpgrader();
towerDialogReloadUpgrader.labelTxt.text = "Reload";
towerDialog.addChild(towerDialogReloadUpgrader);
towerDialogReloadUpgrader.x = 1;
towerDialogReloadUpgrader.y = ((towerDialogDamageUpgrader.y + towerDialogDamageUpgrader.height) + 4);
towerDialogReloadUpgrader.minTxt.text = ("" + dialogTargetTower.minReloadTime);
towerDialogReloadUpgrader.maxTxt.text = ("" + dialogTargetTower.maxReloadTime);
towerDialogReloadUpgrader.bar.scaleX = ((dialogTargetTower.reloadTime - dialogTargetTower.minReloadTime) / (dialogTargetTower.maxReloadTime - dialogTargetTower.minReloadTime));
towerDialogReloadUpgrader.upgradeBtn.highlight.visible = false;
towerDialogReloadUpgrader.upgradeBtn.mouseChildren = false;
if (dialogTargetTower.numReloadUpgrades < 4){
towerDialogReloadUpgrader.upgradeBtn.buttonMode = true;
towerDialogReloadUpgrader.upgradeBtn.useHandCursor = true;
towerDialogReloadUpgrader.upgradeBtn.label.text = ("Upgrade for " + dialogTargetTower.reloadUpgradeCost);
towerDialogReloadUpgrader.upgradeBtn.addEventListener(MouseEvent.MOUSE_OVER, upgradeBtnOver, false, 0, true);
towerDialogReloadUpgrader.upgradeBtn.addEventListener(MouseEvent.MOUSE_OUT, upgradeBtnOut, false, 0, true);
towerDialogReloadUpgrader.upgradeBtn.addEventListener(MouseEvent.CLICK, upgradeReload, false, 0, true);
} else {
towerDialogReloadUpgrader.upgradeBtn.label.text = "MAX";
};
_local2 = ((towerDialogReloadUpgrader.y + towerDialogReloadUpgrader.height) + 8);
};
towerDialog.sellBtn.y = _local2;
towerDialog.closeBtn.y = _local2;
towerDialog.bg.height = ((_local2 + towerDialog.closeBtn.height) + 6);
towerDialog.x = (stage.mouseX + 10);
towerDialog.y = (stage.mouseY + 10);
if ((towerDialog.x + towerDialog.width) > 630){
towerDialog.x = ((stage.mouseX - 10) - towerDialog.width);
};
if ((towerDialog.y + towerDialog.height) > 410){
towerDialog.y = ((stage.mouseY - 10) - towerDialog.height);
};
}
public function launcherBtnClick(_arg1):void{
setupTowerFromType("launcher");
}
public function getHighScores(_arg1:MouseEvent):void{
gameMenu.visible = false;
gameOverScreen.visible = false;
highScoresScreen.visible = true;
highScoresScreen.statusTxt.text = "Getting Scores...";
highScoresScreen.namesTxt.text = "";
highScoresScreen.scoresTxt.text = "";
highScoreService.getScores(gotScoresHandler, scoresErrorHandler);
}
public function updateGame(_arg1):void{
var _local2:int;
if (!gameOn){
return;
};
rangeCanvas.graphics.clear();
setStatusTextFields();
if (draggingTower){
draggingTowerPreview.x = stage.mouseX;
draggingTowerPreview.y = stage.mouseY;
if ((((((draggingTowerTypeCostToBuy > money)) || (((!((draggingTowerType == "bomb"))) && (draggingTowerIsOverPath()))))) || (draggingTowerIsOverTower()))){
draggingTowerPreview.transform.colorTransform = new ColorTransform(1, 0.5, 0.5, 1, 64, 0, 0, 0);
} else {
draggingTowerPreview.transform.colorTransform = new ColorTransform();
};
};
if (draggingTower){
drawDraggingTowerRange();
};
drawMouseOverTowerRange();
if (((towerDialogIsOpen) && (dialogTargetTower.dead))){
towerDialogClose();
};
removeDeadTowers();
lifebarCanvas.graphics.clear();
drawCreepLifeBars();
drawTowerUpgradeProgressBars();
if (paused){
return;
};
frameCounter++;
spawnCreep();
_local2 = 0;
while (_local2 < creeps.length) {
creeps[_local2].speedMultiplier = 1;
_local2++;
};
particleCanvas.graphics.clear();
shockCanvas.graphics.clear();
shootGuns();
updateMissiles();
updateCreeps();
updateParticles();
}
public function bombBtnOver(_arg1):void{
showInfoForTowerType("bomb");
}
function towerMouseOutHandler(_arg1:MouseEvent):void{
_arg1.target.mouseIsOver = false;
setDefaultInfoTxt();
}
public function lightArtilleryBtnOver(_arg1):void{
showInfoForTowerType("artillery");
}
public function setStatusTextFields():void{
lifeTxt.text = ("Life: " + life);
scoreTxt.text = ("Score: " + int(score));
moneyTxt.text = ("Money: " + money);
if (currCreepWave == (creepWaveData.length - 1)){
waveTxt.text = "SHOWDOWN!!";
} else {
waveTxt.text = ("Wave: " + (currCreepWave + 1));
};
}
public function setDefaultInfoTxt():void{
if (draggingTower){
infoTxt.text = "Click to build this tower. If it is red you can't build it. Press space to cancel this tower.";
} else {
infoTxt.text = "Click a tower in the menu to select it, then click again where you want to build it.";
};
}
function keyDownHandler(_arg1:KeyboardEvent):void{
}
public function drawTowerUpgradeProgressBars():void{
var _local1:int;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:int;
var _local7:Number;
_local1 = 0;
while (_local1 < towers.length) {
if (towers[_local1].framesLeftInUpgrade <= 0){
} else {
_local2 = (towers[_local1].framesLeftInUpgrade / towers[_local1].totalFramesToUpgrade);
_local3 = (-(Math.PI) / 2);
lifebarCanvas.graphics.lineStyle(0, 0, 0);
lifebarCanvas.graphics.beginFill(0xFF0000, 0.2);
_local4 = (1 / 30);
_local5 = ((_local4 * Math.PI) * 2);
_local6 = 0;
_local7 = _local4;
while (_local7 <= 1) {
if (_local7 > _local2){
lifebarCanvas.graphics.beginFill(0xFF00, 0.2);
};
lifebarCanvas.graphics.moveTo(towers[_local1].x, towers[_local1].y);
lifebarCanvas.graphics.lineTo((towers[_local1].x + (15 * upgradeCosTable[_local6])), (towers[_local1].y + (15 * upgradeSinTable[_local6])));
lifebarCanvas.graphics.lineTo((towers[_local1].x + (15 * upgradeCosTable[(_local6 + 1)])), (towers[_local1].y + (15 * upgradeSinTable[(_local6 + 1)])));
_local6++;
_local7 = (_local7 + _local4);
};
};
_local1++;
};
}
public function updateBladeParticle(_arg1:int):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:int;
particles[_arg1].spr.x = (particles[_arg1].spr.x + particles[_arg1].vx);
particles[_arg1].spr.y = (particles[_arg1].spr.y + particles[_arg1].vy);
particles[_arg1].spr.rotation = (particles[_arg1].spr.rotation + 15);
if (particles[_arg1].age < BLADE_PARTICLE_INIT_ANIM_DURATION){
particles[_arg1].spr.scaleX = (0.2 + ((0.8 * particles[_arg1].age) / BLADE_PARTICLE_INIT_ANIM_DURATION));
particles[_arg1].spr.scaleY = (0.5 + ((0.5 * particles[_arg1].age) / BLADE_PARTICLE_INIT_ANIM_DURATION));
} else {
particles[_arg1].spr.scaleX = 1;
particles[_arg1].spr.scaleY = 1;
};
if (creeps.length == 0){
particles[_arg1].dead = true;
makeParticleExplosion(particles[_arg1].spr.x, particles[_arg1].spr.y, 1, 0.5);
} else {
if (particles[_arg1].targetCreepIndex >= creeps.length){
particles[_arg1].targetCreepIndex = (creeps.length - 1);
};
_local2 = (creeps[particles[_arg1].targetCreepIndex].x - particles[_arg1].spr.x);
_local3 = (creeps[particles[_arg1].targetCreepIndex].y - particles[_arg1].spr.y);
_local4 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
_local2 = (_local2 / _local4);
_local3 = (_local3 / _local4);
particles[_arg1].vx = (particles[_arg1].vx + _local2);
particles[_arg1].vy = (particles[_arg1].vy + _local3);
particles[_arg1].vx = (particles[_arg1].vx * 0.95);
particles[_arg1].vy = (particles[_arg1].vy * 0.95);
_local5 = 0;
while (_local5 < creeps.length) {
_local2 = (creeps[_local5].x - particles[_arg1].spr.x);
_local3 = (creeps[_local5].y - particles[_arg1].spr.y);
_local4 = ((_local2 * _local2) + (_local3 * _local3));
if (_local4 < (BLADE_PARTICLE_EXPLDOE_DIST * BLADE_PARTICLE_EXPLDOE_DIST)){
particles[_arg1].dead = true;
damageCreep(_local5, particles[_arg1].damage);
};
_local5++;
};
};
}
public function precalcUpgradeSinCosTables():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:*;
_local1 = (1 / 30);
_local2 = ((_local1 * Math.PI) * 2);
_local3 = _local1;
while (_local3 <= (1 + (2 * _local1))) {
_local4 = (((-(Math.PI) / 2) - ((_local3 * Math.PI) * 2)) + _local2);
upgradeSinTable.push(Math.sin(_local4));
upgradeCosTable.push(Math.cos(_local4));
_local3 = (_local3 + _local1);
};
}
function upgradeRange(_arg1):void{
var _local2:Number;
if (dialogTargetTower.framesLeftInUpgrade > 0){
infoTxt.text = "An upgrade is currently in progress. Wait until it finishes to upgrade again.";
return;
};
if (money < dialogTargetTower.rangeUpgradeCost){
infoTxt.text = ("You don't have enough money to upgrade. Required: " + dialogTargetTower.rangeUpgradeCost);
return;
};
_local2 = ((dialogTargetTower.maxRange - dialogTargetTower.minRange) / 4);
dialogTargetTower.range = (dialogTargetTower.range + _local2);
dialogTargetTower.numRangeUpgrades++;
if (dialogTargetTower.numRangeUpgrades == 4){
towerDialogRangeUpgrader.upgradeBtn.highlight.visible = false;
towerDialogRangeUpgrader.upgradeBtn.label.text = "MAX";
towerDialogRangeUpgrader.upgradeBtn.buttonMode = false;
towerDialogRangeUpgrader.upgradeBtn.useHandCursor = false;
towerDialogRangeUpgrader.upgradeBtn.removeEventListener(MouseEvent.MOUSE_OVER, upgradeBtnOver);
towerDialogRangeUpgrader.upgradeBtn.removeEventListener(MouseEvent.MOUSE_OUT, upgradeBtnOut);
towerDialogRangeUpgrader.upgradeBtn.removeEventListener(MouseEvent.CLICK, upgradeRange);
};
money = (money - dialogTargetTower.rangeUpgradeCost);
dialogTargetTower.sellValue = (dialogTargetTower.sellValue + dialogTargetTower.rangeUpgradeCost);
towerDialog.sellBtn.label.text = ("Sell for " + int((dialogTargetTower.sellValue * sellValueFrac)));
setStatusTextFields();
dialogTargetTower.framesLeftInUpgrade = dialogTargetTower.totalFramesToUpgrade;
towerDialogRangeUpgrader.bar.scaleX = ((dialogTargetTower.range - dialogTargetTower.minRange) / (dialogTargetTower.maxRange - dialogTargetTower.minRange));
}
public function creepMouseOut(_arg1:MouseEvent):void{
setDefaultInfoTxt();
}
function upgradeBtnOut(_arg1:MouseEvent):void{
_arg1.target.highlight.visible = false;
}
function keyUpHandler(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.SPACE)) || ((_arg1.keyCode == Keyboard.ESCAPE)))){
killDraggingTower();
};
}
public function removeDeadParticles():void{
var _local1:Array;
var _local2:int;
_local1 = new Array();
_local2 = 0;
while (_local2 < particles.length) {
if (!particles[_local2].dead){
_local1.push(particles[_local2]);
} else {
particleContainer.removeChild(particles[_local2].spr);
};
_local2++;
};
particles = _local1;
}
public function pauseBtnClick(_arg1):void{
paused = !(paused);
if (paused){
menuBar.pauseBtn.label.text = "RESUME";
} else {
menuBar.pauseBtn.label.text = "PAUSE";
};
}
function upgradeDamage(_arg1):void{
var _local2:Number;
if (dialogTargetTower.framesLeftInUpgrade > 0){
infoTxt.text = "An upgrade is currently in progress. Wait until it finishes to upgrade again.";
return;
};
if (money < dialogTargetTower.damageUpgradeCost){
infoTxt.text = ("You don't have enough money to upgrade. Required: " + dialogTargetTower.damageUpgradeCost);
return;
};
_local2 = ((dialogTargetTower.maxDamage - dialogTargetTower.minDamage) / 4);
dialogTargetTower.damage = (dialogTargetTower.damage + _local2);
dialogTargetTower.numDamageUpgrades++;
if (dialogTargetTower.numDamageUpgrades == 4){
towerDialogDamageUpgrader.upgradeBtn.highlight.visible = false;
towerDialogDamageUpgrader.upgradeBtn.label.text = "MAX";
towerDialogDamageUpgrader.upgradeBtn.buttonMode = false;
towerDialogDamageUpgrader.upgradeBtn.useHandCursor = false;
towerDialogDamageUpgrader.upgradeBtn.removeEventListener(MouseEvent.MOUSE_OVER, upgradeBtnOver);
towerDialogDamageUpgrader.upgradeBtn.removeEventListener(MouseEvent.MOUSE_OUT, upgradeBtnOut);
towerDialogDamageUpgrader.upgradeBtn.removeEventListener(MouseEvent.CLICK, upgradeDamage);
};
money = (money - dialogTargetTower.damageUpgradeCost);
dialogTargetTower.sellValue = (dialogTargetTower.sellValue + dialogTargetTower.damageUpgradeCost);
towerDialog.sellBtn.label.text = ("Sell for " + int((dialogTargetTower.sellValue * sellValueFrac)));
setStatusTextFields();
dialogTargetTower.framesLeftInUpgrade = dialogTargetTower.totalFramesToUpgrade;
towerDialogDamageUpgrader.bar.scaleX = ((dialogTargetTower.damage - dialogTargetTower.minDamage) / (dialogTargetTower.maxDamage - dialogTargetTower.minDamage));
}
public function setupTowerFromType(_arg1:String):void{
var towerType = _arg1;
towerDialogClose();
try {
towerContainer.removeChild(draggingTowerPreview);
} catch(e) {
};
draggingTower = true;
draggingTowerType = towerType;
switch (towerType){
case "artillery":
draggingTowerPreview = new LightArtillery();
break;
case "shock":
draggingTowerPreview = new ShockTower();
break;
case "bomb":
draggingTowerPreview = new Bomb();
break;
case "laser":
draggingTowerPreview = new SmallLaserTower();
break;
case "missile":
draggingTowerPreview = new SmallMissileTower();
break;
case "slow":
draggingTowerPreview = new SmallSlowTower();
break;
case "money":
draggingTowerPreview = new MoneyTower();
break;
case "launcher":
draggingTowerPreview = new BladeLauncher();
break;
};
towerContainer.addChild(draggingTowerPreview);
draggingTowerPreview.mouseEnabled = false;
draggingTowerPreview.mouseChildren = false;
towerContainer.mouseEnabled = false;
draggingTowerPreview.alpha = 0.5;
draggingTowerTypeCostToBuy = towerData[towerType].price;
draggingTowerRadius = 20;
if (towerData[towerType].radius){
draggingTowerRadius = towerData[towerType].radius;
};
showInfoForTowerType(towerType);
}
public function pauseBtnOver(_arg1):void{
menuBar.pauseBtn.bg.alpha = 0.8;
}
public function centerOnScreen(_arg1):void{
_arg1.x = ((STAGE_WIDTH / 2) - (_arg1.width / 2));
_arg1.x = ((STAGE_HEIGHT / 2) - (_arg1.height / 2));
}
public function removeDeadCreeps():void{
var _local1:Array;
var _local2:int;
_local1 = new Array();
_local2 = 0;
while (_local2 < creeps.length) {
if (creeps[_local2].dead){
creepContainer.removeChild(creeps[_local2]);
} else {
_local1.push(creeps[_local2]);
};
_local2++;
};
creeps = _local1;
}
public function gotScoresHandler(_arg1:Array):void{
var _local2:*;
highScoresScreen.statusTxt.text = "";
for each (_local2 in _arg1) {
highScoresScreen.namesTxt.appendText((_local2.name + "\n"));
highScoresScreen.scoresTxt.appendText((_local2.score + "\n"));
};
}
function towerDialogClose(_arg1=null):void{
var _local2:int;
if (towerDialogIsOpen){
removeChild(towerDialog);
towerDialogIsOpen = false;
_local2 = 0;
while (_local2 < towers.length) {
towers[_local2].mouseIsOver = false;
_local2++;
};
};
}
public function damageCreep(_arg1:int, _arg2:Number):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:Number;
var _local7:Number;
creeps[_arg1].life = (creeps[_arg1].life - _arg2);
score = (score + _arg2);
if (creeps[_arg1].life <= 0){
_local3 = 0;
_local4 = 0;
while (_local4 < towers.length) {
if (towers[_local4].type != "money"){
} else {
_local6 = (creeps[_arg1].x - towers[_local4].x);
_local7 = (creeps[_arg1].y - towers[_local4].y);
if (((_local6 * _local6) + (_local7 * _local7)) < (towers[_local4].range * towers[_local4].range)){
_local3++;
makeTextParticle("+1", towers[_local4].x, towers[_local4].y);
};
};
_local4++;
};
creeps[_arg1].dead = true;
_local5 = (creeps[_arg1].moneyValue + _local3);
money = (money + _local5);
score = (score + _local5);
makeTextParticle(("+" + creeps[_arg1].moneyValue), creeps[_arg1].x, creeps[_arg1].y);
makeParticleExplosion(creeps[_arg1].x, creeps[_arg1].y, 1, 1);
};
makeParticleExplosion(creeps[_arg1].x, creeps[_arg1].y, 1, 0.5);
setStatusTextFields();
}
function upgradeReload(_arg1):void{
var _local2:Number;
if (dialogTargetTower.framesLeftInUpgrade > 0){
infoTxt.text = "An upgrade is currently in progress. Wait until it finishes to upgrade again.";
return;
};
if (money < dialogTargetTower.reloadUpgradeCost){
infoTxt.text = ("You don't have enough money to upgrade. Required: " + dialogTargetTower.reloadUpgradeCost);
return;
};
_local2 = ((dialogTargetTower.maxReloadTime - dialogTargetTower.minReloadTime) / 4);
dialogTargetTower.reloadTime = (dialogTargetTower.reloadTime - _local2);
dialogTargetTower.numReloadUpgrades++;
if (dialogTargetTower.numReloadUpgrades == 4){
towerDialogReloadUpgrader.upgradeBtn.highlight.visible = false;
towerDialogReloadUpgrader.upgradeBtn.label.text = "MAX";
towerDialogReloadUpgrader.upgradeBtn.buttonMode = false;
towerDialogReloadUpgrader.upgradeBtn.useHandCursor = false;
towerDialogReloadUpgrader.upgradeBtn.removeEventListener(MouseEvent.MOUSE_OVER, upgradeBtnOver);
towerDialogReloadUpgrader.upgradeBtn.removeEventListener(MouseEvent.MOUSE_OUT, upgradeBtnOut);
towerDialogReloadUpgrader.upgradeBtn.removeEventListener(MouseEvent.CLICK, upgradeReload);
};
money = (money - dialogTargetTower.reloadUpgradeCost);
dialogTargetTower.sellValue = (dialogTargetTower.sellValue + dialogTargetTower.reloadUpgradeCost);
towerDialog.sellBtn.label.text = ("Sell for " + int((dialogTargetTower.sellValue * sellValueFrac)));
setStatusTextFields();
dialogTargetTower.framesLeftInUpgrade = dialogTargetTower.totalFramesToUpgrade;
towerDialogReloadUpgrader.bar.scaleX = ((dialogTargetTower.reloadTime - dialogTargetTower.minReloadTime) / (dialogTargetTower.maxReloadTime - dialogTargetTower.minReloadTime));
}
public function smallMissileTowerBtnClick(_arg1):void{
setupTowerFromType("missile");
}
function sellTower(_arg1):void{
var _local2:int;
_local2 = (dialogTargetTower.sellValue * sellValueFrac);
dialogTargetTower.dead = true;
money = (money + _local2);
setStatusTextFields();
towerDialogClose();
if (!paused){
makeTextParticle(("+" + _local2), dialogTargetTower.x, dialogTargetTower.y);
};
}
public function moreGamesBtnHandler(_arg1:MouseEvent):void{
var e = _arg1;
try {
navigateToURL(new URLRequest("http://www.flashgamealot.com"));
} catch(e) {
};
}
public function countMoneyTowers():int{
var _local1:int;
var _local2:int;
_local2 = 0;
while (_local2 < towers.length) {
if (towers[_local2].type == "money"){
_local1++;
};
_local2++;
};
return (_local1);
}
public function cleanUpGame():void{
var i:int;
towerDialogClose();
killDraggingTower();
laserCanvas.graphics.clear();
particleCanvas.graphics.clear();
shockCanvas.graphics.clear();
rangeCanvas.graphics.clear();
lifebarCanvas.graphics.clear();
laserCanvas.visible = false;
particleCanvas.visible = false;
shockCanvas.visible = false;
rangeCanvas.visible = false;
particleContainer.visible = false;
lifebarCanvas.visible = false;
i = 0;
while (i < creeps.length) {
try {
creepContainer.removeChild(creeps[i]);
} catch(e) {
};
i = (i + 1);
};
i = 0;
while (i < towers.length) {
try {
towerContainer.removeChild(towers[i]);
} catch(e) {
};
i = (i + 1);
};
i = 0;
while (i < missiles.length) {
try {
removeChild(missiles[i]);
} catch(e) {
};
i = (i + 1);
};
i = 0;
while (i < particles.length) {
particles[i].dead = true;
i = (i + 1);
};
removeDeadParticles();
creeps = new Array();
towers = new Array();
missiles = new Array();
}
public function makeParticleExplosion(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Number=1, _arg5:Number=1):void{
var _local6:int;
var _local7:Number;
var _local8:Number;
var _local9:Object;
var _local10:Explosion;
_local6 = 0;
while (_local6 < _arg3) {
_local7 = ((Math.random() * Math.PI) * 2);
_local8 = ((Math.random() + 1) * 10);
_local9 = {type:EXPLOSION_PARTICLE, age:0, x:(_arg1 + ((Math.sin(_local7) * _local8) * _arg5)), y:(_arg2 + ((Math.cos(_local7) * _local8) * _arg5))};
_local10 = new Explosion();
particleContainer.addChild(_local10);
_local9.spr = _local10;
_local10.x = _local9.x;
_local10.y = _local9.y;
_local10.scaleX = _arg4;
_local10.scaleY = _arg4;
_local10.rotation = (Math.random() * 360);
particles.push(_local9);
_local6++;
};
}
public function moneyTowerBtnOver(_arg1):void{
showInfoForTowerType("money");
}
public function pauseBtnOut(_arg1):void{
menuBar.pauseBtn.bg.alpha = 1;
}
public function scoresErrorHandler(_arg1:String):void{
highScoresScreen.statusTxt.text = "High scores are not available right now.";
}
public function updateExplosionParticle(_arg1:int):void{
if (particles[_arg1].age > EXPLOSION_PARTICLE_PARTICLE_MAX_AGE){
particles[_arg1].dead = true;
return;
};
particles[_arg1].spr.alpha = (1 - (Number(particles[_arg1].age) / Number(EXPLOSION_PARTICLE_PARTICLE_MAX_AGE)));
}
function draggingTowerIsOverPath():Boolean{
var _local1:*;
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local1 = 0;
while (_local1 < creepPath.length) {
_local2 = (creepPath[_local1].x - stage.mouseX);
_local3 = (creepPath[_local1].y - stage.mouseY);
_local4 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
if (_local4 < (draggingTowerRadius + 14)){
return (true);
};
_local1++;
};
return (false);
}
public function drawDraggingTowerRange():void{
rangeCanvas.graphics.lineStyle(2, 0xFFFFFF, 0.35);
rangeCanvas.graphics.drawCircle(stage.mouseX, stage.mouseY, towerData[draggingTowerType].range);
}
public function drawCreepLifeBars():void{
var _local1:int;
var _local2:Number;
_local1 = 0;
while (_local1 < creeps.length) {
_local2 = (creeps[_local1].life / creeps[_local1].fullLife);
lifebarCanvas.graphics.lineStyle(3, 0xFF00, 0.5);
lifebarCanvas.graphics.moveTo((creeps[_local1].x + 10), (creeps[_local1].y - 10));
lifebarCanvas.graphics.lineTo(((creeps[_local1].x + (_local2 * 20)) + 10), (creeps[_local1].y - 10));
lifebarCanvas.graphics.lineStyle(3, 0x990000, 0.3);
lifebarCanvas.graphics.lineTo(((creeps[_local1].x + 20) + 10), (creeps[_local1].y - 10));
_local1++;
};
}
public function initGame():void{
try {
removeChild(adContainer);
} catch(e) {
};
precalcUpgradeSinCosTables();
stage.scaleMode = StageScaleMode.SHOW_ALL;
highScoreService = new LaserPirateHighScoreService(HIGH_SCORE_GAME_CODE);
gameMenu = new GameMenu();
addChild(gameMenu);
centerOnScreen(gameMenu);
gameOverScreen = new GameOverScreen();
addChild(gameOverScreen);
centerOnScreen(gameOverScreen);
gameOverScreen.visible = false;
highScoresScreen = new HighScoresScreen();
addChild(highScoresScreen);
centerOnScreen(highScoresScreen);
highScoresScreen.visible = false;
gameMenu.playNowBtn.addEventListener(MouseEvent.CLICK, playNowBtnHandler);
gameMenu.moreGamesBtn.addEventListener(MouseEvent.CLICK, moreGamesBtnHandler);
gameMenu.highScoresBtn.addEventListener(MouseEvent.CLICK, getHighScores);
gameOverScreen.continueBtn.addEventListener(MouseEvent.CLICK, continueBtnHandler);
highScoresScreen.backBtn.addEventListener(MouseEvent.CLICK, continueBtnHandler);
gameOverScreen.submitScoreBtn.addEventListener(MouseEvent.CLICK, submitScoreBtnHandler);
addEventListener(Event.ENTER_FRAME, updateGame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
gameBg = new GameBg();
addChild(gameBg);
gameBg.visible = false;
creepContainer = new Sprite();
towerContainer = new Sprite();
particleContainer = new Sprite();
creepContainer.mouseEnabled = false;
towerContainer.mouseEnabled = false;
particleContainer.mouseEnabled = false;
addChild(creepContainer);
addChild(towerContainer);
addChild(particleContainer);
rangeCanvas = new Sprite();
addChild(rangeCanvas);
rangeCanvas.mouseEnabled = false;
laserCanvas = new Sprite();
addChild(laserCanvas);
laserCanvas.mouseEnabled = false;
particleCanvas = new Sprite();
addChild(particleCanvas);
particleCanvas.mouseEnabled = false;
particleCanvas.filters = [new GlowFilter(16755319, 0.8, 8, 8, 4, BitmapFilterQuality.HIGH, false, false)];
shockCanvas = new Sprite();
addChild(shockCanvas);
shockCanvas.mouseEnabled = false;
shockCanvas.filters = [new GlowFilter(11184895, 0.5, 4, 4, 3, BitmapFilterQuality.HIGH, false, false)];
lifebarCanvas = new Sprite();
addChild(lifebarCanvas);
lifebarCanvas.mouseEnabled = false;
textContainer = new Sprite();
addChild(textContainer);
textContainer.mouseEnabled = false;
textContainer.mouseChildren = false;
fmt.font = "Arial";
fmt.color = 0xFFFFFF;
scoreTxt = new TextField();
lifeTxt = new TextField();
moneyTxt = new TextField();
waveTxt = new TextField();
infoTxt = new TextField();
scoreTxt.defaultTextFormat = fmt;
lifeTxt.defaultTextFormat = fmt;
moneyTxt.defaultTextFormat = fmt;
waveTxt.defaultTextFormat = fmt;
infoTxt.defaultTextFormat = fmt;
scoreTxt.selectable = false;
lifeTxt.selectable = false;
moneyTxt.selectable = false;
waveTxt.selectable = false;
infoTxt.selectable = false;
scoreTxt.embedFonts = true;
lifeTxt.embedFonts = true;
moneyTxt.embedFonts = true;
waveTxt.embedFonts = true;
infoTxt.embedFonts = true;
lifeTxt.height = 20;
scoreTxt.height = 20;
waveTxt.height = 20;
moneyTxt.height = 20;
infoTxt.height = 50;
lifeTxt.width = 100;
waveTxt.width = 100;
scoreTxt.width = 100;
moneyTxt.width = 100;
infoTxt.width = 544;
scoreTxt.y = 8;
lifeTxt.y = (scoreTxt.height + scoreTxt.y);
moneyTxt.y = (lifeTxt.height + lifeTxt.y);
waveTxt.y = (moneyTxt.height + moneyTxt.y);
infoTxt.y = 422;
infoTxt.x = 84;
lifeTxt.x = 80;
scoreTxt.x = 80;
moneyTxt.x = 80;
waveTxt.x = 80;
scoreTxt.visible = false;
lifeTxt.visible = false;
moneyTxt.visible = false;
waveTxt.visible = false;
infoTxt.visible = false;
infoTxt.multiline = true;
infoTxt.wordWrap = true;
textContainer.addChild(scoreTxt);
textContainer.addChild(lifeTxt);
textContainer.addChild(moneyTxt);
textContainer.addChild(waveTxt);
menuBar = new MenuBar();
menuBar.visible = false;
addChild(menuBar);
textContainer2 = new Sprite();
addChild(textContainer2);
textContainer2.mouseEnabled = false;
textContainer2.mouseChildren = false;
textContainer2.addChild(infoTxt);
menuBar.smallLaserTowerBtn.buttonMode = true;
menuBar.smallSlowTowerBtn.buttonMode = true;
menuBar.smallMissileTowerBtn.buttonMode = true;
menuBar.moneyTowerBtn.buttonMode = true;
menuBar.shockTowerBtn.buttonMode = true;
menuBar.bombBtn.buttonMode = true;
menuBar.lightArtilleryBtn.buttonMode = true;
menuBar.launcherBtn.buttonMode = true;
menuBar.pauseBtn.buttonMode = true;
menuBar.smallLaserTowerBtn.useHandCursor = true;
menuBar.smallSlowTowerBtn.useHandCursor = true;
menuBar.smallMissileTowerBtn.useHandCursor = true;
menuBar.moneyTowerBtn.useHandCursor = true;
menuBar.shockTowerBtn.useHandCursor = true;
menuBar.bombBtn.useHandCursor = true;
menuBar.lightArtilleryBtn.useHandCursor = true;
menuBar.launcherBtn.useHandCursor = true;
menuBar.pauseBtn.useHandCursor = true;
menuBar.pauseBtn.mouseChildren = false;
menuBar.smallLaserTowerBtn.addEventListener(MouseEvent.CLICK, smallLaserTowerBtnClick);
menuBar.smallSlowTowerBtn.addEventListener(MouseEvent.CLICK, smallSlowTowerBtnClick);
menuBar.smallMissileTowerBtn.addEventListener(MouseEvent.CLICK, smallMissileTowerBtnClick);
menuBar.moneyTowerBtn.addEventListener(MouseEvent.CLICK, moneyTowerBtnClick);
menuBar.shockTowerBtn.addEventListener(MouseEvent.CLICK, shockTowerBtnClick);
menuBar.bombBtn.addEventListener(MouseEvent.CLICK, bombBtnClick);
menuBar.lightArtilleryBtn.addEventListener(MouseEvent.CLICK, lightArtilleryBtnClick);
menuBar.launcherBtn.addEventListener(MouseEvent.CLICK, launcherBtnClick);
menuBar.smallLaserTowerBtn.addEventListener(MouseEvent.MOUSE_OVER, smallLaserTowerBtnOver);
menuBar.smallSlowTowerBtn.addEventListener(MouseEvent.MOUSE_OVER, smallSlowTowerBtnOver);
menuBar.smallMissileTowerBtn.addEventListener(MouseEvent.MOUSE_OVER, smallMissileTowerBtnOver);
menuBar.moneyTowerBtn.addEventListener(MouseEvent.MOUSE_OVER, moneyTowerBtnOver);
menuBar.shockTowerBtn.addEventListener(MouseEvent.MOUSE_OVER, shockTowerBtnOver);
menuBar.bombBtn.addEventListener(MouseEvent.MOUSE_OVER, bombBtnOver);
menuBar.lightArtilleryBtn.addEventListener(MouseEvent.MOUSE_OVER, lightArtilleryBtnOver);
menuBar.launcherBtn.addEventListener(MouseEvent.MOUSE_OVER, launcherBtnOver);
menuBar.addEventListener(MouseEvent.MOUSE_OUT, menuRollOutHandler);
menuBar.addEventListener(MouseEvent.CLICK, menuClickHandler);
menuBar.pauseBtn.addEventListener(MouseEvent.MOUSE_OVER, pauseBtnOver);
menuBar.pauseBtn.addEventListener(MouseEvent.MOUSE_OUT, pauseBtnOut);
menuBar.pauseBtn.addEventListener(MouseEvent.CLICK, pauseBtnClick);
menuBar.exitBtn.addEventListener(MouseEvent.CLICK, exitBtnClick);
gameBg.addEventListener(MouseEvent.CLICK, bgClickHandler);
musicBtn = new MusicBtn();
addChild(musicBtn);
musicBtn.x = ((640 - musicBtn.width) - 8);
musicBtn.y = ((480 - musicBtn.height) - 8);
musicBtn.addEventListener(MouseEvent.CLICK, musicBtnHandler, false, 0, true);
bgMusicOn = true;
bgMusic = new BgMusic();
bgMusicChannel = bgMusic.play(0, int.MAX_VALUE);
}
public function smallLaserTowerBtnClick(_arg1):void{
setupTowerFromType("laser");
}
public function creepMouseOver(_arg1:MouseEvent):void{
var _local2:Creep;
_local2 = (_arg1.target as Creep);
infoTxt.text = ((((((("Life: " + _local2.life) + " / ") + _local2.fullLife) + ", Speed: ") + _local2.speed) + ", Money: ") + _local2.moneyValue);
}
function draggingTowerIsOverTower():Boolean{
var _local1:*;
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local1 = 0;
while (_local1 < towers.length) {
_local2 = (towers[_local1].x - stage.mouseX);
_local3 = (towers[_local1].y - stage.mouseY);
_local4 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
if (_local4 < (towers[_local1].radius + draggingTowerRadius)){
return (true);
};
_local1++;
};
return (false);
}
function towerMouseOverHandler(_arg1:MouseEvent):void{
var _local2:Tower;
var _local3:String;
_local2 = (_arg1.target as Tower);
_local2.mouseIsOver = true;
_local3 = "";
_local3 = (_local3 + (towerData[_local2.type].name + " - "));
if (_local2.damage > 0){
_local3 = (_local3 + (("Damage: " + _local2.damage) + " "));
};
if (_local2.range > 0){
_local3 = (_local3 + (("Range: " + _local2.range) + " "));
};
if (_local2.reloadTime > 0){
_local3 = (_local3 + (("Reload Time: " + _local2.reloadTime) + " "));
};
if (_local2.splashRadius > 0){
_local3 = (_local3 + (("Splash: " + _local2.splashRadius) + " "));
};
_local3 = (_local3 + "\nClick on the tower to upgrade or sell it.");
infoTxt.text = _local3;
}
public function removeDeadMissiles():void{
var _local1:Array;
var _local2:int;
_local1 = new Array();
_local2 = 0;
while (_local2 < missiles.length) {
if (missiles[_local2].dead){
removeChild(missiles[_local2]);
} else {
_local1.push(missiles[_local2]);
};
_local2++;
};
missiles = _local1;
}
public function shockTowerBtnClick(_arg1):void{
setupTowerFromType("shock");
}
function sellBtnOut(_arg1):void{
towerDialog.sellBtn.highlight.visible = false;
}
public function bombBtnClick(_arg1):void{
setupTowerFromType("bomb");
}
function musicBtnHandler(_arg1):void{
if (bgMusicOn){
bgMusicChannel.stop();
} else {
bgMusicChannel = bgMusic.play(0, int.MAX_VALUE);
};
bgMusicOn = !(bgMusicOn);
}
public function continueBtnHandler(_arg1:MouseEvent):void{
gameMenu.visible = true;
gameOverScreen.visible = false;
highScoresScreen.visible = false;
}
public function makeBladeParticle(_arg1:int, _arg2:int):void{
var _local3:Object;
var _local4:Blade;
_local3 = {type:BLADE_PARTICLE, age:0, x:towers[_arg1].x, y:towers[_arg1].y, vx:0, vy:10, targetCreepIndex:_arg2, damage:towers[_arg1].damage};
_local4 = new Blade();
particleContainer.addChild(_local4);
_local3.spr = _local4;
_local4.x = _local3.x;
_local4.y = _local3.y;
_local4.rotation = (Math.random() * 360);
particles.push(_local3);
}
public function submitScore(_arg1:String, _arg2:int):void{
gameOverScreen.visible = false;
highScoresScreen.visible = true;
highScoresScreen.statusTxt.text = "Sending Score...";
highScoresScreen.namesTxt.text = "";
highScoresScreen.scoresTxt.text = "";
highScoreService.submitScore(_arg1, _arg2, gotScoresHandler, scoresErrorHandler);
}
public function lightArtilleryBtnClick(_arg1):void{
setupTowerFromType("artillery");
}
public function bgClickHandler(_arg1:MouseEvent):void{
var _local2:Boolean;
var _local3:Tower;
towerDialogClose();
if (!draggingTower){
return;
};
_local2 = draggingTowerIsOverPath();
if (draggingTowerTypeCostToBuy > money){
infoTxt.text = (("You don't have enough money to buy that. Required: " + draggingTowerTypeCostToBuy) + "\nPress the space key to cancel this tower.");
return;
};
if (((!((draggingTowerType == "bomb"))) && (_local2))){
infoTxt.text = ("You cannot build a tower on top of the creep path." + "\nPress the space key to cancel this tower.");
return;
};
if (draggingTowerIsOverTower()){
infoTxt.text = ("You cannot build a tower on top of another tower." + "\nPress the space key to cancel this tower.");
return;
};
money = (money - draggingTowerTypeCostToBuy);
setStatusTextFields();
_local3 = new Tower();
towerContainer.addChild(_local3);
towers.push(_local3);
towerContainer.removeChild(draggingTowerPreview);
draggingTowerPreview.x = 0;
draggingTowerPreview.y = 0;
_local3.sellValue = draggingTowerTypeCostToBuy;
_local3.spr = draggingTowerPreview;
_local3.addChild(_local3.spr);
_local3.type = draggingTowerType;
_local3.rangeUpgradeCost = towerData[_local3.type].rangeUpgradeCost;
_local3.range = towerData[_local3.type].range;
_local3.minRange = towerData[_local3.type].range;
_local3.maxRange = towerData[_local3.type].maxRange;
_local3.damageUpgradeCost = towerData[_local3.type].damageUpgradeCost;
_local3.damage = towerData[_local3.type].damage;
_local3.minDamage = towerData[_local3.type].damage;
_local3.maxDamage = towerData[_local3.type].maxDamage;
_local3.reloadUpgradeCost = towerData[_local3.type].reloadUpgradeCost;
_local3.reloadTime = towerData[_local3.type].reloadTime;
_local3.minReloadTime = towerData[_local3.type].minReloadTime;
_local3.maxReloadTime = towerData[_local3.type].reloadTime;
_local3.slowdownCoef = 0.75;
_local3.splashRadius = -1;
if (towerData[_local3.type].splashRadius){
_local3.splashRadius = towerData[_local3.type].splashRadius;
};
_local3.radius = draggingTowerRadius;
_local3.createdFrameCounter = frameCounter;
_local3.x = stage.mouseX;
_local3.y = stage.mouseY;
_local3.buttonMode = true;
_local3.useHandCursor = true;
_local3.addEventListener(MouseEvent.MOUSE_OVER, towerMouseOverHandler, false, 0, true);
_local3.addEventListener(MouseEvent.MOUSE_OUT, towerMouseOutHandler, false, 0, true);
_local3.addEventListener(MouseEvent.CLICK, towerClickHandler, false, 0, true);
draggingTowerPreview.alpha = 1;
draggingTower = false;
if (_arg1.shiftKey){
setupTowerFromType(draggingTowerType);
};
}
public function launcherBtnOver(_arg1):void{
showInfoForTowerType("launcher");
}
public function menuClickHandler(_arg1):void{
if (_arg1.target == menuBar){
killDraggingTower();
};
}
public function removeDeadTowers():void{
var _local1:Array;
var _local2:int;
_local1 = new Array();
_local2 = 0;
while (_local2 < towers.length) {
if (towers[_local2].dead){
towerContainer.removeChild(towers[_local2]);
} else {
_local1.push(towers[_local2]);
};
_local2++;
};
towers = _local1;
}
public function updateCreeps():void{
var _local1:int;
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local1 = 0;
while (_local1 < creeps.length) {
_local2 = (creepPath[creeps[_local1].targetCheckPoint].x - creeps[_local1].x);
_local3 = (creepPath[creeps[_local1].targetCheckPoint].y - creeps[_local1].y);
_local4 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
_local2 = (_local2 / _local4);
_local3 = (_local3 / _local4);
creeps[_local1].x = (creeps[_local1].x + ((_local2 * creeps[_local1].speed) * creeps[_local1].speedMultiplier));
creeps[_local1].y = (creeps[_local1].y + ((_local3 * creeps[_local1].speed) * creeps[_local1].speedMultiplier));
creeps[_local1].rotation = ((Math.atan2(_local3, _local2) * 180) / Math.PI);
if (_local4 < CREEP_DIST_TO_REACH_CHECKPOINT){
creeps[_local1].targetCheckPoint++;
if (creeps[_local1].targetCheckPoint >= creepPath.length){
creeps[_local1].dead = true;
creepEscaped();
if (life == 0){
return;
};
};
};
_local1++;
};
removeDeadCreeps();
}
function upgradeBtnOver(_arg1:MouseEvent):void{
_arg1.target.highlight.visible = true;
}
public function creepEscaped():void{
life = (life - 1);
setStatusTextFields();
if (life == 0){
gameOver(score);
};
}
public function menuRollOutHandler(_arg1):void{
if (_arg1.target == menuBar){
setDefaultInfoTxt();
};
}
public function shockTowerBtnOver(_arg1):void{
showInfoForTowerType("shock");
}
public function exitBtnClick(_arg1):void{
gameOver(score);
}
public function smallMissileTowerBtnOver(_arg1):void{
showInfoForTowerType("missile");
}
public function drawMouseOverTowerRange():void{
var _local1:int;
var _local2:Boolean;
drawMouseOverTowerRangeCurr = ((drawMouseOverTowerRangeCurr * 0.6) + (drawMouseOverTowerRangeTarget * 0.4));
drawMouseOverTowerAlpha = ((drawMouseOverTowerAlpha * 0.6) + (drawMouseOverTowerAlphaTarget * 0.4));
if (draggingTower){
return;
};
if (towerDialogIsOpen){
_local1 = 0;
while (_local1 < towers.length) {
towers[_local1].mouseIsOver = false;
_local1++;
};
dialogTargetTower.mouseIsOver = true;
};
_local2 = false;
drawMouseOverTowerAlphaTarget = 0;
rangeCanvas.graphics.lineStyle(2, 0xFFFFFF, drawMouseOverTowerAlpha);
_local1 = 0;
while (_local1 < towers.length) {
if (!towers[_local1].mouseIsOver){
} else {
drawMouseOverTowerRangeTarget = towers[_local1].range;
drawMouseOverTowerRangeX = towers[_local1].x;
drawMouseOverTowerRangeY = towers[_local1].y;
drawMouseOverTowerAlphaTarget = 0.25;
_local2 = true;
};
_local1++;
};
rangeCanvas.graphics.drawCircle(drawMouseOverTowerRangeX, drawMouseOverTowerRangeY, drawMouseOverTowerRangeCurr);
if (!_local2){
drawMouseOverTowerRangeTarget = 0;
};
}
public function moneyTowerBtnClick(_arg1):void{
setupTowerFromType("money");
}
public function smallSlowTowerBtnOver(_arg1):void{
showInfoForTowerType("slow");
}
public function showMochiAd():void{
adContainer = new MochiContainer();
addChild(adContainer);
MochiAd.showPreGameAd({clip:adContainer, id:"4f20a9f811f7f164", res:"640x480", ad_finished:initGame});
}
public function makeTextParticle(_arg1:String, _arg2:int, _arg3:int):void{
var _local4:Object;
var _local5:TextField;
_local4 = {type:TEXT_PARTICLE, age:0, vy:-1};
_local4.spr = new Sprite();
particleContainer.addChild(_local4.spr);
_local5 = new TextField();
_local4.spr.addChild(_local5);
_local5.embedFonts = true;
_local5.defaultTextFormat = fmt;
_local5.text = _arg1;
_local5.selectable = false;
_local4.spr.mouseEnabled = false;
_local4.spr.mouseChildren = false;
_local4.spr.x = _arg2;
_local4.spr.y = _arg3;
particles.push(_local4);
}
public function drawCreepPath():void{
var _local1:int;
creepPathCavas.graphics.clear();
creepPathCavas.graphics.lineStyle(0, 0xFFFFFF, 0.3);
creepPathCavas.graphics.moveTo(creepPath[0].x, creepPath[0].y);
_local1 = 0;
while (_local1 < creepPath.length) {
creepPathCavas.graphics.lineTo(creepPath[_local1].x, creepPath[_local1].y);
_local1++;
};
}
public function gameOver(_arg1:int):void{
cleanUpGame();
gameOn = false;
scoreTxt.visible = false;
lifeTxt.visible = false;
infoTxt.visible = false;
menuBar.visible = false;
moneyTxt.visible = false;
waveTxt.visible = false;
gameBg.visible = false;
gameOn = false;
this.finalScore = _arg1;
gameOverScreen.visible = true;
gameOverScreen.finalScoreTxt.text = ("" + _arg1);
musicBtn.x = ((640 - musicBtn.width) - 8);
musicBtn.y = ((480 - musicBtn.height) - 8);
}
public function updateParticles():void{
var _local1:int;
_local1 = 0;
while (_local1 < particles.length) {
particles[_local1].age++;
if (particles[_local1].type == BLADE_PARTICLE){
updateBladeParticle(_local1);
};
if (particles[_local1].type == EXPLOSION_PARTICLE){
updateExplosionParticle(_local1);
};
if (particles[_local1].type == TEXT_PARTICLE){
updateTextParticle(_local1);
};
_local1++;
};
removeDeadParticles();
}
public function smallSlowTowerBtnClick(_arg1):void{
setupTowerFromType("slow");
}
public function playNowBtnHandler(_arg1:MouseEvent):void{
musicBtn.x = 80;
musicBtn.y = 390;
currCreepWave = 0;
creepsToSpawnThisWave = creepWaveData[currCreepWave].numCreepsInWave;
framesUntilSpawnCreep = 50;
creeps = new Array();
gameMenu.visible = false;
gameOn = true;
paused = false;
menuBar.pauseBtn.label.text = "PAUSE";
scoreTxt.visible = true;
lifeTxt.visible = true;
infoTxt.visible = true;
menuBar.visible = true;
moneyTxt.visible = true;
waveTxt.visible = true;
gameBg.visible = true;
laserCanvas.visible = true;
particleCanvas.visible = true;
shockCanvas.visible = true;
rangeCanvas.visible = true;
lifebarCanvas.visible = true;
particleContainer.visible = true;
score = 0;
life = 20;
money = 350;
setStatusTextFields();
infoTxt.text = "Welcome to Omega Tower Defense. Click a tower in the menu bar to select it, then click again to build it. Don't let the creeps get to their destination.";
}
public function updateMissiles():void{
var _local1:int;
var _local2:int;
var _local3:Number;
var _local4:Number;
_local1 = 0;
while (_local1 < missiles.length) {
missiles[_local1].x = (missiles[_local1].x + missiles[_local1].vx);
missiles[_local1].y = (missiles[_local1].y + missiles[_local1].vy);
laserCanvas.graphics.lineStyle(3, 0xFFFFFF, 0.8);
laserCanvas.graphics.moveTo(missiles[_local1].x, missiles[_local1].y);
laserCanvas.graphics.lineTo((missiles[_local1].x + missiles[_local1].vx), (missiles[_local1].y + missiles[_local1].vy));
_local2 = 0;
while (_local2 < creeps.length) {
if ((((((((missiles[_local1].x < -10)) || ((missiles[_local1].y < -10)))) || ((missiles[_local1].x > 650)))) || ((missiles[_local1].y > 490)))){
missiles[_local1].dead = true;
} else {
_local3 = (missiles[_local1].x - creeps[_local2].x);
_local4 = (missiles[_local1].y - creeps[_local2].y);
if (((_local3 * _local3) + (_local4 * _local4)) < (missiles[_local1].splashRadius * missiles[_local1].splashRadius)){
missiles[_local1].dead = true;
damageCreep(_local2, missiles[_local1].damage);
};
};
_local2++;
};
_local1++;
};
removeDeadMissiles();
}
}
}//package
import flash.display.*;
dynamic class MochiContainer extends MovieClip {
private function MochiContainer(){
}
}
Section 38
//ShockTower (ShockTower)
package {
import flash.display.*;
public dynamic class ShockTower extends Sprite {
}
}//package
Section 39
//SmallLaserTower (SmallLaserTower)
package {
import flash.display.*;
public dynamic class SmallLaserTower extends MovieClip {
public var glow:MovieClip;
}
}//package
Section 40
//SmallMissileTower (SmallMissileTower)
package {
import flash.display.*;
public dynamic class SmallMissileTower extends Sprite {
public var turret:MovieClip;
}
}//package
Section 41
//SmallSlowTower (SmallSlowTower)
package {
import flash.display.*;
public dynamic class SmallSlowTower extends Sprite {
}
}//package
Section 42
//StatBar (StatBar)
package {
import flash.display.*;
public dynamic class StatBar extends Sprite {
}
}//package
Section 43
//StatUpgrader (StatUpgrader)
package {
import flash.display.*;
import flash.text.*;
public dynamic class StatUpgrader extends Sprite {
public var bar:StatBar;
public var maxTxt:TextField;
public var upgradeBtn:MovieClip;
public var minTxt:TextField;
public var labelTxt:TextField;
}
}//package
Section 44
//Tower (Tower)
package {
import flash.display.*;
public class Tower extends Sprite {
public var reloadTime:Number;
public var minRange:Number;
public var damageUpgradeCost:int;
public var maxDamage:Number;
public var mouseIsOver:Boolean;// = true
public var totalFramesToUpgrade:int;// = 60
public var sellValue:int;
public var type:String;
public var range:Number;
public var maxRange:Number;
public var numRangeUpgrades:int;// = 0
public var dead:Boolean;// = false
public var damage:Number;// = 0
public var minDamage:Number;
public var maxReloadTime:Number;
public var radius:Number;
public var rangeUpgradeCost:int;
public var reloadUpgradeCost:int;
public var spr:Sprite;
public var framesUntilFire:int;
public var numDamageUpgrades:int;// = 0
public var numReloadUpgrades:int;// = 0
public var slowdownCoef:Number;// = 1
public var residualFrames:int;
public var createdFrameCounter:int;
public var splashRadius:Number;// = 10
public var framesLeftInUpgrade:int;// = 0
public var bombCounter:int;// = 60
public var minReloadTime:Number;
public function Tower(){
damage = 0;
slowdownCoef = 1;
splashRadius = 10;
dead = false;
mouseIsOver = true;
bombCounter = 60;
numRangeUpgrades = 0;
numDamageUpgrades = 0;
numReloadUpgrades = 0;
totalFramesToUpgrade = 60;
framesLeftInUpgrade = 0;
super();
framesUntilFire = 0;
residualFrames = 0;
}
}
}//package
Section 45
//TowerDialog (TowerDialog)
package {
import flash.display.*;
public dynamic class TowerDialog extends Sprite {
public var closeBtn:SimpleButton;
public var bg:TowerDialogBg;
public var sellBtn:MovieClip;
}
}//package
Section 46
//TowerDialogBg (TowerDialogBg)
package {
import flash.display.*;
public dynamic class TowerDialogBg extends Sprite {
}
}//package