Section 1
//MainTimeline (burgerdefense_v14ak_fla.MainTimeline)
package burgerdefense_v14ak_fla {
import flash.events.*;
import flash.display.*;
import mochi.as3.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class MainTimeline extends MovieClip {
public var monster_inc;
public var total_hit;
public var game_over_outcome;
public var upgrade_radius;
public var mute;
public var tank_1:MovieClip;
public var total_fired;
public var upgrade_clip_explode;
public var max_cannon;
public var new_monster;
public var andkon2:SimpleButton;
public var game_over_break;
public var particle_effects;
public var monster_e_inc;
public var andkon:SimpleButton;
public var go_button:SimpleButton;
public var gravity;
public var intro:intro_music;
public var new_cannon;
public var gamedata3_1a:MovieClip;
public var gameSpace1:MovieClip;
public var ground2_1:MovieClip;
public var firepower;
public var monster_energy;
public var gamedata3_1g:MovieClip;
public var monster_type;
public var upgrade_active;
public var upgrade_poison;
public var burgers;
public var next_level_stop;
public var enemy_poisoned;
public var upgrade_spikes;
public var firstClick;
public var hardFired;
public var money;
public var particles;
public var angle;
public var monster_xspeed;
public var money_earned;
public var total_combo;
public var mouseDown:Boolean;
public var monster_combo;
public var fired;
public var angle_xdif;
public var Nav;
public var time_over;
public var game_over;
public var upgrade_time;
public var total_acc;
public var upgrade_clip_money;
public var game_time;
public var myTransform:SoundTransform;
public var myMenu:ContextMenu;
public var game_winner;
public var currentCount;
public var combo_count_five;
public var upgrade_clip_poison;
public var current_level;
public var next_level;
public var spawn_max_monster;
public var cannon_strength;
public var GTimer:Timer;
public var greset;
public var node_1:MovieClip;
public var gamedata2_1:MovieClip;
public var show_aim_ui;
public var mouseMoving;
public var angle_ydif;
public var gamedata_1:MovieClip;
public var _mochiads_game_id:String;
public var fireStop;
public var crosshair_1:MovieClip;
public var monsters_placed;
public var crosshair_2:MovieClip;
public var upgrade_clip_spikes;
public var ground_1:MovieClip;
public var upgrade_approved;
public var max_firepower;
public var upgrade_type;
public var runTimer;
public var spawn_max_cannon;
public var back_button:SimpleButton;
public var enemy_kill_score;
public var cannons_left;
public var bar_border_1:MovieClip;
public var delay;
public var upgrade_clip;
public var repeat;
public var gamedata3_1:MovieClip;
public var ui_aim_bar_1:MovieClip;
public var ui_aim_bar_2:MovieClip;
public var upgrade_time_max;
public var total_accuracy;
public var myChannel:SoundChannel;
public var cannon_delay;
public var upgrade_explode;
public var total_score;
public var explode_strength;
public var thoomp_1:MovieClip;
public var gpause;
public var help_button:SimpleButton;
public var levelCount;
public var max_monster;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 272, frame273, 273, frame274, 274, frame275);
}
function frame273(){
if (repeat == 0){
myChannel = intro.play(0, 10);
myChannel.soundTransform = myTransform;
repeat = 1;
};
go_button.addEventListener(MouseEvent.CLICK, gameGo);
help_button.addEventListener(MouseEvent.CLICK, gameHelp);
andkon.addEventListener(MouseEvent.CLICK, gameandkon);
stop();
}
function frame275(){
MochiBot.track(this, "0994a1f3");
show_aim_ui = true;
mouseMoving = false;
firstClick = true;
Nav = false;
mute = false;
gpause = false;
greset = false;
particle_effects = true;
gravity = 3;
money = 200;
money_earned = 10;
burgers = 20;
combo_count_five = 0;
monster_combo = false;
fired = 0;
hardFired = 0;
fireStop = false;
max_firepower = 5;
total_fired = 0;
total_hit = 0;
total_accuracy = 0;
cannon_strength = 50;
explode_strength = Math.floor((cannon_strength / 3));
cannons_left = max_firepower;
upgrade_time = 0;
upgrade_time_max = 1000;
upgrade_type = "none";
upgrade_approved = false;
upgrade_active = false;
upgrade_clip = 0;
upgrade_explode = 0;
upgrade_spikes = 0;
upgrade_poison = 0;
upgrade_radius = 150;
upgrade_clip_money = 250;
upgrade_clip_explode = 150;
upgrade_clip_poison = 170;
upgrade_clip_spikes = 200;
time_over = false;
game_over = false;
game_over_break = false;
game_over_outcome = "";
enemy_poisoned = 0;
cannon_delay = 0;
new_cannon = 0;
spawn_max_cannon = 0;
max_cannon = max_firepower;
delay = 50;
new_monster = 0;
monsters_placed = 0;
spawn_max_monster = 0;
max_monster = 0;
monster_xspeed = 0.5;
monster_e_inc = 10;
monster_energy = monster_e_inc;
monster_type = new enemy();
current_level = 0;
next_level = 1;
next_level_stop = false;
monster_inc = 2;
game_time = 0;
GTimer = new Timer(5, 0);
levelCount = 999;
currentCount = levelCount;
runTimer = true;
angle_xdif = 0;
angle_ydif = 0;
angle = 0;
firepower = 0;
particles = 0;
enemy_kill_score = 0;
total_score = 0;
total_acc = 0;
total_combo = 0;
game_winner = 0;
gameSpace1 = root.addChild(new gameSpace());
gameSpace1.name = "gameSpace1";
gameSpace1.x = 0;
gameSpace1.y = 0;
ground2_1 = gameSpace1.addChild(new ground2());
ground2_1.x = 0;
ground2_1.y = 196;
ground_1 = gameSpace1.addChild(new ground());
ground_1.x = 0;
ground_1.y = 198;
tank_1 = gameSpace1.addChild(new tank());
tank_1.x = 465;
tank_1.y = 198;
node_1 = gameSpace1.addChild(new node());
node_1.x = 468;
node_1.y = 0xFF;
gamedata_1 = gameSpace1.addChild(new gamedata());
gamedata_1.x = 25;
gamedata_1.y = 315;
gamedata2_1 = gameSpace1.addChild(new gamedata2());
gamedata2_1.x = 25;
gamedata2_1.y = 0;
gamedata3_1 = gameSpace1.addChild(new gamedata3());
gamedata3_1.x = 25;
gamedata3_1.y = 363;
ui_aim_bar_1 = gameSpace1.addChild(new aim_bar());
ui_aim_bar_1.x = 460;
ui_aim_bar_1.y = 50;
ui_aim_bar_1.rotation = 180;
ui_aim_bar_1.aim_name.gotoAndStop(1);
ui_aim_bar_2 = gameSpace1.addChild(new aim_bar());
ui_aim_bar_2.x = 490;
ui_aim_bar_2.y = 50;
ui_aim_bar_2.rotation = 180;
ui_aim_bar_2.aim_name.gotoAndStop(2);
bar_border_1 = gameSpace1.addChild(new bar_border());
bar_border_1.x = 349;
bar_border_1.y = 293;
thoomp_1 = gameSpace1.addChild(new thoomp());
thoomp_1.x = -300;
thoomp_1.y = -300;
crosshair_1 = gameSpace1.addChild(new crosshair());
crosshair_1.x = 50;
crosshair_1.y = 50;
crosshair_2 = gameSpace1.addChild(new crosshair());
crosshair_2.x = -500;
crosshair_2.y = -500;
gamedata_1.explode_button.addEventListener(MouseEvent.CLICK, upgradeExplode);
gamedata_1.explode_button.addEventListener(MouseEvent.ROLL_OVER, describeExplode);
gamedata_1.explode_button.addEventListener(MouseEvent.ROLL_OUT, describeExplode2);
gamedata_1.spike_button.addEventListener(MouseEvent.CLICK, upgradeSpike);
gamedata_1.spike_button.addEventListener(MouseEvent.ROLL_OVER, describeSpike);
gamedata_1.spike_button.addEventListener(MouseEvent.ROLL_OUT, describeSpike2);
gamedata_1.clip_button.addEventListener(MouseEvent.CLICK, upgradeClip);
gamedata_1.clip_button.addEventListener(MouseEvent.ROLL_OVER, describeClip);
gamedata_1.clip_button.addEventListener(MouseEvent.ROLL_OUT, describeClip2);
gamedata_1.poison_button.addEventListener(MouseEvent.CLICK, upgradePoison);
gamedata_1.poison_button.addEventListener(MouseEvent.ROLL_OVER, describePoison);
gamedata_1.poison_button.addEventListener(MouseEvent.ROLL_OUT, describePoison2);
gamedata_1.sound_button.addEventListener(MouseEvent.CLICK, muteSound);
gamedata_1.quality_button.addEventListener(MouseEvent.CLICK, lowerQuality);
gamedata_1.effects_button.addEventListener(MouseEvent.CLICK, dropEffects);
gamedata_1.aim_button.addEventListener(MouseEvent.CLICK, dropAim);
gamedata_1.pause_button.addEventListener(MouseEvent.CLICK, gamePause);
gamedata_1.restart_button.addEventListener(MouseEvent.CLICK, gameRestart);
gameSpace1.addEventListener(Event.ENTER_FRAME, moveMouse);
gameSpace1.addEventListener(Event.ENTER_FRAME, textShow);
gameSpace1.addEventListener(Event.ENTER_FRAME, OEF);
stop();
stop();
}
public function describeSpike(_arg1:MouseEvent):void{
var _local2:MovieClip;
_local2 = gameSpace1.addChild(new spike_description());
_local2.x = (mouseX - 5);
_local2.y = (mouseY - 5);
_local2.name = "spike_description1";
_local2.spike_damage_txt.text = String(("Current Damage: " + cannon_strength));
if (upgrade_spikes <= 2){
_local2.spike_upgrade_txt.text = String(("Next Upgrade: $" + upgrade_clip_spikes));
} else {
_local2.spike_upgrade_txt.text = String("");
};
}
public function gameandkon2(_arg1:MouseEvent):void{
var _local2:String;
var _local3:URLRequest;
_local2 = "http://www.andkon.com/arcade/";
_local3 = new URLRequest(_local2);
navigateToURL(_local3, "_blank");
}
function frame274(){
back_button.addEventListener(MouseEvent.CLICK, gameBack);
}
public function doSomething(_arg1:ContextMenuEvent):void{
var _local2:String;
var _local3:URLRequest;
_local2 = "http://www.burgerdefense.com";
_local3 = new URLRequest(_local2);
navigateToURL(_local3, "_blank");
}
public function upgradePoison(_arg1:MouseEvent):void{
var _local2:*;
if (upgrade_type == "none"){
upgrade_type = "poison";
};
_local2 = gameSpace1.getChildByName("poison_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("poison_description1"));
};
}
public function place_enemy(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6):void{
var _local7:MovieClip;
if (_arg6 == 1){
_local7 = gameSpace1.addChild(new enemy());
} else {
if (_arg6 == 2){
_local7 = gameSpace1.addChild(new enemy2());
} else {
if (_arg6 == 3){
_local7 = gameSpace1.addChild(new enemy3());
} else {
if (_arg6 == 4){
_local7 = gameSpace1.addChild(new enemy4());
} else {
_local7 = gameSpace1.addChild(new enemy());
};
};
};
};
_local7.name = ("enemy_" + spawn_max_monster);
_local7.x = _arg1;
_local7.y = _arg2;
_local7.yspeed = 0;
_local7.xspeed = _arg3;
_local7.energy = _arg4;
_local7.energy_max = _arg4;
_local7.poison_level = 0;
_local7.pi = _arg5;
_local7.graphic = _arg6;
_local7.dead = false;
_local7.hit = false;
_local7.delay_hit = 25;
_local7.count = 1;
_local7.max_count = 2;
_local7.new_count = 0;
_local7.hit = false;
_local7.addEventListener(Event.ENTER_FRAME, move_enemy);
}
function frame2(){
gamedata3_1g = this.addChild(new gamedata3());
gamedata3_1g.x = 25;
gamedata3_1g.y = 363;
andkon2.addEventListener(MouseEvent.CLICK, gameandkon2);
}
public function gameHelp(_arg1:MouseEvent):void{
gotoAndStop(2);
}
public function moveShot(_arg1:Event){
var enemy_count:*;
var enemyChecker:*;
var combo_graphic_1:*;
var event = _arg1;
var _local3 = event.target;
with (_local3) {
if (gpause == false){
diry = (diry + gravity);
x = (x + (dirx / 30));
y = (y + (diry / 30));
while (ground_1.hitTestPoint(x, y, true)) {
y--;
rotation = (rotation - 1);
dirx = (dirx + final_momentum);
if ((((dirx >= 0)) && ((blow_up_state == false)))){
dirx = 0;
rotation = final_rotation;
if (u_explode >= 1){
gotoAndPlay("explode");
if (mute == false){
thoomp_1.gotoAndPlay("explode2");
};
ground_explode = true;
} else {
gotoAndPlay(26);
};
blow_up_state = true;
} else {
if ((((dirx >= 0)) && ((blow_up_state == true)))){
dirx = 0;
rotation = final_rotation;
};
};
};
if (!ground_1.hitTestPoint(x, y, true)){
rotation = (rotation - 10);
};
};
enemy_count = 1;
while (enemy_count <= max_monster) {
enemyChecker = parent.getChildByName(("enemy_" + enemy_count));
if (enemyChecker){
if (((parent.getChildByName(("enemy_" + enemy_count)).hitTestPoint(x, y, true)) && ((parent.getChildByName(("enemy_" + enemy_count)).dead == false)))){
if (p_strength > 0){
parent.getChildByName(("enemy_" + enemy_count)).poison_level = p_strength;
};
if ((((u_explode >= 1)) && ((blowing_up == false)))){
parent.getChildByName(("enemy_" + enemy_count)).energy = (parent.getChildByName(("enemy_" + enemy_count)).energy - c_strength);
dirx = 0;
gotoAndPlay("explode");
if (mute == false){
thoomp_1.gotoAndPlay("explode");
};
total_hit++;
blowing_up = true;
};
if (u_explode == 0){
parent.getChildByName(("enemy_" + enemy_count)).energy = (parent.getChildByName(("enemy_" + enemy_count)).energy - c_strength);
if (mute == false){
thoomp_1.gotoAndPlay("crack");
};
total_hit++;
dead = true;
};
};
if ((((blowing_up == true)) || ((ground_explode == true)))){
ground_explode = false;
distance_from_turret_x = (x - parent.getChildByName(("enemy_" + enemy_count)).x);
distance_from_turret_y = (y - parent.getChildByName(("enemy_" + enemy_count)).y);
if ((((Math.sqrt(((distance_from_turret_x * distance_from_turret_x) + (distance_from_turret_y * distance_from_turret_y))) < (radius / 2))) && ((parent.getChildByName(("enemy_" + enemy_count)).hit == false)))){
combo = (combo + 1);
parent.getChildByName(("enemy_" + enemy_count)).energy = (parent.getChildByName(("enemy_" + enemy_count)).energy - e_strength);
parent.getChildByName(("enemy_" + enemy_count)).hit = true;
if (p_strength > 0){
parent.getChildByName(("enemy_" + enemy_count)).poison_level = p_strength;
};
if ((((combo >= 5)) && ((combo_finished == false)))){
if (particle_effects == true){
createExplosion(x, (y - 20));
createExplosion((x + 15), (y - 20));
createExplosion((x - 15), (y - 20));
};
combo_graphic_1 = gameSpace1.addChild(new combo_graphic());
combo_graphic_1.name = ("combo_" + name);
combo_graphic_1.x = x;
combo_graphic_1.y = (y - 15);
if (mute == false){
thoomp_1.gotoAndPlay("combo");
};
p_strength = (p_strength * 2);
combo = 0;
radius = (radius + 200);
e_strength = (e_strength * 3.5);
combo_count_five = (combo_count_five + 1);
combo_finished = true;
parent.getChildByName(("enemy_" + enemy_count)).hit = false;
};
};
};
};
enemy_count++;
};
if (currentFrame == 25){
dead = true;
};
if (currentFrame == 35){
dead = true;
};
if ((((x < -10)) || ((x > 525)))){
dead = true;
};
if ((((dead == true)) || ((greset == true)))){
fired--;
event.target.removeEventListener(Event.ENTER_FRAME, moveShot);
gameSpace1.removeChild(DisplayObject(event.target));
};
if (game_over == true){
};
};
}
public function gameGo(_arg1:MouseEvent):void{
myChannel.stop();
gotoAndStop(1, "Game");
}
public function describeClip(_arg1:MouseEvent):void{
var _local2:MovieClip;
_local2 = gameSpace1.addChild(new clip_description());
_local2.x = (mouseX - 5);
_local2.y = (mouseY - 5);
_local2.name = "clip_description1";
_local2.clip_damage_txt.text = String(("Max Firepower: " + max_firepower));
if (upgrade_clip <= 2){
_local2.clip_upgrade_txt.text = String(("Next Upgrade: $" + upgrade_clip_money));
} else {
_local2.clip_upgrade_txt.text = String("");
};
}
public function onStageMouseUp(_arg1:MouseEvent):void{
gameSpace1.removeEventListener(MouseEvent.MOUSE_UP, onStageMouseUp);
mouseDown = false;
firstClick = true;
}
public function gameandkon(_arg1:MouseEvent):void{
var _local2:String;
var _local3:URLRequest;
_local2 = "http://www.andkon.com/arcade/";
_local3 = new URLRequest(_local2);
navigateToURL(_local3, "_blank");
}
public function lowerQuality(_arg1:MouseEvent):void{
if (stage.quality == "HIGH"){
stage.quality = "LOW";
gamedata_1.option_quality.gotoAndStop(2);
} else {
stage.quality = "HIGH";
gamedata_1.option_quality.gotoAndStop(1);
};
}
public function level_timer(_arg1:TimerEvent):void{
if (gpause == false){
currentCount--;
};
game_time = Math.floor((currentCount / 100));
if (currentCount == 0){
switch_levels();
currentCount = levelCount;
GTimer.stop();
};
}
public function describeClip2(_arg1:MouseEvent):void{
var _local2:*;
_local2 = gameSpace1.getChildByName("clip_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("clip_description1"));
};
}
public function muteSound(_arg1:MouseEvent):void{
if (mute == false){
mute = true;
gamedata_1.option_sound.gotoAndStop(2);
} else {
mute = false;
gamedata_1.option_sound.gotoAndStop(1);
};
}
public function switch_levels():void{
spawn_max_monster = 0;
if (current_level == 0){
levelCount = 299;
monster_e_inc = 30;
};
if (current_level == 4){
monster_e_inc = 150;
};
if (current_level == 6){
monster_e_inc = 200;
};
if (current_level == 7){
monster_e_inc = 250;
};
if (current_level == 9){
monster_e_inc = 325;
};
max_monster = (max_monster + monster_inc);
monster_energy = (monster_energy + monster_e_inc);
money_earned = (money_earned + 1);
current_level = (current_level + 1);
next_level_stop = true;
runTimer = true;
if (current_level == next_level){
if ((((current_level <= 19)) && ((game_over == false)))){
if (game_time > 0){
next_level_stop = false;
next_level = (next_level + 1);
};
} else {
next_level_stop = true;
};
};
if (current_level == 6){
ground_1.gotoAndPlay(2);
ground2_1.gotoAndPlay(2);
};
if (current_level == 11){
ground_1.gotoAndPlay(26);
ground2_1.gotoAndPlay(26);
};
if (current_level == 16){
ground_1.gotoAndPlay(51);
ground2_1.gotoAndPlay(51);
};
}
public function describePoison2(_arg1:MouseEvent):void{
var _local2:*;
_local2 = gameSpace1.getChildByName("poison_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("poison_description1"));
};
}
public function dropEffects(_arg1:MouseEvent):void{
if (particle_effects == true){
particle_effects = false;
gamedata_1.option_effects.gotoAndStop(2);
} else {
particle_effects = true;
gamedata_1.option_effects.gotoAndStop(1);
};
}
public function OEF(_arg1:Event){
var game_bar_1:MovieClip;
var bar_border_1:MovieClip;
var UTimer:Timer;
var upgrade_potato:*;
var xplacement:*;
var yplacement:*;
var monster_energy_temp:*;
var monster_xspeed_temp:*;
var ranNum:*;
var poison_immunity:*;
var gamedata4_1:MovieClip;
var event = _arg1;
if (Nav == false){
angle_xdif = (mouseX - tank_1.x);
angle_ydif = ((mouseY - tank_1.y) * -1);
angle = (Math.atan((angle_ydif / angle_xdif)) / (Math.PI / 180));
if (angle_xdif < 0){
angle = (angle + 180);
};
if ((((angle_xdif >= 0)) && ((angle_ydif < 0)))){
angle = (angle + 360);
};
if (angle > 175){
angle = 175;
};
if (angle < 20){
angle = 20;
};
tank_1.cannon.rotation = (angle * -1);
firepower = Math.sqrt(((angle_xdif * angle_xdif) + ((angle_ydif * angle_ydif) * 6)));
firepower = (firepower / 1.8);
if (firepower > 250){
firepower = 250;
};
if (firepower < 30){
firepower = 30;
};
};
if (show_aim_ui == true){
if (gpause == false){
firepower2 = (firepower - 30);
ui_aim_bar_1.aim_bar_main.scaleY = (firepower2 / 220);
angle2 = (175 - angle);
if (angle2 > 85){
angle3 = (angle2 - 85);
angle2 = (angle2 - angle3);
};
ui_aim_bar_2.aim_bar_main.scaleY = (angle2 / 85);
};
};
if (fired >= max_firepower){
fireStop = true;
};
if (fired == 0){
fireStop = false;
hardFired = 0;
cannons_left = (max_firepower - hardFired);
};
if (fired < 0){
fired = 0;
};
if (((((!((upgrade_type == "none"))) && ((upgrade_active == false)))) && ((gpause == false)))){
if ((((((upgrade_type == "clip")) && ((money >= upgrade_clip_money)))) && ((upgrade_clip <= 2)))){
money = (money - upgrade_clip_money);
upgrade_approved = true;
} else {
if ((((((upgrade_type == "explode")) && ((money >= upgrade_clip_explode)))) && ((upgrade_explode <= 2)))){
money = (money - upgrade_clip_explode);
upgrade_approved = true;
} else {
if ((((((upgrade_type == "spikes")) && ((money >= upgrade_clip_spikes)))) && ((upgrade_spikes <= 2)))){
money = (money - upgrade_clip_spikes);
upgrade_approved = true;
} else {
if ((((((upgrade_type == "poison")) && ((money >= upgrade_clip_poison)))) && ((upgrade_poison <= 2)))){
money = (money - upgrade_clip_poison);
upgrade_approved = true;
} else {
upgrade_type = "none";
};
};
};
};
} else {
if ((((gpause == true)) && ((upgrade_approved == false)))){
upgrade_type = "none";
};
};
if (upgrade_approved == true){
if (upgrade_active == false){
upgrade_potato = function (_arg1:TimerEvent):void{
var _local2:*;
if (gpause == false){
upgrade_time++;
};
_local2 = (upgrade_time / upgrade_time_max);
if (_local2 <= 1){
game_bar_1.bar.scaleX = _local2;
};
if (upgrade_approved == false){
UTimer.stop();
};
};
game_bar_1 = gameSpace1.addChild(new game_bar());
game_bar_1.x = 349;
game_bar_1.y = 293;
game_bar_1.name = "game_bar";
bar_border_1 = gameSpace1.addChild(new bar_border());
bar_border_1.x = 349;
bar_border_1.y = 293;
bar_border_1.name = "bar_border";
game_bar_1.bar.scaleX = 0;
UTimer = new Timer(10, 0);
UTimer.addEventListener(TimerEvent.TIMER, upgrade_potato);
UTimer.start();
};
upgrade_active = true;
if (upgrade_time >= upgrade_time_max){
if (upgrade_type == "clip"){
upgrade_clip_money = (upgrade_clip_money + 400);
max_firepower = (max_firepower + 5);
upgrade_clip = (upgrade_clip + 1);
};
if (upgrade_type == "explode"){
upgrade_clip_explode = (upgrade_clip_explode + 300);
upgrade_radius = (upgrade_radius + 20);
explode_strength = (explode_strength + 55);
upgrade_explode = (upgrade_explode + 1);
};
if (upgrade_type == "spikes"){
upgrade_clip_spikes = (upgrade_clip_spikes + 400);
cannon_strength = (cannon_strength + 70);
upgrade_spikes = (upgrade_spikes + 1);
};
if (upgrade_type == "poison"){
upgrade_clip_poison = (upgrade_clip_poison + 400);
enemy_poisoned = (enemy_poisoned + 1);
upgrade_poison = (upgrade_poison + 1);
};
upgrade_active = false;
upgrade_approved = false;
upgrade_type = "none";
upgrade_time = 0;
gameSpace1.removeChild(gameSpace1.getChildByName("game_bar"));
gameSpace1.removeChild(gameSpace1.getChildByName("bar_border"));
};
};
if (gpause == false){
if (spawn_max_monster < max_monster){
new_monster++;
};
if (new_monster == delay){
spawn_max_monster++;
monsters_placed++;
new_monster = 0;
xplacement = -50;
yplacement = 0;
monster_energy_temp = monster_energy;
monster_xspeed_temp = monster_xspeed;
poison_immunity = 0;
if ((((current_level >= 1)) && ((current_level <= 5)))){
monster_type = 1;
poison_immunity = 0;
};
if ((((current_level >= 6)) && ((current_level <= 10)))){
monster_type = 3;
poison_immunity = -1;
};
if ((((current_level >= 11)) && ((current_level <= 15)))){
monster_type = 2;
poison_immunity = 1;
ranNum = Math.floor(((Math.random() * (3 - 1)) + 1));
if (ranNum == 1){
yplacement = 200;
};
monster_xspeed_temp = 0.7;
};
if ((((current_level >= 16)) && ((current_level <= 20)))){
monster_type = 4;
poison_immunity = 0;
xplacement = Math.floor(((Math.random() * (200 - 0)) + 0));
};
if (current_level == 21){
monster_type = Math.floor(((Math.random() * (5 - 1)) + 1));
if ((((monster_type == 1)) || ((monster_type == 4)))){
poison_immunity = 0;
} else {
if (monster_type == 3){
poison_immunity = -1;
} else {
if (monster_type == 2){
poison_immunity = 1;
} else {
poison_immunity = 0;
};
};
};
};
place_enemy(xplacement, yplacement, monster_xspeed_temp, monster_energy_temp, poison_immunity, monster_type);
};
};
if ((((((((spawn_max_monster == max_monster)) && ((monsters_placed == 0)))) && ((game_over == false)))) && ((runTimer == true)))){
runTimer = false;
GTimer.addEventListener(TimerEvent.TIMER, level_timer);
GTimer.start();
};
if (current_level == 20){
};
if ((((((current_level == 20)) && ((monsters_placed == 0)))) && (!((spawn_max_monster == 0))))){
game_over = true;
game_over_outcome = "winner";
};
if (burgers <= 0){
time_over = true;
game_over = true;
game_over_outcome = "loser";
};
if (game_over == true){
if (game_over_break == false){
gamedata4_1 = gameSpace1.addChild(new gamedata4());
gamedata4_1.x = 18;
gamedata4_1.y = 15;
if (game_over_outcome == "winner"){
gamedata4_1.end_graphic.gotoAndStop(2);
game_winner = 10000;
};
total_killed = (enemy_kill_score / 100);
total_acc = ((total_accuracy * 0.01) * 1000);
total_combo = (combo_count_five * 10);
total_score = ((((enemy_kill_score + money) + total_acc) + total_combo) + game_winner);
gamedata4_1.money_txt.text = String(("$" + money));
gamedata4_1.total_combo_txt.text = String(total_combo);
gamedata4_1.combo_txt.text = String(combo_count_five);
gamedata4_1.total_acc_txt.text = String(total_acc);
gamedata4_1.acc_txt.text = String((total_accuracy + "%"));
gamedata4_1.total_killed_txt.text = String(total_killed);
gamedata4_1.enemy_kill_txt.text = String(enemy_kill_score);
gamedata4_1.total_txt.text = String(total_score);
Nav = true;
gpause = true;
game_over_break = true;
GTimer.stop();
};
};
if (total_fired > 0){
total_accuracy = Math.floor(((total_hit / total_fired) * 100));
};
if (game_over == false){
total_score = (enemy_kill_score + (combo_count_five * 10));
};
gameSpace1.addEventListener(MouseEvent.MOUSE_DOWN, onStageMouseDown);
if (fired == 0){
cannon_delay = 15;
spawn_max_cannon = 0;
firstClick = true;
max_cannon = max_firepower;
};
if (mouseDown){
if (firstClick == true){
firstClick = false;
shootShot();
} else {
if (spawn_max_cannon < (max_cannon - 1)){
new_cannon++;
};
if (new_cannon == cannon_delay){
spawn_max_cannon++;
new_cannon = 0;
shootShot();
};
};
};
}
public function upgradeExplode(_arg1:MouseEvent):void{
var _local2:*;
if (upgrade_type == "none"){
upgrade_type = "explode";
};
_local2 = gameSpace1.getChildByName("explode_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("explode_description1"));
};
}
public function upgradeSpike(_arg1:MouseEvent):void{
var _local2:*;
if (upgrade_type == "none"){
upgrade_type = "spikes";
};
_local2 = gameSpace1.getChildByName("spike_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("spike_description1"));
};
}
public function describeExplode2(_arg1:MouseEvent):void{
var _local2:*;
_local2 = gameSpace1.getChildByName("explode_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("explode_description1"));
};
}
public function onStageMouseDown(_arg1:MouseEvent):void{
gameSpace1.addEventListener(MouseEvent.MOUSE_UP, onStageMouseUp);
mouseDown = true;
}
public function moveMouse(_arg1){
if ((((((mouseY > 290)) || ((gpause == true)))) || ((game_over == true)))){
Mouse.show();
Nav = true;
} else {
Mouse.hide();
Nav = false;
};
if ((((((Nav == false)) && ((gpause == false)))) && ((game_over == false)))){
crosshair_1.x = mouseX;
crosshair_1.y = mouseY;
} else {
crosshair_1.x = -300;
crosshair_1.y = -300;
};
}
public function gamePause(_arg1:MouseEvent):void{
if (gpause == false){
gpause = true;
} else {
gpause = false;
};
}
public function describeSpike2(_arg1:MouseEvent):void{
var _local2:*;
_local2 = gameSpace1.getChildByName("spike_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("spike_description1"));
};
}
public function describeExplode(_arg1:MouseEvent):void{
var _local2:MovieClip;
_local2 = gameSpace1.addChild(new explode_description());
_local2.x = (mouseX - 5);
_local2.y = (mouseY - 5);
_local2.name = "explode_description1";
_local2.explode_damage_txt.text = String(("Current Damage: " + explode_strength));
if (upgrade_explode <= 2){
_local2.explode_upgrade_txt.text = String(("Next Upgrade: $" + upgrade_clip_explode));
} else {
_local2.explode_upgrade_txt.text = String("");
};
}
public function upgradeClip(_arg1:MouseEvent):void{
var _local2:*;
if (upgrade_type == "none"){
upgrade_type = "clip";
};
_local2 = gameSpace1.getChildByName("clip_description1");
if (_local2){
gameSpace1.removeChild(gameSpace1.getChildByName("clip_description1"));
};
}
public function move_enemy(_arg1:Event){
var PercentLoaded:*;
var colorTransform2:*;
var earned_money_1:*;
var event = _arg1;
var _local3 = event.target;
with (_local3) {
if (currentFrame == 42){
gotoAndPlay(1);
};
if (currentFrame == 1){
if (dead == true){
gotoAndPlay("dead");
};
};
if (currentFrame == 74){
event.target.removeEventListener(Event.ENTER_FRAME, move_enemy);
gameSpace1.removeChild(DisplayObject(event.target));
};
if (gameSpace1.getChildByName(("enemy_" + name))){
if (gameSpace1.getChildByName(("enemy_" + name)).currentFrame == 25){
gameSpace1.removeChild(gameSpace1.getChildByName(("enemy_" + name)));
};
if (game_over == true){
gameSpace1.removeChild(gameSpace1.getChildByName(("enemy_" + name)));
};
};
if (hit == true){
if (count < max_count){
new_count++;
};
if (new_count == delay_hit){
count++;
new_count = 0;
count = 1;
max_count = 2;
hit = false;
};
};
if (dead == false){
PercentLoaded = ((energy / energy_max) * 100);
PercentLoaded = (energy / energy_max);
if (PercentLoaded <= 1){
bar.scaleX = PercentLoaded;
};
if ((((poison_level > 0)) && (!((pi == -1))))){
colorTransform2 = transform.colorTransform;
colorTransform2.color = "0x00EE00";
bar.transform.colorTransform = colorTransform2;
};
};
if (gpause == false){
if (pi == 0){
energy = (energy - poison_level);
} else {
if (pi == 1){
energy = (energy - (poison_level * 4));
} else {
if (pi == -1){
energy = energy;
} else {
energy = (energy - poison_level);
};
};
};
yspeed = (yspeed + (gravity / 10));
x = (x + xspeed);
while (ground_1.hitTestPoint((x + (width / 2)), ((y + height) - 10), true)) {
y--;
yspeed = 0;
};
if (!ground_1.hitTestPoint((x + (width / 2)), ((y + height) - 9), true)){
y = (y + yspeed);
} else {
yspeed = 0;
};
if (node_1.hitTestPoint(x, y, true)){
xspeed = -3;
gotoAndPlay(75);
dead = true;
burgers--;
if (burgers <= 0){
burgers = 0;
};
};
};
if (greset == true){
event.target.removeEventListener(Event.ENTER_FRAME, move_enemy);
};
if (x > 500){
monsters_placed--;
event.target.removeEventListener(Event.ENTER_FRAME, move_enemy);
gameSpace1.removeChild(DisplayObject(event.target));
};
if (y > 500){
monsters_placed--;
event.target.removeEventListener(Event.ENTER_FRAME, move_enemy);
gameSpace1.removeChild(DisplayObject(event.target));
};
if ((((energy <= 0)) && ((dead == false)))){
earned_money_1 = gameSpace1.addChild(new earned_money());
earned_money_1.name = ("enemy_" + name);
earned_money_1.x = x;
earned_money_1.y = (y + 5);
earned_money_1.money_money.money_earned_txt.text = String(("+$" + money_earned));
gotoAndPlay("dead");
dead = true;
xspeed = 0;
money = (money + money_earned);
enemy_kill_score = (enemy_kill_score + 100);
monsters_placed--;
};
};
}
public function createExplosion(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:MovieClip;
var _local11:ColorTransform;
_local3 = new Array("0xFF0000", "0x00FF00", "0x0000FF", "0xFFFF00", "0xFF00FF", "0x00FFFF");
particles++;
i = 0;
while (i < 2) {
_local4 = ((_arg1 + Math.floor((Math.random() * (40 + 40)))) - 40);
_local5 = (_arg2 + ((Math.floor((Math.random() * (25 - 1))) + 1) * -1));
_local6 = (Math.floor((Math.random() * (15 - 1))) + 1);
_local7 = (Math.floor((Math.random() * (5 - 0))) + 0);
_local8 = (Math.floor((Math.random() * (0.6 - 0.3))) + 0.3);
_local9 = (Math.floor((Math.random() * (0.7 - 0.5))) + 0.5);
_local10 = stage.addChild(new myParticle());
_local11 = _local10.transform.colorTransform;
_local11.color = _local3[_local7];
_local10.fireworkz.transform.colorTransform = _local11;
_local10.x = _local4;
_local10.y = _local5;
_local10.scaleX = _local8;
_local10.scaleY = _local8;
_local10.alpha = _local9;
_local10.gotoAndPlay(_local6);
_local10.name = (("Particle1_" + particles) + i);
i++;
};
}
public function describePoison(_arg1:MouseEvent):void{
var _local2:MovieClip;
_local2 = gameSpace1.addChild(new poison_description());
_local2.x = (mouseX - 5);
_local2.y = (mouseY - 5);
_local2.name = "poison_description1";
_local2.poison_damage_txt.text = String(("Toxic Level: " + enemy_poisoned));
if (upgrade_poison <= 2){
_local2.poison_upgrade_txt.text = String(("Next Upgrade: $" + upgrade_clip_poison));
} else {
_local2.poison_upgrade_txt.text = String("");
};
}
public function shootShot():void{
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:MovieClip;
if ((((((hardFired < max_firepower)) && ((fireStop == false)))) && ((Nav == false)))){
if (mute == false){
thoomp_1.gotoAndPlay("cannon");
};
money--;
total_fired++;
hardFired++;
fired++;
cannons_left = (max_firepower - hardFired);
_local1 = (tank_1.cannon.rotation - 1);
_local2 = (tank_1.x + (48 * Math.cos(((_local1 * Math.PI) / 180))));
_local3 = (tank_1.y + (48 * Math.sin(((_local1 * Math.PI) / 180))));
_local4 = gameSpace1.addChild(new cannonball());
_local4.x = _local2;
_local4.y = _local3;
_local4.name = ("cannon_" + total_fired);
_local4.lasty = 0;
_local4.x_stop = false;
_local4.dirx = (Math.cos(((_local1 * Math.PI) / 180)) * firepower);
_local4.diry = (Math.sin(((_local1 * Math.PI) / 180)) * firepower);
_local4.final_rotation = (Math.floor((Math.random() * (360 - 0))) + 0);
_local4.final_momentum = (Math.floor((Math.random() * (5 - 1))) + 1);
_local4.blow_up_state = false;
_local4.blowing_up = false;
_local4.ground_explode = false;
_local4.combo = 0;
_local4.combo_finished = false;
_local4.c_strength = cannon_strength;
_local4.e_strength = explode_strength;
_local4.u_explode = upgrade_explode;
_local4.radius = upgrade_radius;
_local4.p_strength = enemy_poisoned;
_local4.dead = false;
_local4.addEventListener(Event.ENTER_FRAME, moveShot);
if (upgrade_spikes == 1){
_local4.spikes.gotoAndStop(2);
} else {
if (upgrade_spikes == 2){
_local4.spikes.gotoAndStop(3);
} else {
if (upgrade_spikes == 3){
_local4.spikes.gotoAndStop(4);
} else {
_local4.spikes.gotoAndStop(1);
};
};
};
if (upgrade_poison > 0){
_local4.poisoned1.gotoAndStop(2);
} else {
_local4.poisoned1.gotoAndStop(1);
};
};
}
function frame1(){
repeat = 0;
gamedata3_1a = this.addChild(new gamedata3());
gamedata3_1a.x = 25;
gamedata3_1a.y = 363;
intro = new intro_music();
myChannel = new SoundChannel();
myTransform = new SoundTransform(0.25, 0);
myMenu = new ContextMenu();
myMenu.hideBuiltInItems();
this.contextMenu = myMenu;
_mochiads_game_id = "4d6395c7952b0bd2";
MochiServices.connect("4d6395c7952b0bd2", root);
}
public function textShow(_arg1:Event){
gamedata2_1.money_txt.text = String(("$" + money));
gamedata2_1.burger_txt.text = String(burgers);
gamedata2_1.timer_txt.text = String(game_time);
gamedata2_1.level_txt.text = String(current_level);
gamedata_1.explode_txt.text = String((upgrade_explode + " / 3"));
gamedata_1.spike_txt.text = String((upgrade_spikes + " / 3"));
gamedata_1.clip_txt.text = String((upgrade_clip + " / 3"));
gamedata_1.poison_txt.text = String((upgrade_poison + " / 3"));
gamedata_1.ammo_txt.text = String(cannons_left);
gamedata_1.combo_txt.text = String(combo_count_five);
gamedata_1.acc_txt.text = String(total_accuracy);
gamedata_1.total_txt.text = String(enemy_kill_score);
}
public function gameRestart(_arg1:MouseEvent):void{
GTimer.removeEventListener(TimerEvent.TIMER, level_timer);
gameSpace1.removeEventListener(Event.ENTER_FRAME, moveMouse);
gameSpace1.removeEventListener(Event.ENTER_FRAME, OEF);
gameSpace1.removeEventListener(MouseEvent.MOUSE_DOWN, onStageMouseDown);
greset = true;
root.removeChild(getChildByName("gameSpace1"));
gotoAndStop(1, "Title");
}
public function dropAim(_arg1:MouseEvent):void{
if (show_aim_ui == true){
show_aim_ui = false;
ui_aim_bar_1.alpha = 0;
ui_aim_bar_2.alpha = 0;
gamedata_1.option_aim.gotoAndStop(2);
} else {
show_aim_ui = true;
ui_aim_bar_1.alpha = 1;
ui_aim_bar_2.alpha = 1;
gamedata_1.option_aim.gotoAndStop(1);
};
}
public function doSomething2(_arg1:ContextMenuEvent):void{
var _local2:String;
var _local3:URLRequest;
_local2 = "http://www.razoric.com";
_local3 = new URLRequest(_local2);
navigateToURL(_local3, "_blank");
}
public function gameBack(_arg1:MouseEvent):void{
gotoAndStop(1);
}
}
}//package burgerdefense_v14ak_fla
Section 2
//poisoned_65 (burgerdefense_v14ak_fla.poisoned_65)
package burgerdefense_v14ak_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class poisoned_65 extends MovieClip {
public function poisoned_65(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package burgerdefense_v14ak_fla
Section 3
//Symbol11_66 (burgerdefense_v14ak_fla.Symbol11_66)
package burgerdefense_v14ak_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class Symbol11_66 extends MovieClip {
public function Symbol11_66(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame2(){
stop();
}
}
}//package burgerdefense_v14ak_fla
Section 4
//Symbol21_20 (burgerdefense_v14ak_fla.Symbol21_20)
package burgerdefense_v14ak_fla {
import flash.display.*;
import flash.text.*;
public dynamic class Symbol21_20 extends MovieClip {
public var money_earned_txt:TextField;
}
}//package burgerdefense_v14ak_fla
Section 5
//Symbol30_12 (burgerdefense_v14ak_fla.Symbol30_12)
package burgerdefense_v14ak_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class Symbol30_12 extends MovieClip {
public function Symbol30_12(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package burgerdefense_v14ak_fla
Section 6
//Symbol32_8 (burgerdefense_v14ak_fla.Symbol32_8)
package burgerdefense_v14ak_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class Symbol32_8 extends MovieClip {
public function Symbol32_8(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package burgerdefense_v14ak_fla
Section 7
//xmark_36 (burgerdefense_v14ak_fla.xmark_36)
package burgerdefense_v14ak_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class xmark_36 extends MovieClip {
public function xmark_36(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package burgerdefense_v14ak_fla
Section 8
//KongregateEvent (com.kongregate.as3.client.events.KongregateEvent)
package com.kongregate.as3.client.events {
import flash.events.*;
public class KongregateEvent extends Event {
public static const COMPLETE:String = "component_api_available";
public function KongregateEvent(_arg1:String){
super(_arg1);
}
}
}//package com.kongregate.as3.client.events
Section 9
//AbstractShadowService (com.kongregate.as3.client.services.AbstractShadowService)
package com.kongregate.as3.client.services {
import flash.events.*;
public class AbstractShadowService extends EventDispatcher {
protected function alert(_arg1:String, _arg2:String, _arg3="", _arg4:String=""):void{
trace(((((((("Kongregate API: " + _arg1) + ".") + _arg2) + "(") + _arg3) + ") ") + _arg4));
}
}
}//package com.kongregate.as3.client.services
Section 10
//HighScoreServiceShadow (com.kongregate.as3.client.services.HighScoreServiceShadow)
package com.kongregate.as3.client.services {
public class HighScoreServiceShadow extends AbstractShadowService implements IHighScoreServices {
private var mode:String;
public function HighScoreServiceShadow(){
mode = "";
}
public function submit(_arg1:Number, _arg2:String=null):void{
alert("IHighScoreServices", "submit", arguments);
}
public function connect():Boolean{
alert("IKongregateServices", "connect");
return (true);
}
public function requestList(_arg1:Function):void{
alert("IHighScoreServices", "requestList", "", (("[Mode: " + mode) + "]"));
_arg1({success:false});
}
public function setMode(_arg1:String):void{
alert("IHighScoreServices", "setMode", arguments);
this.mode = _arg1;
}
}
}//package com.kongregate.as3.client.services
Section 11
//IHighScoreServices (com.kongregate.as3.client.services.IHighScoreServices)
package com.kongregate.as3.client.services {
public interface IHighScoreServices {
function setMode(_arg1:String):void;
function submit(_arg1:Number, _arg2:String=null):void;
function requestList(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 12
//IKongregateServices (com.kongregate.as3.client.services.IKongregateServices)
package com.kongregate.as3.client.services {
import flash.events.*;
public interface IKongregateServices extends IEventDispatcher {
function getPlayerInfo(_arg1:Function):void;
function connect(_arg1:Number=-1):Boolean;
}
}//package com.kongregate.as3.client.services
Section 13
//IStatServices (com.kongregate.as3.client.services.IStatServices)
package com.kongregate.as3.client.services {
public interface IStatServices {
function submitArray(_arg1:Array):void;
function submit(_arg1:String, _arg2:Number):void;
}
}//package com.kongregate.as3.client.services
Section 14
//IUserServices (com.kongregate.as3.client.services.IUserServices)
package com.kongregate.as3.client.services {
public interface IUserServices {
function getName():String;
function getPlayerInfo(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 15
//KongregateServiceShadow (com.kongregate.as3.client.services.KongregateServiceShadow)
package com.kongregate.as3.client.services {
public class KongregateServiceShadow extends AbstractShadowService implements IKongregateServices {
public function getName():String{
alert("IKongregateServices", "getName");
return ("Guest");
}
public function connect(_arg1:Number=-1):Boolean{
alert("IKongregateServices", "connect", arguments);
return (true);
}
public function getPlayerInfo(_arg1:Function):void{
alert("IKongregateServices", "getPlayerInfo");
_arg1(new Object());
}
}
}//package com.kongregate.as3.client.services
Section 16
//StatServiceShadow (com.kongregate.as3.client.services.StatServiceShadow)
package com.kongregate.as3.client.services {
public class StatServiceShadow extends AbstractShadowService implements IStatServices {
public function submitArray(_arg1:Array):void{
alert("IStatServices", "submitArray", arguments);
}
public function submit(_arg1:String, _arg2:Number):void{
alert("IStatServices", "submitStat", arguments);
}
}
}//package com.kongregate.as3.client.services
Section 17
//UserServiceShadow (com.kongregate.as3.client.services.UserServiceShadow)
package com.kongregate.as3.client.services {
public class UserServiceShadow extends AbstractShadowService implements IUserServices {
public function getName():String{
alert("UserService", "getName");
return ("Guest");
}
public function getPlayerInfo(_arg1:Function):void{
alert("UserService", "getPlayerInfo");
_arg1({isGuest:true, name:"Guest", points:0, level:0, isMode:false, isAdmin:false, isDeveloper:false, avatarPath:"", chatAvatarPath:""});
}
}
}//package com.kongregate.as3.client.services
Section 18
//IAPIBootstrap (com.kongregate.as3.client.IAPIBootstrap)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
public interface IAPIBootstrap {
function init(_arg1:Event=null, _arg2:Stage=null):void;
function hideLog():void;
function showLog(_arg1:int=0):void;
}
}//package com.kongregate.as3.client
Section 19
//KongregateAPI (com.kongregate.as3.client.KongregateAPI)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import com.kongregate.as3.client.services.*;
import com.kongregate.as3.client.events.*;
import flash.net.*;
import flash.system.*;
import flash.errors.*;
public class KongregateAPI extends Sprite {
private const VERSION:Number = 1;
private var loader:Loader;
private var loadedDomain:ApplicationDomain;
private static const CLASS_USER:String = "com.kongregate.as3.client.services.UserServices";
private static const CLASS_STATS:String = "com.kongregate.as3.client.services.StatServices";
private static const CLASS_SERVICES:String = "com.kongregate.as3.client.services.KongregateServices";
private static const CLASS_SCORES:String = "com.kongregate.as3.client.services.HighScoreServices";
private static const DEBUG_API_URL:String = "//Linuxpc/kongregate/public/flash/API_AS3.swf";
private static var _connected:Boolean;
private static var kUser:IUserServices;
private static var _loaded:Boolean;
private static var kServices:IKongregateServices;
private static var kScores:IHighScoreServices;
private static var mInstance:KongregateAPI;
private static var kStats:IStatServices;
private static var kAPI:IAPIBootstrap;
public function KongregateAPI(){
if (mInstance != null){
throw (new Error("Warning: KongregateAPI has been added to stage more than once or accessed improperly. Use getInstance() or a stage reference to access."));
};
mInstance = this;
this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
public function get loaded():Boolean{
return (_loaded);
}
public function get connected():Boolean{
return (_connected);
}
private function alertConnected(_arg1:TimerEvent=null):void{
var _local2:KongregateEvent;
var _local3:Boolean;
_local2 = new KongregateEvent(KongregateEvent.COMPLETE);
_local3 = this.dispatchEvent(_local2);
}
private function init(_arg1:Event):void{
var _local2:Object;
var _local3:String;
var _local4:URLRequest;
var _local5:LoaderContext;
this.removeEventListener(Event.ADDED_TO_STAGE, init);
_loaded = false;
_connected = false;
_local2 = LoaderInfo(root.loaderInfo).parameters;
_local3 = _local2.api_path;
if (_local3 == null){
trace("Alert: Kongregate API could not be loaded, due to local testing. API will load when the game is uploaded.");
createShadowServices();
return;
};
Security.allowDomain("*.kongregate.com");
Security.allowDomain("kongregatetrunk.com");
_local4 = new URLRequest(_local3);
_local5 = new LoaderContext(false);
_local5.applicationDomain = ApplicationDomain.currentDomain;
_local5.securityDomain = SecurityDomain.currentDomain;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(_local4, _local5);
}
public function get api():IAPIBootstrap{
return (kAPI);
}
private function loadComplete(_arg1:Event):void{
getServices();
}
public function get scores():IHighScoreServices{
return (kScores);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
throw (new IOError(("API file not found. " + _arg1)));
}
public function get services():IKongregateServices{
return (kServices);
}
public function get stats():IStatServices{
return (kStats);
}
private function createShadowServices():void{
var _local1:Timer;
trace(">>> Kongregate Shadow Services instantiated for local development..");
kServices = new KongregateServiceShadow();
kScores = new HighScoreServiceShadow();
kStats = new StatServiceShadow();
kUser = new UserServiceShadow();
_local1 = new Timer(200, 1);
_local1.addEventListener(TimerEvent.TIMER_COMPLETE, alertConnected);
_local1.start();
_connected = true;
}
public function get user():IUserServices{
return (kUser);
}
private function getServices():void{
var _local1:ApplicationDomain;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = ApplicationDomain.currentDomain;
kAPI = IAPIBootstrap(loader.getChildAt(0));
this.addChild(loader);
_local2 = _local1.getDefinition(CLASS_SERVICES);
trace(_local2);
kServices = _local2.getInstance();
_local3 = _local1.getDefinition(CLASS_SCORES);
kScores = _local3.getInstance();
_local4 = _local1.getDefinition(CLASS_STATS);
kStats = _local4.getInstance();
_local5 = _local1.getDefinition(CLASS_USER);
kUser = _local5.getInstance();
kServices.connect(VERSION);
_loaded = true;
_connected = true;
alertConnected();
}
public static function getInstance():KongregateAPI{
if (!mInstance){
throw (new IllegalOperationError("You must add the Kongregate API component to the stage before attempting to access it."));
};
return (mInstance);
}
}
}//package com.kongregate.as3.client
Section 20
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_HIDE:String = "StoreHide";
public static const NO_USER:String = "NoUser";
public static const IO_ERROR:String = "IOError";
public static const ITEM_NEW:String = "ItemNew";
public static const ITEM_OWNED:String = "ItemOwned";
public static const STORE_ITEMS:String = "StoreItems";
public static const ERROR:String = "Error";
public static const STORE_SHOW:String = "StoreShow";
public static var _inventory:MochiInventory;
public static function triggerEvent(_arg1:String, _arg2:Object):void{
MochiSocial.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.addEventListener(_arg1, _arg2);
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function get inventory():MochiInventory{
return (_inventory);
}
public static function showStore(_arg1:Object=null):void{
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:_arg1}, null, null);
}
public static function showItem(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showItem call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:_arg1}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showVideo(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showVideo call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_inventory = new MochiInventory();
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_inventory = null;
});
}
}//package mochi.as3
Section 21
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function reencode():void{
var _local1:uint;
_local1 = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function toString():String{
var _local1:String;
_local1 = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function get value():Number{
return (Number(this.toString()));
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String;
_local3 = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 22
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
eventTable = {};
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
return;
};
for (_local3 in eventTable[_arg1]) {
var _local6 = eventTable[_arg1];
_local6[_local3](_arg2);
};
}
public function removeEventListener(_arg1:String, _arg2:Function):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
eventTable[_arg1] = [];
return;
};
for (_local3 in eventTable[_arg1]) {
if (eventTable[_arg1][_local3] != _arg2){
} else {
eventTable[_arg1].splice(Number(_local3), 1);
};
};
}
public function addEventListener(_arg1:String, _arg2:Function):void{
removeEventListener(_arg1, _arg2);
eventTable[_arg1].push(_arg2);
}
}
}//package mochi.as3
Section 23
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const FORMAT_LONG:String = "LongForm";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const FORMAT_SHORT:String = "ShortForm";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_CENTER:String = "ALIGN_C";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var gameStart:Number;
private static var levelStart:Number;
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function startSession(_arg1:String):void{
MochiServices.send("events_beginSession", {achievementID:_arg1}, null, null);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function setNotifications(_arg1:MovieClip, _arg2:Object):void{
var _local3:Object;
var _local4:Object;
_local3 = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
_local3.clip = _arg1;
MochiServices.send("events_setNotifications", _local3, null, null);
}
public static function endGame():void{
var _local1:Number;
_local1 = (new Date().time - gameStart);
trigger("end_game", {time:_local1});
}
public static function startGame():void{
gameStart = new Date().time;
trigger("start_game");
}
public static function trigger(_arg1:String, _arg2:Object=null):void{
if (_arg2 == null){
_arg2 = {};
} else {
if (_arg2["kind"] != undefined){
trace("WARNING: optional arguments package contains key 'id', it will be overwritten");
_arg2["kind"] = _arg1;
};
};
MochiServices.send("events_triggerEvent", {eventObject:_arg2}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startLevel():void{
levelStart = new Date().time;
trigger("start_level");
}
public static function endLevel():void{
var _local1:Number;
_local1 = (new Date().time - levelStart);
trigger("end_level", {time:_local1});
}
}
}//package mochi.as3
Section 24
//MochiInventory (mochi.as3.MochiInventory)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
public dynamic class MochiInventory extends Proxy {
private var _timer:Timer;
private var _names:Array;
private var _consumableProperties:Object;
private var _syncID:Number;
private var _storeSync:Object;
private var _outstandingID:Number;
private var _syncPending:Boolean;
public static const READY:String = "InvReady";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IoError";
private static const KEY_SALT:String = " syncMaint";
public static const WRITTEN:String = "InvWritten";
public static const NOT_READY:String = "InvNotReady";
public static const VALUE_ERROR:String = "InvValueError";
private static const CONSUMER_KEY:String = "MochiConsumables";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public function MochiInventory():void{
MochiCoins.addEventListener(MochiCoins.ITEM_OWNED, itemOwned);
MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, loggedOut);
_storeSync = new Object();
_syncPending = false;
_outstandingID = 0;
_syncID = 0;
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, sync);
_timer.start();
if (MochiSocial.loggedIn){
loggedIn();
} else {
loggedOut();
};
}
private function newItems(_arg1:Object):void{
if (!this[(_arg1.id + KEY_SALT)]){
this[(_arg1.id + KEY_SALT)] = 0;
};
if (!this[_arg1.id]){
this[_arg1.id] = 0;
};
this[(_arg1.id + KEY_SALT)] = (this[(_arg1.id + KEY_SALT)] + _arg1.count);
this[_arg1.id] = (this[_arg1.id] + _arg1.count);
if (_arg1.privateProperties.consumable){
if (!this[_arg1.privateProperties.tag]){
this[_arg1.privateProperties.tag] = 0;
};
this[_arg1.privateProperties.tag] = (this[_arg1.privateProperties.tag] + (_arg1.privateProperties.inc * _arg1.count));
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (-1);
};
if (_consumableProperties[_arg1]){
return (MochiDigits(_consumableProperties[_arg1]).value);
};
return (undefined);
}
public function release():void{
MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (false);
};
if (_consumableProperties[_arg1] == undefined){
return (false);
};
return (true);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{
return (((_arg1)>=_names.length) ? 0 : (_arg1 + 1));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:MochiDigits;
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return;
};
if (!(_arg2 is Number)){
triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:_arg2});
return;
};
if (_consumableProperties[_arg1]){
_local3 = MochiDigits(_consumableProperties[_arg1]);
if (_local3.value == _arg2){
return;
};
_local3.value = _arg2;
} else {
_names.push(_arg1);
_consumableProperties[_arg1] = new MochiDigits(_arg2);
};
_syncID++;
}
private function sync(_arg1:Event=null):void{
var _local2:Object;
var _local3:String;
if (((_syncPending) || ((_syncID == _outstandingID)))){
return;
};
_outstandingID = _syncID;
_local2 = {};
for (_local3 in _consumableProperties) {
_local2[_local3] = MochiDigits(_consumableProperties[_local3]).value;
};
MochiUserData.put(CONSUMER_KEY, _local2, putConsumableBag);
_syncPending = true;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{
return (_names[(_arg1 - 1)]);
}
private function loggedIn(_arg1:Object=null):void{
MochiUserData.get(CONSUMER_KEY, getConsumableBag);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(_arg1):Boolean{
if (!_consumableProperties[_arg1]){
return (false);
};
_names.splice(_names.indexOf(_arg1), 1);
delete _consumableProperties[_arg1];
return (true);
}
private function itemOwned(_arg1:Object):void{
_storeSync[_arg1.id] = {properties:_arg1.properties, count:_arg1.count};
}
private function putConsumableBag(_arg1:MochiUserData):void{
_syncPending = false;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
_outstandingID = -1;
};
triggerEvent(WRITTEN, {});
}
private function getConsumableBag(_arg1:MochiUserData):void{
var _local2:String;
var _local3:Number;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
return;
};
_consumableProperties = {};
_names = new Array();
if (_arg1.data){
for (_local2 in _arg1.data) {
_names.push(_local2);
_consumableProperties[_local2] = new MochiDigits(_arg1.data[_local2]);
};
};
for (_local2 in _storeSync) {
_local3 = _storeSync[_local2].count;
if (_consumableProperties[(_local2 + KEY_SALT)]){
_local3 = (_local3 - _consumableProperties[_local2]);
};
if (_local3 == 0){
} else {
newItems({id:_local2, count:_local3, properties:_storeSync[_local2].properties});
};
};
triggerEvent(READY, {});
}
private function loggedOut(_arg1:Object=null):void{
_consumableProperties = null;
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
}
}//package mochi.as3
Section 25
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var n:Number;
var options = _arg1;
if (options != null){
delete options.clip;
MochiServices.setContainer();
MochiServices.bringToTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.warnID(options.boardID, true);
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (((((_arg1) && ((_arg1.error == true)))) && (onErrorHandler))){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiServices.warnID(_arg1, true);
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi.as3
Section 26
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _preserved:Object;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
public static var servicesSync:MochiSync = new MochiSync();
private static var _clip:MovieClip;
private static var _id:String;
private static var _services:String = "services.swf";
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _loader:Loader;
private static var _connecting:Boolean = false;
private static var _mochiLocalConnection:MovieClip;
private static var _listenChannelName:String = "__ms_";
public static var onError:Object;
public static var netup:Boolean = true;
private static var _mochiLC:String = "MochiLC.swf";
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function onReceive(_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = _clip._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete _clip._callbacks[cb];
}
public static function get childClip():Object{
return (_clip);
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + _arg1));
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local3:Array;
var _local4:int;
var _local5:Array;
var _local6:Array;
var _local7:MovieClip;
var _local8:LocalConnection;
var _local9:String;
var _local10:ByteArray;
var _local11:ByteArray;
var _local12:uint;
var _local13:uint;
var _local14:Loader;
_local3 = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
_local5 = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
_local6 = [0, 64, 0, 0, 0];
_local7 = new MovieClip();
_local8 = new LocalConnection();
_local9 = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
_local10 = new ByteArray();
_local11 = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
_local12 = ((_local3.length + _local11.length) + 4);
_local13 = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var vars:Object;
var avm1Click:DisplayObject;
var s:String;
var i:Number;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
vars = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
s = "?";
i = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
var _local2:Rectangle;
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
_local2 = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function warnID(_arg1:String, _arg2:Boolean):void{
var _local3:Number;
_arg1 = _arg1.toLowerCase();
if (_arg1.length != 16){
trace((("WARNING: " + (_arg2) ? "board" : "game") + " ID is not the appropriate length"));
return;
} else {
if (_arg1 == "1e113c7239048b3f"){
if (_arg2){
trace("WARNING: Using testing board ID");
} else {
trace("WARNING: Using testing board ID as game ID");
};
return;
} else {
if (_arg1 == "84993a1de4031cd8"){
if (_arg2){
trace("WARNING: Using testing game ID as board ID");
} else {
trace("WARNING: Using testing game ID");
};
return;
};
};
};
_local3 = 0;
while (_local3 < _arg1.length) {
switch (_arg1.charAt(_local3)){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
break;
default:
trace(("WARNING: Board ID contains illegal characters: " + _arg1));
return;
};
_local3++;
};
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_mochiLocalConnection.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.7 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (((_clip) && (_clip._queue))){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
}
public static function get id():String{
return (_id);
}
private static function onEvent(_arg1:Object):void{
var _local2:String;
var _local3:String;
_local2 = _arg1.target;
_local3 = _arg1.event;
switch (_local2){
case "events":
MochiEvents.triggerEvent(_arg1.event, _arg1.args);
break;
case "coins":
MochiCoins.triggerEvent(_arg1.event, _arg1.args);
break;
case "sync":
servicesSync.triggerEvent(_arg1.event, _arg1.args);
break;
};
}
private static function urlOptions(_arg1:Object):Object{
var _local2:Object;
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
_local2 = {};
if (_arg1.stage){
_local3 = _arg1.stage.loaderInfo.parameters.mochiad_options;
} else {
_local3 = _arg1.loaderInfo.parameters.mochiad_options;
};
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
private static function loadError(_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
private static function initComChannels():void{
if (!_connected){
trace("[SERVICES_API] connected!");
_connecting = false;
_connected = true;
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_clip.onReceive = onReceive;
_clip.onEvent = onEvent;
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
while (_clip._queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function loadLCBridge(_arg1:Object):void{
var loader:Loader;
var mochiLCURL:String;
var req:URLRequest;
var complete:Function;
var clip = _arg1;
loader = new Loader();
mochiLCURL = (_servURL + _mochiLC);
req = new URLRequest(mochiLCURL);
complete = function (_arg1:Object):void{
_mochiLocalConnection = MovieClip(loader.content);
listen();
};
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
loader.load(req);
clip.addChild(loader);
}
private static function listen():void{
_mochiLocalConnection.connect(_listenChannelName);
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
trace("Waiting for MochiAds services to connect...");
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var _local3:String;
var _local4:String;
var _local5:URLRequest;
var _local6:URLVariables;
_local3 = ("_mochiservices_com_" + _arg1);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
_local4 = (_servURL + _services);
if (urlOptions(_arg2).servicesURL){
_local4 = urlOptions(_arg2).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(_local4);
_clip = createEmptyMovieClip(_arg2, _local3, 10336, false);
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
_local5 = new URLRequest(_local4);
_local6 = new URLVariables();
_local6.listenLC = _listenChannelName;
_local6.mochiad_options = _arg2.loaderInfo.parameters.mochiad_options;
_local6.api_version = getVersion();
if (widget){
_local6.widget = true;
};
_local5.data = _local6;
_loader.load(_local5);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
warnID(id, false);
if ((clip is DisplayObject)){
if (clip.stage == null){
trace("MochiServices connect requires the containing clip be attached to the stage");
};
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function bringToTop(_arg1:Event=null):void{
var e = _arg1;
if (((!((MochiServices.clip == null))) && (!((MochiServices.childClip == null))))){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
}
}//package mochi.as3
Section 27
//MochiSocial (mochi.as3.MochiSocial)
package mochi.as3 {
public class MochiSocial {
public static const LOGGED_IN:String = "LoggedIn";
public static const PROFILE_HIDE:String = "ProfileHide";
public static const NO_USER:String = "NoUser";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
public static const IO_ERROR:String = "IOError";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const USER_INFO:String = "UserInfo";
public static const ERROR:String = "Error";
public static const LOGIN_SHOW:String = "LoginShow";
public static const LOGGED_OUT:String = "LoggedOut";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const LOGIN_SHOWN:String = "LoginShown";
public static const LOGIN_HIDE:String = "LoginHide";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static var _user_info:Object = null;
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function saveUserProperties(_arg1:Object):void{
MochiServices.send("coins_saveUserProperties", _arg1);
}
public static function get loggedIn():Boolean{
return (!((_user_info == null)));
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function getUserInfo():void{
MochiServices.send("coins_getUserInfo");
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showLoginWidget", {options:_arg1});
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function requestLogin():void{
MochiServices.send("coins_requestLogin");
}
public static function getAPIURL():String{
if (!_user_info){
return (null);
};
return (_user_info.api_url);
}
public static function hideLoginWidget():void{
MochiServices.send("coins_hideLoginWidget");
}
public static function getAPIToken():String{
if (!_user_info){
return (null);
};
return (_user_info.api_token);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_user_info = _arg1;
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_user_info = null;
});
}
}//package mochi.as3
Section 28
//MochiSync (mochi.as3.MochiSync)
package mochi.as3 {
import flash.utils.*;
public dynamic class MochiSync extends Proxy {
private var _syncContainer:Object;
public static var SYNC_PROPERTY:String = "UpdateProperty";
public static var SYNC_REQUEST:String = "SyncRequest";
public function MochiSync():void{
_syncContainer = {};
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
switch (_arg1){
case SYNC_REQUEST:
MochiServices.send("sync_syncronize", _syncContainer);
break;
case SYNC_PROPERTY:
_syncContainer[_arg2.name] = _arg2.value;
break;
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
return (_syncContainer[_arg1]);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:String;
if (_syncContainer[_arg1] == _arg2){
return;
};
_local3 = _arg1.toString();
_syncContainer[_local3] = _arg2;
MochiServices.send("sync_propUpdate", {name:_local3, value:_arg2});
}
}
}//package mochi.as3
Section 29
//MochiUserData (mochi.as3.MochiUserData)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class MochiUserData extends EventDispatcher {
public var callback:Function;// = null
public var error:Event;// = null
public var key:String;// = null
public var operation:String;// = null
public var data;// = null
public var _loader:URLLoader;
public function MochiUserData(_arg1:String="", _arg2:Function=null){
key = null;
data = null;
error = null;
operation = null;
callback = null;
super();
this.key = _arg1;
this.callback = _arg2;
}
public function securityErrorHandler(_arg1:SecurityErrorEvent):void{
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _arg1.toString())));
}
public function putEvent(_arg1):void{
request("put", serialize(_arg1));
}
public function request(_arg1:String, _arg2:ByteArray):void{
var api_url:String;
var api_token:String;
var args:URLVariables;
var req:URLRequest;
var _operation = _arg1;
var _data = _arg2;
operation = _operation;
api_url = MochiSocial.getAPIURL();
api_token = MochiSocial.getAPIToken();
if ((((api_url == null)) || ((api_token == null)))){
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in"));
return;
};
_loader = new URLLoader();
args = new URLVariables();
args.op = _operation;
args.key = key;
req = new URLRequest((((MochiSocial.getAPIURL() + "/") + "MochiUserData?") + args.toString()));
req.method = URLRequestMethod.POST;
req.contentType = "application/x-mochi-userdata";
req.requestHeaders = [new URLRequestHeader("x-mochi-services-version", MochiServices.getVersion()), new URLRequestHeader("x-mochi-api-token", api_token)];
req.data = _data;
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
try {
_loader.load(req);
} catch(e:SecurityError) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + e.toString())));
};
}
public function completeHandler(_arg1:Event):void{
var event = _arg1;
try {
if (_loader.data.length){
data = deserialize(_loader.data);
} else {
data = null;
};
} catch(e:Error) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + e.toString())));
return;
};
if (callback != null){
performCallback();
} else {
dispatchEvent(event);
};
close();
}
public function performCallback():void{
try {
callback(this);
} catch(e:Error) {
trace(("[MochiUserData] exception during callback: " + e));
};
}
public function serialize(_arg1):ByteArray{
var _local2:ByteArray;
_local2 = new ByteArray();
_local2.objectEncoding = ObjectEncoding.AMF3;
_local2.writeObject(_arg1);
_local2.compress();
return (_local2);
}
public function errorHandler(_arg1:IOErrorEvent):void{
data = null;
error = _arg1;
if (callback != null){
performCallback();
} else {
dispatchEvent(_arg1);
};
close();
}
public function getEvent():void{
request("get", serialize(null));
}
override public function toString():String{
return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]"));
}
public function close():void{
if (_loader){
_loader.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_loader.close();
_loader = null;
};
error = null;
callback = null;
}
public function deserialize(_arg1:ByteArray){
_arg1.objectEncoding = ObjectEncoding.AMF3;
_arg1.uncompress();
return (_arg1.readObject());
}
public static function get(_arg1:String, _arg2:Function):void{
var _local3:MochiUserData;
_local3 = new MochiUserData(_arg1, _arg2);
_local3.getEvent();
}
public static function put(_arg1:String, _arg2, _arg3:Function):void{
var _local4:MochiUserData;
_local4 = new MochiUserData(_arg1, _arg3);
_local4.putEvent(_arg2);
}
}
}//package mochi.as3
Section 30
//aim_bar (aim_bar)
package {
import flash.display.*;
public dynamic class aim_bar extends MovieClip {
public var aim_bar_main:MovieClip;
public var aim_name:MovieClip;
}
}//package
Section 31
//bar_border (bar_border)
package {
import flash.display.*;
public dynamic class bar_border extends MovieClip {
}
}//package
Section 32
//cannonball (cannonball)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class cannonball extends MovieClip {
public var spikes:MovieClip;
public var poisoned1:MovieClip;
public function cannonball(){
addFrameScript(0, frame1, 13, frame14, 24, frame25, 34, frame35);
}
function frame14(){
}
function frame1(){
stop();
}
function frame25(){
stop();
}
function frame35(){
stop();
}
}
}//package
Section 33
//cannonballp (cannonballp)
package {
import flash.display.*;
public dynamic class cannonballp extends MovieClip {
}
}//package
Section 34
//clip_description (clip_description)
package {
import flash.display.*;
import flash.text.*;
public dynamic class clip_description extends MovieClip {
public var clip_upgrade_txt:TextField;
public var clip_damage_txt:TextField;
}
}//package
Section 35
//combo_graphic (combo_graphic)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class combo_graphic extends MovieClip {
public function combo_graphic(){
addFrameScript(24, frame25);
}
function frame25(){
stop();
root.gameSpace1.removeChild(root.gameSpace1.getChildByName(name));
}
}
}//package
Section 36
//crosshair (crosshair)
package {
import flash.display.*;
public dynamic class crosshair extends MovieClip {
}
}//package
Section 37
//earned_money (earned_money)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class earned_money extends MovieClip {
public var money_money:MovieClip;
public function earned_money(){
addFrameScript(24, frame25);
}
function frame25(){
}
}
}//package
Section 38
//enemy (enemy)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class enemy extends MovieClip {
public var bar:MovieClip;
public function enemy(){
addFrameScript(0, frame1, 41, frame42, 73, frame74, 115, frame116);
}
function frame74(){
stop();
}
function frame1(){
}
function frame116(){
gotoAndPlay(75);
}
function frame42(){
}
}
}//package
Section 39
//enemy2 (enemy2)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class enemy2 extends MovieClip {
public var bar:MovieClip;
public function enemy2(){
addFrameScript(0, frame1, 41, frame42, 73, frame74, 115, frame116);
}
function frame74(){
stop();
}
function frame1(){
}
function frame116(){
gotoAndPlay(75);
}
function frame42(){
}
}
}//package
Section 40
//enemy3 (enemy3)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class enemy3 extends MovieClip {
public var bar:MovieClip;
public function enemy3(){
addFrameScript(0, frame1, 41, frame42, 73, frame74, 115, frame116);
}
function frame74(){
stop();
}
function frame1(){
}
function frame116(){
gotoAndPlay(75);
}
function frame42(){
}
}
}//package
Section 41
//enemy4 (enemy4)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class enemy4 extends MovieClip {
public var bar:MovieClip;
public function enemy4(){
addFrameScript(0, frame1, 41, frame42, 73, frame74, 115, frame116);
}
function frame74(){
stop();
}
function frame1(){
}
function frame116(){
gotoAndPlay(75);
}
function frame42(){
}
}
}//package
Section 42
//explode_description (explode_description)
package {
import flash.display.*;
import flash.text.*;
public dynamic class explode_description extends MovieClip {
public var explode_upgrade_txt:TextField;
public var explode_damage_txt:TextField;
}
}//package
Section 43
//game_bar (game_bar)
package {
import flash.display.*;
public dynamic class game_bar extends MovieClip {
public var bar:MovieClip;
}
}//package
Section 44
//gamedata (gamedata)
package {
import flash.display.*;
import flash.text.*;
public dynamic class gamedata extends MovieClip {
public var clip_button:SimpleButton;
public var total_txt:TextField;
public var clip_txt:TextField;
public var explode_txt:TextField;
public var effects_button:SimpleButton;
public var option_quality:MovieClip;
public var option_effects:MovieClip;
public var combo_txt:TextField;
public var poison_button:SimpleButton;
public var explode_button:SimpleButton;
public var restart_button:SimpleButton;
public var sound_button:SimpleButton;
public var aim_button:SimpleButton;
public var ammo_txt:TextField;
public var spike_button:SimpleButton;
public var option_aim:MovieClip;
public var quality_button:SimpleButton;
public var pause_button:SimpleButton;
public var spike_txt:TextField;
public var poison_txt:TextField;
public var acc_txt:TextField;
public var option_sound:MovieClip;
}
}//package
Section 45
//gamedata2 (gamedata2)
package {
import flash.display.*;
import flash.text.*;
public dynamic class gamedata2 extends MovieClip {
public var level_txt:TextField;
public var money_txt:TextField;
public var timer_txt:TextField;
public var burger_txt:TextField;
}
}//package
Section 46
//gamedata3 (gamedata3)
package {
import flash.display.*;
public dynamic class gamedata3 extends MovieClip {
}
}//package
Section 47
//gamedata4 (gamedata4)
package {
import flash.events.*;
import flash.display.*;
import mochi.as3.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class gamedata4 extends MovieClip {
public var total_txt:TextField;
public var total_combo_txt:TextField;
public var combo_txt:TextField;
public var submit_button:SimpleButton;
public var money_txt:TextField;
public var end_graphic:MovieClip;
public var total_killed_txt:TextField;
public var total_acc_txt:TextField;
public var acc_txt:TextField;
public var enemy_kill_txt:TextField;
public function gamedata4(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
submit_button.addEventListener(MouseEvent.CLICK, gameSubmit);
stop();
}
function frame2(){
stop();
}
public function myClosefunction(){
gotoAndStop(2);
}
public function gameSubmit(_arg1:MouseEvent):void{
MochiScores.showLeaderboard({boardID:"9b9651265e258494", score:root.total_score, onClose:myClosefunction});
}
}
}//package
Section 48
//gameSpace (gameSpace)
package {
import flash.display.*;
public dynamic class gameSpace extends MovieClip {
}
}//package
Section 49
//ground (ground)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class ground extends MovieClip {
public function ground(){
addFrameScript(0, frame1, 24, frame25, 49, frame50, 74, frame75);
}
function frame75(){
stop();
}
function frame1(){
stop();
}
function frame25(){
stop();
}
function frame50(){
stop();
}
}
}//package
Section 50
//ground2 (ground2)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class ground2 extends MovieClip {
public function ground2(){
addFrameScript(0, frame1, 24, frame25, 49, frame50, 74, frame75);
}
function frame75(){
stop();
}
function frame1(){
stop();
}
function frame25(){
stop();
}
function frame50(){
stop();
}
}
}//package
Section 51
//intro_music (intro_music)
package {
import flash.media.*;
public dynamic class intro_music extends Sound {
}
}//package
Section 52
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 53
//myParticle (myParticle)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class myParticle extends MovieClip {
public var fireworkz:MovieClip;
public function myParticle(){
addFrameScript(34, frame35);
}
function frame35(){
stop();
stage.removeChild(stage.getChildByName(name));
}
}
}//package
Section 54
//node (node)
package {
import flash.display.*;
public dynamic class node extends MovieClip {
}
}//package
Section 55
//poison_description (poison_description)
package {
import flash.display.*;
import flash.text.*;
public dynamic class poison_description extends MovieClip {
public var poison_upgrade_txt:TextField;
public var poison_damage_txt:TextField;
}
}//package
Section 56
//spike_description (spike_description)
package {
import flash.display.*;
import flash.text.*;
public dynamic class spike_description extends MovieClip {
public var spike_upgrade_txt:TextField;
public var spike_damage_txt:TextField;
}
}//package
Section 57
//tank (tank)
package {
import flash.display.*;
public dynamic class tank extends MovieClip {
public var cannon:MovieClip;
}
}//package
Section 58
//thoomp (thoomp)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.text.*;
import flash.geom.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.filters.*;
public dynamic class thoomp extends MovieClip {
public function thoomp(){
addFrameScript(0, frame1, 16, frame17, 58, frame59, 89, frame90, 173, frame174, 199, frame200);
}
function frame200(){
stop();
}
function frame90(){
stop();
}
function frame174(){
stop();
}
function frame1(){
stop();
}
function frame17(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 59
//upgrade_bar (upgrade_bar)
package {
import flash.display.*;
public dynamic class upgrade_bar extends MovieClip {
public var bar:MovieClip;
}
}//package