Section 1
//LevelBTNMC_21 (bgsurvival_fla.LevelBTNMC_21)
package bgsurvival_fla {
import flash.display.*;
public dynamic class LevelBTNMC_21 extends MovieClip {
public var medal:MovieClip;
}
}//package bgsurvival_fla
Section 2
//UI_35 (bgsurvival_fla.UI_35)
package bgsurvival_fla {
import flash.display.*;
import flash.text.*;
public dynamic class UI_35 extends MovieClip {
public var counter:TextField;
}
}//package bgsurvival_fla
Section 3
//Acoin (gam.Acoin)
package gam {
import flash.display.*;
public class Acoin extends MovieClip {
public var mycoin:Coin;
public function Acoin(c:Coin){
super();
mycoin = c;
mycoin.stop();
c.addFrameScript((c.totalFrames - 1), removeme);
}
public function hit():void{
mycoin.play();
}
private function removeme():void{
mycoin.stop();
mycoin.parent.removeChild(mycoin);
}
}
}//package gam
Section 4
//Bullet (gam.Bullet)
package gam {
import flash.display.*;
public class Bullet extends Sprite {
public var removeme:Boolean;// = false
public var yspeed:Number;
public var xspeed:Number;
public function Bullet(){
super();
graphics.lineStyle(0, 0xFF0000);
graphics.beginFill(0xFF0000);
graphics.drawCircle(0, 0, 4);
graphics.endFill();
}
}
}//package gam
Section 5
//CompleteScreen (gam.CompleteScreen)
package gam {
import flash.events.*;
import nav.*;
import snd.*;
public class CompleteScreen extends CompleteMC {
public function CompleteScreen(c:Number, tc:Number, lives:Number){
super();
cointxt.text = ((String(c) + "/") + String(tc));
lifetxt.text = String(lives);
if ((((lives == 0)) && ((c == tc)))){
medal.gotoAndStop(3);
} else {
if ((tc - c) < 3){
medal.gotoAndStop(2);
} else {
medal.gotoAndStop(1);
};
};
levelselect.addEventListener(MouseEvent.CLICK, showLevelSelect);
SoundButton.addSound(levelselect);
}
private function showLevelSelect(e:MouseEvent):void{
var g:Game = Game(parent);
parent.removeChild(this);
Navigation.showLevelSelect(g);
}
public function save():void{
SaveGameData.levelCompleted(Game(parent).currentLevelNum, (medal.currentFrame + 2));
}
}
}//package gam
Section 6
//Game (gam.Game)
package gam {
import flash.events.*;
import flash.display.*;
import snd.*;
import flash.ui.*;
public class Game extends GameMC {
private var started:Boolean;// = false
private var level:MovieClip;
private var pauseMc2:PauseScreen2;
private var slowToRemove:SlowDown;
private var starter:MovieClip;
private var acc:Number;// = 0.02
private var finish:MovieClip;
private var moveList:Array;
private var shrinkToRemove:Shrinker;
private var totalLives:Number;
private var totalCoins:Number;
private var turretList:Array;
private var pauseMc:PauseScreen;
private var livesLeft:Number;
private var invincible:Boolean;// = false
private var collectedCoins:Number;
private var smallCursor:Boolean;// = false
private var slowList:Array;
private var bulletContainer:MovieClip;
private var shrinkList:Array;
private var superList:Array;
private var invCounter:Number;// = 120
private var gameover:Boolean;
private var coinList:Array;
private var paused:Boolean;// = false
private var hitList:Array;
private var cursor:MovieClip;
private var bulletList:Array;
private var speed:Number;// = 0.2
private var cc:Number;// = 0
private var enList:Array;
private var hitMcList:Array;
private var levels:Array;
private var hitCounter:Number;// = 30
private var topSpeed:Number;// = 2
private var smallCounter:Number;// = 120
private var superToRemove:Super;
public var currentLevelNum:Number;
public function Game(){
levels = [Level1, Level2, Level3, Level4, Level5, Level6, Level7, Level8, Level9, Level10, Level11, Level12, Level13, Level14, Level15, Level16];
bulletList = new Array();
hitMcList = new Array();
pauseMc = new PauseScreen();
pauseMc2 = new PauseScreen2();
super();
pauseMc.addEventListener(MouseEvent.MOUSE_MOVE, reactivate);
pauseMc2.addEventListener(MouseEvent.MOUSE_MOVE, reactivate);
}
private function run(e:Event):void{
var m:Object;
var en:Object;
var t:Object;
var _t:Object;
var b:Bullet;
var c:Acoin;
var s:SlowDown;
var _s:Super;
var _m:Object;
var _en:Object;
var sh:Shrinker;
var mc:MovieClip;
var _mc:Object;
var w:WinScreen;
var _c:CompleteScreen;
parent.stage.focus = this;
cursor.x = mouseX;
cursor.y = mouseY;
if (!started){
for each (m in moveList) {
moveObject(m);
};
for each (en in enList) {
moveEnemy(en);
};
for each (t in turretList) {
moveTurret(t);
};
if (cursor.hitTestObject(starter)){
SoundManager.playSound("win", 1, 0.2);
started = true;
starter.gotoAndStop(2);
};
} else {
if (speed < topSpeed){
speed = (speed + acc);
};
level.x = (level.x - speed);
if (invincible){
invCounter--;
ui.counter.text = String(invCounter);
if (invCounter == 0){
removeChild(cursor);
cursor = new CursorMC();
addChild(cursor);
invincible = false;
invCounter = 120;
ui.visible = false;
};
} else {
for each (mc in hitList) {
if (cursor.hitTestObject(mc)){
hitList.splice(hitList.indexOf(mc), 1);
hitMcList.push(mc);
mc.gotoAndStop(2);
invincible = true;
looseLife();
};
};
};
if (hitMcList.length != 0){
hitCounter--;
if (hitCounter == 0){
hitCounter = 30;
for each (_mc in hitMcList) {
if ((_mc is Hit)){
_mc.gotoAndStop(1);
hitList.push(_mc);
} else {
if ((_mc is Turner)){
_mc.play();
hitList.push(_mc);
} else {
if ((_mc is Object)){
if ((_mc.clip is EnemyMC)){
_mc.clip.gotoAndStop(1);
enList.push(_mc);
} else {
if ((_mc.clip is Mover)){
_mc.clip.gotoAndStop(1);
moveList.push(_mc);
} else {
if ((_mc.clip is Turret)){
_mc.clip.gotoAndStop(1);
turretList.push(_mc);
};
};
};
};
};
};
};
hitMcList = [];
invincible = false;
};
};
for each (_t in turretList) {
moveTurret(_t);
};
for each (b in bulletList) {
moveBullet(b);
};
for each (c in coinList) {
if (cursor.hitTestObject(c.mycoin)){
SoundManager.playSound("catchs", 1);
coinList.splice(coinList.indexOf(c), 1);
c.hit();
collectedCoins++;
};
};
for each (s in slowList) {
if (cursor.hitTestObject(s)){
SoundManager.playSound("slow", 1);
slowList.splice(slowList.indexOf(s), 1);
slowToRemove = s;
s.play();
speed = 0;
};
};
for each (_s in superList) {
if (cursor.hitTestObject(_s)){
SoundManager.playSound("supers", 1, 0.2);
superList.splice(superList.indexOf(_s), 1);
superToRemove = _s;
_s.play();
invincible = true;
invCounter = 120;
removeChild(cursor);
cursor = new SuperCursorMC();
addChild(cursor);
ui.visible = true;
};
};
for each (_m in moveList) {
moveObject(_m);
};
for each (_en in enList) {
moveEnemy(_en);
};
for each (sh in shrinkList) {
if (cursor.hitTestObject(sh)){
SoundManager.playSound("shrink", 1);
shrinkList.splice(slowList.indexOf(sh), 1);
shrinkToRemove = sh;
sh.play();
smallCursor = true;
removeChild(cursor);
cursor = new SmallCursorMC();
addChild(cursor);
ui.visible = true;
};
};
cc++;
if (cc == 3){
cc = 0;
if (smallCursor){
addSmallTrail();
smallCounter--;
ui.counter.text = String(smallCounter);
if (smallCounter == 0){
smallCounter = 120;
smallCursor = false;
removeChild(cursor);
cursor = new CursorMC();
addChild(cursor);
ui.visible = false;
};
} else {
addTrail();
};
};
if (cursor.hitTestObject(finish)){
SoundManager.playSound("win", 1, 0.3);
removeEventListener(Event.ENTER_FRAME, run);
Mouse.show();
removeChild(cursor);
if (currentLevelNum < 16){
w = new WinScreen(collectedCoins, totalCoins, (totalLives - livesLeft));
w.x = 78;
w.y = 88;
addChild(w);
w.save();
} else {
_c = new CompleteScreen(collectedCoins, totalCoins, (totalLives - livesLeft));
_c.x = 78;
_c.y = 88;
addChild(_c);
_c.save();
};
};
};
}
private function pauseGame(e:KeyboardEvent=null):void{
if (!gameover){
removeEventListener(KeyboardEvent.KEY_UP, pauseGame);
removeEventListener(Event.ENTER_FRAME, run);
removeChild(cursor);
Mouse.show();
if (started){
addChild(pauseMc);
addEventListener(KeyboardEvent.KEY_UP, unpause);
} else {
addChild(pauseMc2);
addEventListener(KeyboardEvent.KEY_UP, unpause2);
};
paused = true;
};
}
private function moveTurret(m:Object):void{
var b:Bullet;
if (!m.haveToMove){
if (level.x < (550 - m.clip.x)){
m.haveToMove = true;
};
} else {
if (((((started) && (cursor.hitTestObject(m.clip)))) && (!(invincible)))){
turretList.splice(turretList.indexOf(m), 1);
hitMcList.push(m);
invincible = true;
m.clip.gotoAndStop(2);
looseLife();
};
m.dx = (m.clip.x - level.mouseX);
m.dy = (m.clip.y - level.mouseY);
m.angle = Math.atan2(m.dy, m.dx);
if (m.clip.rotation == -90){
m.rot = (((m.angle * 180) / Math.PI) + m.clip.rotation);
} else {
m.rot = ((((m.angle * 180) / Math.PI) - m.clip.rotation) + 180);
};
if ((((m.clip.rotation == 0)) && ((m.rot > 180)))){
m.rot = (((m.angle * 180) / Math.PI) - 180);
};
if ((((m.rot > -75)) && ((m.rot < 75)))){
m.clip.gun.rotation = m.rot;
m.canShoot = true;
} else {
m.canShoot = false;
};
if (((started) && (m.canShoot))){
m.reloadCount++;
if (m.reloadCount == m.reload){
m.reloadCount = 0;
b = new Bullet();
b.x = (m.clip.x + level.x);
b.y = m.clip.y;
b.xspeed = (Math.cos(m.angle) * 10);
b.yspeed = (Math.sin(m.angle) * 10);
bulletContainer.addChild(b);
bulletList.push(b);
};
};
if (level.x < (-(m.clip.x) - m.clip.width)){
m.haveToMove = false;
};
};
}
private function unpause(e:KeyboardEvent):void{
if (pauseMc.returner.hitTestPoint(mouseX, mouseY)){
addEventListener(KeyboardEvent.KEY_UP, pauseGame);
removeEventListener(KeyboardEvent.KEY_UP, unpause);
addChild(cursor);
addEventListener(Event.ENTER_FRAME, run);
Mouse.hide();
removeChild(pauseMc);
paused = false;
};
}
public function removeEvent(mc:MovieClip):void{
if (mc == pauseMc){
removeEventListener(KeyboardEvent.KEY_UP, unpause);
};
if (mc == pauseMc2){
removeEventListener(KeyboardEvent.KEY_UP, unpause2);
};
}
public function newGame(lvl:Number):void{
var mc:MovieClip;
var a:Acoin;
var t:Object;
var distance:String;
var m:Object;
var diameter:String;
var en:Object;
focusRect = false;
parent.stage.focus = this;
addEventListener(KeyboardEvent.KEY_UP, pauseGame);
bulletList = [];
if (((bulletContainer) && (contains(bulletContainer)))){
removeChild(bulletContainer);
};
bulletContainer = new MovieClip();
addChild(bulletContainer);
if (((level) && (contains(level)))){
removeChild(level);
};
currentLevelNum = lvl;
level = new (levels[(lvl - 1)]);
addChildAt(level, 1);
totalCoins = 0;
coinList = new Array();
hitList = new Array();
slowList = new Array();
shrinkList = new Array();
moveList = new Array();
superList = new Array();
enList = new Array();
turretList = new Array();
var i:Number = 0;
while (i < level.numChildren) {
if ((level.getChildAt(i) is MovieClip)){
mc = MovieClip(level.getChildAt(i));
if ((mc is Coin)){
totalCoins++;
mc.stop();
a = new Acoin(Coin(mc));
coinList.push(a);
} else {
if ((mc is SlowDown)){
mc.stop();
mc.addFrameScript((mc.totalFrames - 1), removeSlow);
slowList.push(mc);
} else {
if ((mc is Shrinker)){
mc.stop();
mc.addFrameScript((mc.totalFrames - 1), removeShrink);
shrinkList.push(mc);
} else {
if ((mc is Super)){
mc.stop();
mc.addFrameScript((mc.totalFrames - 1), removeSuper);
superList.push(mc);
} else {
if ((mc is Turret)){
trace(mc.x);
mc.stop();
t = {clip:mc, dx:0, dy:0, angle:0, reload:30, reloadCount:0, haveToMove:true};
if (t.clip.x > 550){
t.haveToMove = false;
};
turretList.push(t);
} else {
if ((mc is Mover)){
distance = mc.name.substr(1, (mc.name.length - 1));
m = {clip:mc, distCounter:0, dist:Number(distance), normal:true, dir:mc.name.charAt(0), haveToMove:true};
if (m.clip.x > 550){
m.haveToMove = false;
};
m.clip.gotoAndStop(1);
moveList.push(m);
} else {
if ((mc is EnemyMC)){
diameter = mc.name.substr(1, (mc.name.length - 1));
en = {clip:mc, diam:Number(diameter), curRot:0, normal:true, haveToMove:true};
if (en.clip.x > 550){
en.haveToMove = false;
};
en.clip.gotoAndStop(1);
enList.push(en);
} else {
if ((mc is StartMC)){
starter = mc;
starter.gotoAndStop(1);
} else {
if ((mc is FinishMC)){
finish = mc;
} else {
if ((mc is Turner)){
mc.play();
} else {
mc.stop();
};
hitList.push(mc);
};
};
};
};
};
};
};
};
};
};
i++;
};
Mouse.hide();
cursor = new CursorMC();
cursor.x = mouseX;
cursor.y = mouseY;
addChild(cursor);
speed = 0.1;
acc = 0.01;
switch (lvl){
case 1:
topSpeed = 1.5;
totalLives = 3;
break;
case 2:
topSpeed = 2;
totalLives = 3;
break;
case 3:
acc = 0.01;
topSpeed = 1;
totalLives = 3;
break;
case 4:
acc = 0.01;
topSpeed = 2.5;
totalLives = 3;
break;
case 5:
acc = 0.02;
topSpeed = 2;
totalLives = 3;
break;
case 6:
acc = 0.01;
topSpeed = 1.2;
totalLives = 4;
break;
case 7:
acc = 0.01;
topSpeed = 1.5;
totalLives = 3;
break;
case 8:
acc = 0.01;
topSpeed = 1.2;
totalLives = 3;
break;
case 9:
acc = 0.01;
topSpeed = 1;
totalLives = 2;
break;
case 10:
acc = 0.01;
topSpeed = 6;
totalLives = 2;
break;
case 11:
acc = 0.005;
topSpeed = 2;
totalLives = 4;
break;
case 12:
acc = 0.005;
topSpeed = 1;
totalLives = 3;
break;
case 13:
acc = 0.01;
topSpeed = 1;
totalLives = 1;
break;
case 14:
acc = 0.02;
topSpeed = 1.5;
totalLives = 3;
break;
case 15:
acc = 0.02;
topSpeed = 1.7;
totalLives = 3;
break;
case 16:
acc = 0.01;
topSpeed = 1.4;
totalLives = 3;
break;
};
hitMcList = [];
hitCounter = 30;
livesLeft = totalLives;
livestxt.text = ("x" + String(livesLeft));
collectedCoins = 0;
smallCursor = false;
smallCounter = 120;
invincible = false;
invCounter = 120;
gameover = false;
ui.visible = false;
started = false;
addEventListener(Event.ENTER_FRAME, run);
}
private function removeSlow():void{
slowToRemove.stop();
level.removeChild(slowToRemove);
}
private function moveBullet(b:Bullet):void{
b.x = (b.x - b.xspeed);
b.y = (b.y - b.yspeed);
if (((b.hitTestObject(cursor)) && (!(invincible)))){
looseLife();
b.removeme = true;
};
if ((((((((b.x < 0)) || ((b.x > 550)))) || ((b.y < 0)))) || ((b.y > 450)))){
b.removeme = true;
};
if (b.removeme){
removeBullet(b);
};
}
private function looseLife():void{
SoundManager.playSound("hit", 1, 0.1);
livesLeft--;
if (livesLeft > 0){
livestxt.text = ("x" + String(livesLeft));
} else {
SoundManager.playSound("fail", 1, 0.2);
gameover = true;
removeEventListener(Event.ENTER_FRAME, run);
Mouse.show();
if (contains(cursor)){
removeChild(cursor);
};
addChild(new GameOver());
};
}
private function reactivate(e:MouseEvent):void{
parent.stage.focus = this;
}
private function unpause2(e:KeyboardEvent):void{
addEventListener(KeyboardEvent.KEY_UP, pauseGame);
removeEventListener(KeyboardEvent.KEY_UP, unpause2);
addChild(cursor);
addEventListener(Event.ENTER_FRAME, run);
Mouse.hide();
removeChild(pauseMc2);
paused = false;
}
private function removeSuper():void{
superToRemove.stop();
level.removeChild(superToRemove);
}
private function moveEnemy(m:Object):void{
if (!m.haveToMove){
if ((((level.x < ((550 - m.clip.x) - m.clip.width))) && ((level.x > (-(m.clip.x) - m.clip.width))))){
m.haveToMove = true;
};
} else {
if (((((started) && (cursor.hitTestObject(m.clip)))) && (!(invincible)))){
moveList.splice(moveList.indexOf(m), 1);
hitMcList.push(m);
invincible = true;
m.clip.gotoAndStop(2);
looseLife();
};
m.curRot = (m.curRot + 2);
if (m.curRot == 360){
m.curRot = 0;
};
m.angle = ((m.curRot / 180) * Math.PI);
m.clip.x = (m.clip.x + ((Math.cos(m.angle) * m.diam) / 45));
m.clip.y = (m.clip.y + ((Math.sin(m.angle) * m.diam) / 45));
if (level.x < (-(m.clip.x) - m.clip.width)){
m.haveToMove = false;
};
};
}
private function removeShrink():void{
shrinkToRemove.stop();
level.removeChild(shrinkToRemove);
}
private function addSmallTrail():void{
var d:SmallCursorMC = new SmallCursorMC();
d.stop();
d.x = level.mouseX;
d.y = level.mouseY;
d.alpha = 0.2;
level.addChild(d);
}
private function addTrail():void{
var d:CursorMC = new CursorMC();
d.x = level.mouseX;
d.y = level.mouseY;
d.alpha = 0.2;
level.addChild(d);
}
private function removeBullet(b:Bullet):void{
bulletList.splice(bulletList.indexOf(b), 1);
bulletContainer.removeChild(b);
}
private function moveObject(m:Object):void{
if (!m.haveToMove){
if ((((level.x < (550 - m.clip.x))) && ((level.x > -(m.clip.x))))){
m.haveToMove = true;
};
} else {
if (((((started) && (cursor.hitTestObject(m.clip)))) && (!(invincible)))){
moveList.splice(moveList.indexOf(m), 1);
hitMcList.push(m);
invincible = true;
m.clip.gotoAndStop(2);
looseLife();
};
m.distCounter++;
if (m.distCounter >= m.dist){
m.distCounter = 0;
if (m.normal){
m.normal = false;
} else {
m.normal = true;
};
};
if (m.dir == "u"){
if (m.normal){
m.clip.y = (m.clip.y - 1);
} else {
m.clip.y = (m.clip.y + 1);
};
} else {
if (m.dir == "d"){
if (m.normal){
m.clip.y = (m.clip.y + 1);
} else {
m.clip.y = (m.clip.y - 1);
};
} else {
if (m.dir == "r"){
if (m.normal){
m.clip.x = (m.clip.x + 1);
} else {
m.clip.x = (m.clip.x - 1);
};
} else {
if (m.dir == "l"){
if (m.normal){
m.clip.x = (m.clip.x - 1);
} else {
m.clip.x = (m.clip.x + 1);
};
};
};
};
};
if (level.x < (-(m.clip.x) - m.clip.width)){
m.haveToMove = false;
};
};
}
public function pause():void{
if (!paused){
pauseGame();
};
}
}
}//package gam
Section 7
//GameOver (gam.GameOver)
package gam {
import flash.events.*;
import nav.*;
import snd.*;
public class GameOver extends GameOverMC {
private var txtList:Array;
public function GameOver(){
txtList = ["OH NO!", "TOO BAD...", "OH, MAN", "CAN'T TOUCH THIS", "YOU DIDN'T MAKE IT", "GRRRRR!", "ARGH!"];
super();
addFrameScript((totalFrames - 1), stopit);
}
private function retryLevel(e:MouseEvent):void{
Game(parent).newGame(Game(parent).currentLevelNum);
parent.removeChild(this);
}
private function map(e:MouseEvent):void{
var g:Game = Game(parent);
parent.removeChild(this);
Navigation.showLevelSelect(g);
}
private function stopit():void{
stop();
var t:Number = Math.round((Math.random() * (txtList.length - 1)));
overtxt.text = txtList[t];
retry.addEventListener(MouseEvent.CLICK, retryLevel);
levelmap.addEventListener(MouseEvent.CLICK, map);
SoundButton.addSound(retry);
SoundButton.addSound(levelmap);
}
}
}//package gam
Section 8
//PauseScreen (gam.PauseScreen)
package gam {
import flash.events.*;
import nav.*;
import snd.*;
public class PauseScreen extends PauseMC {
public function PauseScreen(){
super();
levelmap.addEventListener(MouseEvent.CLICK, map);
retry.addEventListener(MouseEvent.CLICK, retryLevel);
addEventListener(Event.ADDED_TO_STAGE, added);
SoundButton.initSoundButton(soundbtn);
SoundButton.addSound(levelmap);
SoundButton.addSound(retry);
}
private function added(e:Event):void{
returner.x = mouseX;
returner.y = mouseY;
}
private function map(e:MouseEvent):void{
var g:Game = Game(parent);
parent.removeChild(this);
g.removeEvent(this);
Navigation.showLevelSelect(g);
}
private function retryLevel(e:MouseEvent):void{
Game(parent).newGame(Game(parent).currentLevelNum);
Game(parent).removeEvent(this);
parent.removeChild(this);
}
}
}//package gam
Section 9
//PauseScreen2 (gam.PauseScreen2)
package gam {
import flash.events.*;
import nav.*;
import snd.*;
public class PauseScreen2 extends PauseMC2 {
public function PauseScreen2(){
super();
levelmap.addEventListener(MouseEvent.CLICK, map);
SoundButton.initSoundButton(soundbtn);
SoundButton.addSound(levelmap);
}
private function map(e:MouseEvent):void{
var g:Game = Game(parent);
parent.removeChild(this);
g.removeEvent(this);
Navigation.showLevelSelect(g);
}
}
}//package gam
Section 10
//WinScreen (gam.WinScreen)
package gam {
import flash.events.*;
import nav.*;
import snd.*;
public class WinScreen extends WinMC {
public function WinScreen(c:Number, tc:Number, lives:Number){
super();
cointxt.text = ((String(c) + "/") + String(tc));
lifetxt.text = String(lives);
if ((((lives == 0)) && ((c == tc)))){
medal.gotoAndStop(3);
} else {
if ((tc - c) < 3){
medal.gotoAndStop(2);
} else {
medal.gotoAndStop(1);
};
};
next.addEventListener(MouseEvent.CLICK, nextLevel);
levelselect.addEventListener(MouseEvent.CLICK, showLevelSelect);
SoundButton.addSound(next);
SoundButton.addSound(levelselect);
}
private function nextLevel(e:MouseEvent):void{
Game(parent).newGame((Game(parent).currentLevelNum + 1));
parent.removeChild(this);
}
private function showLevelSelect(e:MouseEvent):void{
var g:Game = Game(parent);
parent.removeChild(this);
Navigation.showLevelSelect(g);
}
public function save():void{
SaveGameData.levelCompleted(Game(parent).currentLevelNum, (medal.currentFrame + 2));
}
}
}//package gam
Section 11
//MochiAd (mochi.MochiAd)
package mochi {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiAd {
public function MochiAd(){
super();
}
public static function getVersion():String{
return ("3.02 as3");
}
public static function showClickAwayAd(options:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = options;
var DEFAULTS:Object = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (width:Number, height:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
var sendHostProgress:Boolean;
mc.regContLC = function (lc_name:String):void{
mc._containerLCName = lc_name;
};
chk["onEnterFrame"] = function ():void{
var total:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var ad_clip:Object = this.parent._mochiad_ctr;
var elapsed:Number = (getTimer() - this.started);
var finished:Boolean;
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
finished = true;
chk.started = getTimer();
} else {
if (elapsed > chk.ad_timeout){
options.ad_failed();
finished = true;
};
};
};
if (this.root == null){
finished = true;
};
if (finished){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(server:String):String{
var hostname:String = server.split("/")[2].split(":")[0];
if (Security.sandboxType == "application"){
return (hostname);
};
Security.allowDomain("*");
Security.allowDomain(hostname);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(hostname);
return (hostname);
}
public static function unload(clip:Object):Boolean{
if (((clip.clip) && (clip.clip._mochiad))){
clip = clip.clip;
};
if (clip.origFrameRate != undefined){
clip.stage.frameRate = clip.origFrameRate;
};
if (!clip._mochiad){
return (false);
};
if (clip._mochiad._containerLCName != undefined){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"unload"});
};
if (clip._mochiad.onUnload){
clip._mochiad.onUnload();
};
delete clip._mochiad_loaded;
delete clip._mochiad;
return (true);
}
public static function showInterLevelAd(options:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = options;
var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (width:Number, height:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (p > 0){
this.parent.alpha = (p * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (msec:Number):void{
var _chk:Object = mc._mochiad_wait;
_chk.server_control = true;
_chk.showing = true;
_chk.started = getTimer();
_chk.ad_msec = (msec - 250);
};
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
chk["onEnterFrame"] = function ():void{
var total:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var ad_clip:Object = this.parent._mochiad_ctr;
var elapsed:Number = (getTimer() - this.started);
var finished:Boolean;
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (elapsed > chk.ad_timeout){
options.ad_failed();
finished = true;
};
};
};
if (elapsed > chk.ad_msec){
finished = true;
};
if (finished){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(options:Object, defaults:Object):Object{
var k:String;
var pairs:Array;
var i:Number;
var kv:Array;
var optcopy:Object = {};
for (k in defaults) {
optcopy[k] = defaults[k];
};
if (options){
for (k in options) {
optcopy[k] = options[k];
};
};
if (optcopy.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
options = optcopy.clip.loaderInfo.parameters.mochiad_options;
if (options){
pairs = options.split("&");
i = 0;
while (i < pairs.length) {
kv = pairs[i].split("=");
optcopy[unescape(kv[0])] = unescape(kv[1]);
i++;
};
};
if (optcopy.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (optcopy);
}
public static function _cleanup(mc:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = mc;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
lc.client = null;
lc.close();
//unresolved jump
var _slot1 = e;
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(options:Object):MovieClip{
var clip:Object;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = options;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
if (clip._mochiad_loaded){
return (null);
};
//unresolved jump
var _slot1 = e;
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
var depth:Number = options.depth;
delete options.depth;
var mc:MovieClip = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
} else {
trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (ev:Object):void{
ev.target.removeEventListener(ev.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime()));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (io:IOErrorEvent):void{
trace("[MochiAds] Blocked URL");
});
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(base:Object, methodName:String, argsArray:Array):Object{
var nameArray:Array = methodName.split(".");
var i:Number = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return (undefined);
};
base = base[nameArray[i]];
i++;
};
if (typeof(base[nameArray[i]]) == "function"){
return (base[nameArray[i]].apply(base, argsArray));
};
return (undefined);
}
public static function createEmptyMovieClip(parent:Object, name:String, depth:Number):MovieClip{
var mc:MovieClip = new MovieClip();
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
parent[name] = mc;
mc["_name"] = name;
return (mc);
}
public static function _getRes(options:Object, clip:Object):Array{
var xy:Array;
var b:Object = clip.getBounds(clip.root);
var w:Number = 0;
var h:Number = 0;
if (typeof(options.res) != "undefined"){
xy = options.res.split("x");
w = parseFloat(xy[0]);
h = parseFloat(xy[1]);
} else {
w = (b.xMax - b.xMin);
h = (b.yMax - b.yMin);
};
if ((((w == 0)) || ((h == 0)))){
w = clip.stage.stageWidth;
h = clip.stage.stageHeight;
};
return ([w, h]);
}
public static function adShowing(mc:Object):void{
mc.origFrameRate = mc.stage.frameRate;
mc.stage.frameRate = 30;
}
public static function getValue(base:Object, objectName:String):Object{
var nameArray:Array = objectName.split(".");
var i:Number = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return (undefined);
};
base = base[nameArray[i]];
i++;
};
return (base[nameArray[i]]);
}
public static function rpc(clip:Object, callbackID:Number, arg:Object):void{
var _local4:Object;
var _local5:Object;
switch (arg.id){
case "setValue":
MochiAd.setValue(clip, arg.objectName, arg.value);
break;
case "getValue":
_local4 = MochiAd.getValue(clip, arg.objectName);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(clip, arg.method, arg.args);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + arg.id));
};
}
public static function setValue(base:Object, objectName:String, value:Object):void{
var nameArray:Array = objectName.split(".");
var i:Number = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return;
};
base = base[nameArray[i]];
i++;
};
base[nameArray[i]] = value;
}
public static function showPreGameAd(options:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = options;
var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (width:Number, height:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (percent:Number):void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = 10;
bar.y = (h - 20);
};
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (p > 0){
this.parent.alpha = (p * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var f:Function = function (ev:Event):void{
ev.target.removeEventListener(ev.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
if (clip.loaderInfo.bytesLoaded == clip.loaderInfo.bytesTotal){
complete = true;
} else {
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (msec:Number):void{
var _chk:Object = mc._mochiad_wait;
_chk.server_control = true;
_chk.showing = true;
_chk.started = getTimer();
_chk.ad_msec = msec;
};
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
mc.rpcTestFn = function (s:String):Object{
trace(("[MOCHIAD rpcTestFn] " + s));
return (s);
};
mc.regContLC = function (lc_name:String):void{
mc._containerLCName = lc_name;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (lc_name:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var total:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _clip:Object = this.parent.parent.root;
var ad_clip:Object = this.parent._mochiad_ctr;
var elapsed:Number = (getTimer() - this.started);
var finished:Boolean;
var clip_total:Number = _clip.loaderInfo.bytesTotal;
var clip_loaded:Number = _clip.loaderInfo.bytesLoaded;
if (complete){
clip_loaded = Math.max(1, clip_loaded);
clip_total = clip_loaded;
};
var clip_pcnt:Number = ((100 * clip_loaded) / clip_total);
var ad_pcnt:Number = ((100 * elapsed) / chk.ad_msec);
var _inside:Object = this._mochiad_bar._inside;
var pcnt:Number = Math.min(100, Math.min(((clip_pcnt) || (0)), ad_pcnt));
pcnt = Math.max(this.last_pcnt, pcnt);
this.last_pcnt = pcnt;
_inside.scaleX = (pcnt * 0.01);
options.ad_progress(pcnt);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:clip_pcnt});
if (clip_pcnt == 100){
sendHostProgress = false;
};
};
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((elapsed > chk.ad_timeout)) && ((clip_pcnt == 100)))){
options.ad_failed();
finished = true;
};
};
};
if (elapsed > chk.ad_msec){
finished = true;
};
if (((complete) && (finished))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(options:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(options);
}
public static function showTimedAd(options:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(options);
}
public static function doOnEnterFrame(mc:MovieClip):void{
var mc = mc;
var f:Function = function (ev:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
ev.target.removeEventListener(ev.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package mochi
Section 12
//LevelSelect (nav.LevelSelect)
package nav {
import flash.events.*;
import flash.display.*;
import snd.*;
import flash.net.*;
public class LevelSelect extends LevelSelectMC {
private var lvlList:Array;
private var highestLevel:Number;
public function LevelSelect(){
super();
lvlList = [lvl01, lvl02, lvl03, lvl04, lvl05, lvl06, lvl07, lvl08, lvl09, lvl10, lvl11, lvl12, lvl13, lvl14, lvl15, lvl16];
logo.addEventListener(MouseEvent.CLICK, toWeb);
SoundButton.initSoundButton(soundbtn);
}
private function mouseOver(e:MouseEvent):void{
MovieClip(e.currentTarget).gotoAndStop(2);
}
private function unlockLevel(l:Number):void{
var lvl:MovieClip = MovieClip(lvlList[(l - 1)]);
lvl.medal.gotoAndStop(2);
lvl.buttonMode = true;
lvl.useHandCursor = true;
lvl.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
lvl.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
lvl.addEventListener(MouseEvent.CLICK, selectLevel);
SoundButton.addSoundOnMC(lvl);
}
private function toWeb(e:MouseEvent):void{
navigateToURL(Navigation._url);
}
private function selectLevel(e:MouseEvent):void{
Navigation.startLevel((lvlList.indexOf(e.currentTarget) + 1));
}
private function mouseOut(e:MouseEvent):void{
MovieClip(e.currentTarget).gotoAndStop(1);
}
public function prepare():void{
var lvlData:Object;
var lvl:MovieClip;
highestLevel = 0;
var i:Number = 0;
while (i < lvlList.length) {
lvlData = SaveGameData.getLevelData((i + 1));
lvl = MovieClip(lvlList[i]);
lvl.gotoAndStop(1);
if (lvlData.played){
lvl.medal.gotoAndStop(lvlData.medal);
lvl.buttonMode = true;
lvl.useHandCursor = true;
lvl.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
lvl.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
lvl.addEventListener(MouseEvent.CLICK, selectLevel);
SoundButton.addSoundOnMC(lvl);
highestLevel = (i + 1);
} else {
lvl.medal.gotoAndStop(1);
};
i++;
};
if (highestLevel == 0){
unlockLevel(1);
} else {
if (highestLevel < 16){
unlockLevel((highestLevel + 1));
};
};
}
}
}//package nav
Section 13
//MainMenu (nav.MainMenu)
package nav {
import flash.events.*;
import snd.*;
import flash.net.*;
public class MainMenu extends MainMenuMC {
private var lvlStuff:Array;
public function MainMenu(){
lvlStuff = [logo, start_btn];
super();
logo.addEventListener(MouseEvent.CLICK, toWeb);
start_btn.addEventListener(MouseEvent.CLICK, startGame);
SoundButton.addSound(start_btn);
}
private function toWeb(e:MouseEvent):void{
navigateToURL(Navigation._url);
}
private function startGame(e:MouseEvent):void{
Navigation.showLevelSelect(this);
}
}
}//package nav
Section 14
//Navigation (nav.Navigation)
package nav {
import flash.display.*;
import gam.*;
import flash.net.*;
public class Navigation {
private static var levelselect:LevelSelect = new LevelSelect();
private static var game:Game = new Game();
public static var _url:URLRequest = new URLRequest("http://www.manicmartian.com");
public static var _main:MovieClip;
private static var mainmenu:MainMenu = new MainMenu();
public function Navigation(){
super();
}
public static function showLevelSelect(mc:MovieClip):void{
_main.removeChild(mc);
levelselect.prepare();
_main.addChild(levelselect);
}
public static function startLevel(lvl:Number):void{
_main.removeChild(levelselect);
_main.addChild(game);
game.newGame(lvl);
}
public static function pauseGame():void{
_main.contains(game);
game.pause();
}
public static function init(m:MovieClip):void{
_main = m;
_main.addChild(mainmenu);
}
}
}//package nav
Section 15
//Preloadscreen (nav.Preloadscreen)
package nav {
import flash.events.*;
import flash.net.*;
public class Preloadscreen extends PreloaderMC {
public function Preloadscreen():void{
super();
logo.addEventListener(MouseEvent.CLICK, toWeb);
}
private function toWeb(e:MouseEvent):void{
navigateToURL(Navigation._url, "_blank");
}
}
}//package nav
Section 16
//SaveGameData (nav.SaveGameData)
package nav {
import flash.net.*;
public class SaveGameData {
public static var settings:Object = {volume:1, quality:"best"};
public static var so_path:String = "/";
public static var so_name:String = "BG_survival";
private static var reset:Boolean = false;
public static var campaign:Array = new Array();
private static var totalLevels:Number = 17;
private static var so:SharedObject;
private static var version:Number = 0.8;
public function SaveGameData(){
super();
}
public static function deleteSaveGameData():void{
if (so){
delete so.data.campaign;
delete so.data.settings;
};
}
private static function prepare():void{
var i:Number = 0;
while (i < totalLevels) {
campaign.push(createLevelData((i + 1)));
i++;
};
}
public static function levelCompleted(level:Number, m:Number):void{
var lvlData:Object = campaign[level];
lvlData.played = true;
if (lvlData.medal < m){
lvlData.medal = m;
};
so.data.campaign = campaign;
}
private static function createLevelData(l:Number):Object{
return ({number:l, played:false, medal:1});
}
public static function getLevelData(levelNum:Number):Object{
return (campaign[levelNum]);
}
public static function init():void{
so = SharedObject.getLocal("BG_survival", "/");
//unresolved jump
var _slot1 = e;
trace("Error getting local data");
if (so){
if (!so.data.havePlayed){
trace("firstPlay");
prepare();
reset = true;
so.data.havePlayed = true;
};
if (((!(so.data.version)) || ((so.data.version < version)))){
reset = true;
so.data.version = version;
};
if (((so.data.campaign) && (!(reset)))){
campaign = so.data.campaign;
} else {
so.data.campaign = campaign;
};
if (((so.data.settings) && (!(reset)))){
settings = so.data.settings;
} else {
so.data.settings = settings;
};
};
}
}
}//package nav
Section 17
//SoundButton (snd.SoundButton)
package snd {
import flash.events.*;
import flash.display.*;
public class SoundButton {
public function SoundButton(){
super();
}
private static function mouseOut(e:MouseEvent):void{
if (MovieClip(e.currentTarget).currentLabel == "mouseOver"){
e.currentTarget.gotoAndStop("mouseup");
};
}
public static function initSoundButton(m:MovieClip):void{
m.gotoAndStop("mouseup");
m.buttonMode = true;
m.useHandCursor = true;
m.addEventListener(Event.ADDED_TO_STAGE, checkSound);
m.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
m.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
m.addEventListener(MouseEvent.CLICK, mouseClickSound);
}
public static function addSoundOnMC(mc:MovieClip):void{
mc.addEventListener(MouseEvent.MOUSE_OVER, mouseOverSound);
mc.addEventListener(MouseEvent.CLICK, clickSound);
}
private static function mouseOverSound(e:MouseEvent):void{
SoundManager.playSound("mouseOver", 1, 0.5);
}
private static function clickSound(e:MouseEvent):void{
SoundManager.playSound("klik", 1, 0.5);
}
private static function mouseOver(e:MouseEvent):void{
if (MovieClip(e.currentTarget).currentLabel == "mouseup"){
e.currentTarget.gotoAndStop("mouseOver");
};
SoundManager.playSound("mouseOver", 1, 1);
}
private static function mouseClickSound(e:MouseEvent):void{
if (MovieClip(e.currentTarget).currentLabel == "_off"){
e.currentTarget.gotoAndStop("mouseup");
SoundFX.mute = false;
} else {
e.currentTarget.gotoAndStop("_off");
SoundFX.mute = true;
};
}
public static function addSound(btn:SimpleButton):void{
btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverSound);
btn.addEventListener(MouseEvent.CLICK, clickSound);
}
private static function checkSound(e:Event):void{
if (SoundFX.mute){
e.currentTarget.gotoAndStop("_off");
} else {
e.currentTarget.gotoAndStop("mouseup");
};
}
}
}//package snd
Section 18
//SoundFX (snd.SoundFX)
package snd {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class SoundFX {
private static var soundDict:Dictionary = new Dictionary();
private static var _mute:Boolean = false;
private static var channelDict:Dictionary = new Dictionary();
public static var volume:Number = 1;
public function SoundFX(){
super();
}
public static function get mute():Boolean{
return (_mute);
}
public static function set mute(value:Boolean):void{
_mute = value;
}
public static function resetCounters():void{
channelDict = new Dictionary();
soundDict = new Dictionary();
}
private static function soundComplete(e:Event):void{
var sound:Class = channelDict[e.currentTarget];
var _local3 = soundDict;
var _local4 = sound;
var _local5 = (_local3[_local4] - 1);
_local3[_local4] = _local5;
delete channelDict[e.currentTarget];
}
public static function playSound(cls, loops:Number=1, vol:Number=1, max:Number=3):SoundChannel{
if ((cls is Array)){
cls = cls[Math.floor((Math.random() * cls.length))];
};
if ((!(cls) is Class)){
return (null);
};
if (soundDict[cls] >= max){
return (null);
};
var sound:Sound = new (cls);
var channel:SoundChannel = sound.play(0, loops);
if (!channel){
return (null);
};
var transform:SoundTransform = new SoundTransform((_mute) ? 0 : (volume * vol));
channel.soundTransform = transform;
channelDict[channel] = cls;
if (!soundDict[cls]){
soundDict[cls] = 0;
};
var _local8 = soundDict;
var _local9 = cls;
var _local10 = (_local8[_local9] + 1);
_local8[_local9] = _local10;
channel.addEventListener(Event.SOUND_COMPLETE, soundComplete);
return (channel);
}
}
}//package snd
Section 19
//SoundManager (snd.SoundManager)
package snd {
import flash.media.*;
public class SoundManager {
public static var sounds:Object = {mouseOver:Mouseover, slow:Slow, shrink:Shrink, klik:Click, win:Win, fail:Fail, supers:Supers, hit:Hits, catchs:Catch};
public function SoundManager(){
super();
}
public static function playSound(type:String, max:Number, vol:Number=1):SoundChannel{
return (SoundFX.playSound(sounds[type], 1, vol, max));
}
}
}//package snd
Section 20
//Background_survival (Background_survival)
package {
import flash.events.*;
import flash.display.*;
import nav.*;
import mochi.*;
import flash.utils.*;
public dynamic class Background_survival extends MovieClip {
private var loader:Preloadscreen;
public function Background_survival(){
loader = new Preloadscreen();
super();
gotoAndStop(1);
MochiAd.showPreGameAd({clip:root, id:"61647fbe15f72560", res:"500x400", background:0xFFFFFF, color:6674987, outline:3960789, no_bg:false, ad_finished:MochiAdComplete});
}
private function checkLoad(e:Event):void{
if ((((currentFrame == totalFrames)) || ((root.loaderInfo.bytesLoaded == root.loaderInfo.bytesTotal)))){
removeEventListener(Event.ENTER_FRAME, checkLoad);
startup();
};
}
private function startup():void{
gotoAndStop(2);
removeChild(loader);
removeEventListener(Event.ENTER_FRAME, checkLoad);
var mainClass:Class = (getDefinitionByName("Main") as Class);
addChild((new (mainClass) as DisplayObject));
}
private function MochiAdComplete():void{
addChild(loader);
addEventListener(Event.ENTER_FRAME, checkLoad);
}
}
}//package
Section 21
//Catch (Catch)
package {
import flash.media.*;
public dynamic class Catch extends Sound {
}
}//package
Section 22
//Click (Click)
package {
import flash.media.*;
public dynamic class Click extends Sound {
}
}//package
Section 23
//Coin (Coin)
package {
import flash.display.*;
public dynamic class Coin extends MovieClip {
}
}//package
Section 24
//CompleteMC (CompleteMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class CompleteMC extends MovieClip {
public var medal:MovieClip;
public var lifetxt:TextField;
public var cointxt:TextField;
public var levelselect:SimpleButton;
}
}//package
Section 25
//CursorMC (CursorMC)
package {
import flash.display.*;
public dynamic class CursorMC extends MovieClip {
}
}//package
Section 26
//EnemyMC (EnemyMC)
package {
import flash.display.*;
public dynamic class EnemyMC extends MovieClip {
}
}//package
Section 27
//Fail (Fail)
package {
import flash.media.*;
public dynamic class Fail extends Sound {
}
}//package
Section 28
//FinishMC (FinishMC)
package {
import flash.display.*;
public dynamic class FinishMC extends MovieClip {
}
}//package
Section 29
//GameMC (GameMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class GameMC extends MovieClip {
public var livestxt:TextField;
public var ui:MovieClip;
}
}//package
Section 30
//GameOverMC (GameOverMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class GameOverMC extends MovieClip {
public var overtxt:TextField;
public var levelmap:SimpleButton;
public var retry:SimpleButton;
}
}//package
Section 31
//Hit (Hit)
package {
import flash.display.*;
public dynamic class Hit extends MovieClip {
}
}//package
Section 32
//Hits (Hits)
package {
import flash.media.*;
public dynamic class Hits extends Sound {
}
}//package
Section 33
//Level1 (Level1)
package {
import flash.display.*;
public dynamic class Level1 extends MovieClip {
}
}//package
Section 34
//Level10 (Level10)
package {
import flash.display.*;
public dynamic class Level10 extends MovieClip {
public var u80:Mover;
}
}//package
Section 35
//Level11 (Level11)
package {
import flash.display.*;
public dynamic class Level11 extends MovieClip {
public var d60:Mover;
public var u80:Mover;
public var d80:Mover;
public var d40:Mover;
public var u60:Mover;
}
}//package
Section 36
//Level12 (Level12)
package {
import flash.display.*;
public dynamic class Level12 extends MovieClip {
public var e150:EnemyMC;
public var l55:Mover;
public var d60:Mover;
public var r100:Mover;
public var d90:Mover;
public var e100:EnemyMC;
public var r55:Mover;
public var e50:EnemyMC;
public var l38:Mover;
public var u60:Mover;
}
}//package
Section 37
//Level13 (Level13)
package {
import flash.display.*;
public dynamic class Level13 extends MovieClip {
}
}//package
Section 38
//Level14 (Level14)
package {
import flash.display.*;
public dynamic class Level14 extends MovieClip {
public var e150:EnemyMC;
public var d60:Mover;
public var u160:Mover;
public var r100:Mover;
public var e100:EnemyMC;
public var r60:Mover;
public var u50:Mover;
public var d40:Mover;
public var e50:EnemyMC;
public var u60:Mover;
public var d50:Mover;
}
}//package
Section 39
//Level15 (Level15)
package {
import flash.display.*;
public dynamic class Level15 extends MovieClip {
public var u40:Mover;
public var d40:Mover;
public var u60:Mover;
}
}//package
Section 40
//Level16 (Level16)
package {
import flash.display.*;
public dynamic class Level16 extends MovieClip {
public var d60:Mover;
public var u80:Mover;
public var d120:Mover;
public var d80:Mover;
public var u120:Mover;
public var l40:Mover;
public var u60:Mover;
}
}//package
Section 41
//Level2 (Level2)
package {
import flash.display.*;
public dynamic class Level2 extends MovieClip {
}
}//package
Section 42
//Level3 (Level3)
package {
import flash.display.*;
public dynamic class Level3 extends MovieClip {
public var u70:Mover;
public var u325:Mover;
public var d70:Mover;
public var r50:Mover;
public var u50:Mover;
public var d325:Mover;
}
}//package
Section 43
//Level4 (Level4)
package {
import flash.display.*;
public dynamic class Level4 extends MovieClip {
public var l50:EnemyMC;
public var d60:Mover;
public var l25:EnemyMC;
public var u60:Mover;
}
}//package
Section 44
//Level5 (Level5)
package {
import flash.display.*;
public dynamic class Level5 extends MovieClip {
public var d195:Mover;
public var u195:Mover;
public var d50:Mover;
}
}//package
Section 45
//Level6 (Level6)
package {
import flash.display.*;
public dynamic class Level6 extends MovieClip {
public var l100:Mover;
public var l50:Mover;
public var d60:Mover;
public var l60:Mover;
public var u80:Mover;
public var d120:Mover;
public var d80:Mover;
public var d15:Mover;
public var u120:Mover;
public var r50:Mover;
public var l40:Mover;
public var u60:Mover;
public var r80:Mover;
}
}//package
Section 46
//Level7 (Level7)
package {
import flash.display.*;
public dynamic class Level7 extends MovieClip {
public var r20:EnemyMC;
}
}//package
Section 47
//Level8 (Level8)
package {
import flash.display.*;
public dynamic class Level8 extends MovieClip {
public var l100:Mover;
public var u80:Mover;
public var r40:Mover;
public var u145:Mover;
public var l40:Mover;
}
}//package
Section 48
//Level9 (Level9)
package {
import flash.display.*;
public dynamic class Level9 extends MovieClip {
public var l300:Mover;
public var r300:Mover;
}
}//package
Section 49
//LevelSelectMC (LevelSelectMC)
package {
import flash.display.*;
public dynamic class LevelSelectMC extends MovieClip {
public var lvl04:MovieClip;
public var lvl05:MovieClip;
public var lvl06:MovieClip;
public var lvl07:MovieClip;
public var lvl03:MovieClip;
public var lvl08:MovieClip;
public var lvl02:MovieClip;
public var logo:SimpleButton;
public var lvl01:MovieClip;
public var lvl10:MovieClip;
public var lvl11:MovieClip;
public var lvl12:MovieClip;
public var lvl14:MovieClip;
public var lvl15:MovieClip;
public var lvl16:MovieClip;
public var lvl13:MovieClip;
public var soundbtn:MovieClip;
public var lvl09:MovieClip;
}
}//package
Section 50
//Main (Main)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.ui.*;
import flash.geom.*;
import nav.*;
public class Main extends MovieClip {
private var _url:URLRequest;
public var myContextMenu:ContextMenu;
public function Main(){
_url = new URLRequest("http://www.manicmartian.com");
super();
if (stage){
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, init);
};
}
private function addCustomMenuItems():void{
var item:ContextMenuItem = new ContextMenuItem("Manic Martian Website");
myContextMenu.customItems.push(item);
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler);
}
private function init(e:Event=null):void{
stage.scaleMode = StageScaleMode.NO_SCALE;
myContextMenu = new ContextMenu();
removeDefaultItems();
addCustomMenuItems();
this.contextMenu = myContextMenu;
myContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);
scrollRect = new Rectangle(0, 0, 500, 400);
SaveGameData.init();
Navigation.init(this);
}
private function removeDefaultItems():void{
myContextMenu.hideBuiltInItems();
}
private function menuItemSelectHandler(event:ContextMenuEvent):void{
navigateToURL(_url, "blank");
}
private function menuSelectHandler(e:ContextMenuEvent):void{
Navigation.pauseGame();
}
}
}//package
Section 51
//MainMenuMC (MainMenuMC)
package {
import flash.display.*;
public dynamic class MainMenuMC extends MovieClip {
public var logo:SimpleButton;
public var start_btn:SimpleButton;
}
}//package
Section 52
//Mouseover (Mouseover)
package {
import flash.media.*;
public dynamic class Mouseover extends Sound {
}
}//package
Section 53
//Mover (Mover)
package {
import flash.display.*;
public dynamic class Mover extends MovieClip {
}
}//package
Section 54
//PauseMC (PauseMC)
package {
import flash.display.*;
public dynamic class PauseMC extends MovieClip {
public var levelmap:SimpleButton;
public var retry:SimpleButton;
public var returner:MovieClip;
public var soundbtn:MovieClip;
}
}//package
Section 55
//PauseMC2 (PauseMC2)
package {
import flash.display.*;
public dynamic class PauseMC2 extends MovieClip {
public var levelmap:SimpleButton;
public var soundbtn:MovieClip;
}
}//package
Section 56
//PreloaderMC (PreloaderMC)
package {
import flash.display.*;
public dynamic class PreloaderMC extends MovieClip {
public var logo:SimpleButton;
}
}//package
Section 57
//Shrink (Shrink)
package {
import flash.media.*;
public dynamic class Shrink extends Sound {
}
}//package
Section 58
//Shrinker (Shrinker)
package {
import flash.display.*;
public dynamic class Shrinker extends MovieClip {
}
}//package
Section 59
//Slow (Slow)
package {
import flash.media.*;
public dynamic class Slow extends Sound {
}
}//package
Section 60
//SlowDown (SlowDown)
package {
import flash.display.*;
public dynamic class SlowDown extends MovieClip {
}
}//package
Section 61
//SmallCursorMC (SmallCursorMC)
package {
import flash.display.*;
public dynamic class SmallCursorMC extends MovieClip {
}
}//package
Section 62
//StartMC (StartMC)
package {
import flash.display.*;
public dynamic class StartMC extends MovieClip {
}
}//package
Section 63
//Super (Super)
package {
import flash.display.*;
public dynamic class Super extends MovieClip {
}
}//package
Section 64
//SuperCursorMC (SuperCursorMC)
package {
import flash.display.*;
public dynamic class SuperCursorMC extends MovieClip {
}
}//package
Section 65
//Supers (Supers)
package {
import flash.media.*;
public dynamic class Supers extends Sound {
}
}//package
Section 66
//Turner (Turner)
package {
import flash.display.*;
public dynamic class Turner extends MovieClip {
}
}//package
Section 67
//Turret (Turret)
package {
import flash.display.*;
public dynamic class Turret extends MovieClip {
public var gun:MovieClip;
}
}//package
Section 68
//Win (Win)
package {
import flash.media.*;
public dynamic class Win extends Sound {
}
}//package
Section 69
//WinMC (WinMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class WinMC extends MovieClip {
public var medal:MovieClip;
public var next:SimpleButton;
public var lifetxt:TextField;
public var cointxt:TextField;
public var levelselect:SimpleButton;
}
}//package