STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229455
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2574 · P5148

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/86273344?noj=FRM86273344-5DC" width="1" height="1"></div>

Cube Wars - conquer the battlefield in this fun game.swf

This is the info page for
Flash #92048

(Click the ID number above for more basic data on this flash file.)


Text
B

O

N

U

S

THE GOAL

You have to capture as bigger region of battle field as possible.

START

Your start base location marked with red flag.
Starting color is RED accordinly. During the game the color of
flag is changed.

You can capture the neighbour cubes in vertical or horisontal
direction. You can select cube with any color except the color
of the computer player. New color will be applied to your flag
and captured cubes.

and etc..

Bonus      cube gives you one more additional movement
but with random color.

MOVEMENTS

MENU

MENU

MENU

MENU

Hello!
This tutorial will help you understand how
to play!
Press arrow below to continue..

MENU

MENU

<p align="center"><font face="Berlin Sans FB" size="25" color="#ffff99" letterSpacing="0.000000" kerning="1"><b>a</b></font></p>

Let's take a look at you start location.
Your RED base is in the bottom left corner.
AI player starts in the top right corner -
BLUE flag.

Your Base

AI Base

Yours and AI progress

The goal of game: To capture as more
cubes as possible!
You may capture neighbour cube in
horizontal and vertical direction.

You may capture one of these cubes

When you select a cube all your captured
field is changed with a color of the
neighbour cube you have selected..
On last step we selected MAGENTA cube

Your new field with new color..

AI is not sleeping as well!!

There is a restriction! You cannot select a
neighbour cubes with the current color of
AI player. The same is for AI player
movements. It cannot select yours. Use it
as a strategy to disturb to the AI.

You can't select this cube

AI can't capture cubes

During the game the variety of available
cubes to capture is increasing.
Just think about the most appropriate
strategy in your situation.

Available cubes are highlighted

There is a BONUS cube in a game.
Bonus cube gives you one more step with
random color. You field changes a color
automatically when you select it.

BONUS! Use it for additional move!

Now you are ready to play!
Enjoy it! And Good Luck!

Finish

H E L P

H E L P

S C O R E S

S C O R E S

P L A Y

P L A Y

<p align="center"><font face="Arial Black" size="22" color="#ffff99" letterSpacing="0.000000" kerning="1"><b>NORMAL</b></font></p>

>

>

<

<

Make your own history of cube wars..

Rectangle

Bridge

Split

Smile

3 ways

MENU

MENU

SELECT MAP

Tutorial

?

COMPUTER
IS LOCKED

YOU ARE
LOCKED

VICTORY!

SUBMIT

SUBMIT

DEFEAT!

REPLAY

REPLAY

ActionScript [AS3]

Section 1
//ColorStat (com.biox.cubewars.core.ColorStat) package com.biox.cubewars.core { public class ColorStat { public var color:int; public var count:int; public function ColorStat(color:uint, count:uint){ super(); this.color = color; this.count = count; } } }//package com.biox.cubewars.core
Section 2
//Cube (com.biox.cubewars.core.Cube) package com.biox.cubewars.core { import flash.events.*; import flash.display.*; import flash.media.*; public class Cube extends Sprite { private var CubeSound:Class; public var posX:uint; public var posY:uint; public var G:uint; public var F:uint; public var H:uint; public var parrent:Cube; private var selected:Boolean; private var cb:ColorBox; public var player:String; public var isBase:Boolean;// = false public var color:uint; public var visited:Boolean; private var potectialMoves:Array;// = null public var bonusType:String; private var field:Field; public function Cube(field:Field, posX:uint, posY:uint, color:uint, player:String){ CubeSound = Cube_CubeSound; cb = new ColorBox(); super(); this.x = (field.x + (posX * field.cellWidth)); this.y = (field.y + (posY * field.cellHeight)); this.field = field; this.posX = posX; this.posY = posY; this.color = color; this.player = player; this.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); this.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); this.addEventListener(MouseEvent.CLICK, mouseDownHandler); if (player != "EMPTY"){ draw(); addChild(cb); }; } public function draw():void{ if (player == "NONE"){ cb.color = color; } else { if (player == "BONUS"){ cb.color = (field.numberOfColors * 4); } else { if (player == field.player.id){ cb.color = (isBase) ? (color + (field.numberOfColors * 3)) : (color + field.numberOfColors); } else { if (player == field.cpu.id){ cb.color = (isBase) ? (color + (field.numberOfColors * 3)) : (color + (field.numberOfColors * 2)); }; }; }; }; cb.x = this.x; cb.y = this.y; } private function isAllowedToPress():Boolean{ if ((((color == field.cpu.color)) || ((color == field.player.color)))){ return (false); }; if ((((((((((posY > 0)) && ((field.getCube(posX, (posY - 1)).player == field.player.id)))) || ((((posX > 0)) && ((field.getCube((posX - 1), posY).player == field.player.id)))))) || ((((posY < (field.countY - 1))) && ((field.getCube(posX, (posY + 1)).player == field.player.id)))))) || ((((posX < (field.countX - 1))) && ((field.getCube((posX + 1), posY).player == field.player.id)))))){ return (true); }; return (false); } public function unselect():void{ cb.unselect(); } private function mouseDownHandler(event:MouseEvent):void{ var i:uint; if (isAllowedToPress()){ (new CubeSound() as Sound).play(); if (potectialMoves == null){ potectialMoves = field.potectialMoves("PLAYER", color); }; trace(("Size of unselect: " + potectialMoves.length)); i = 0; while (i < potectialMoves.length) { (potectialMoves[i] as Cube).unselect(); i++; }; potectialMoves = null; field.captureTheField(field.player.id, color); field.startCpuDecision(); field.draw(); }; } private function mouseOutHandler(event:MouseEvent):void{ var i:uint; this.blendMode = BlendMode.NORMAL; if (isAllowedToPress()){ if (potectialMoves == null){ potectialMoves = field.potectialMoves("PLAYER", color); }; trace(("Size of unselect: " + potectialMoves.length)); i = 0; while (i < potectialMoves.length) { (potectialMoves[i] as Cube).unselect(); i++; }; potectialMoves = null; }; } private function mouseOverHandler(event:MouseEvent):void{ var i:uint; if (isAllowedToPress()){ if (potectialMoves == null){ potectialMoves = field.potectialMoves("PLAYER", color); } else { return; }; trace(("Size of select: " + potectialMoves.length)); i = 0; while (i < potectialMoves.length) { (potectialMoves[i] as Cube).select(); i++; }; }; } public function select():void{ cb.select(); } } }//package com.biox.cubewars.core
Section 3
//Cube_CubeSound (com.biox.cubewars.core.Cube_CubeSound) package com.biox.cubewars.core { import mx.core.*; public class Cube_CubeSound extends SoundAsset { } }//package com.biox.cubewars.core
Section 4
//Field (com.biox.cubewars.core.Field) package com.biox.cubewars.core { import flash.events.*; import flash.display.*; import com.biox.cubewars.game.*; import flash.text.*; import flash.utils.*; public class Field extends Sprite { public var cellWidth:uint;// = 0 public var level:Level; public var numberOfColors:int; private var stage1Moves:Array;// = null public var isBonusProcessing:Boolean;// = false public var scores:uint; public var catchedBonus:Array; public var cpu:Player; public var cellHeight:uint;// = 0 public var countY:uint;// = 0 public var totalCount:uint;// = 0 private var progress:ProgressLine;// = null public var countX:uint;// = 0 private var stage1Color:int; private var lockedId:String; public var cubes:Array;// = null public var player:Player; public var playerMoves:Array; private var icon:Icon;// = null public var cpuMoves:Array; public function Field(level:Level){ var j:uint; catchedBonus = new Array(); playerMoves = new Array(); cpuMoves = new Array(); super(); this.level = level; this.countX = 30; this.countY = 20; this.cellWidth = 10; this.cellHeight = 10; this.player = level.getPlayer(); this.cpu = level.getCPU(); this.numberOfColors = 6; level.generateField(this); generateBonuses(); fixBaseAround(); totalCount = 0; var i:uint; while (i < countX) { j = 0; while (j < countY) { if ((cubes[i][j] as Cube).player != "EMPTY"){ totalCount++; }; j++; }; i++; }; captureTheField(player.id, player.color); captureTheField(cpu.id, cpu.color); progress = new ProgressLine(this); progress.x = (this.x + 100); progress.y = (this.y + 410); addChild(progress); checkGameFinish(); icon = new Icon(); icon.x = this.x; icon.y = this.y; icon.addEventListener("replayGame", replayGame); icon.addEventListener("submitScores", submitScores); this.draw(); } private function replayGame(event:Event):void{ trace("1. replay"); dispatchEvent(new Event("replayGame")); } private function sortByCount(a:ColorStat, b:ColorStat):Number{ if (a.count > b.count){ return (1); }; if (a.count < b.count){ return (-1); }; return (0); } public function randomColor():uint{ return (randRange(0, (numberOfColors - 1))); } private function pushNotVisited(id:String, captureColor:int, notVisited:Array, cube:Cube):void{ if ((((((cube.player == id)) || ((cube.player == "BONUS")))) || ((((cube.player == "NONE")) && ((cube.color == captureColor)))))){ if ((cube.visited == false)){ notVisited.push(cube); }; }; } private function lockedPlayer(locked:String):void{ lockedId = locked; if (icon == null){ icon = new Icon(); icon.addEventListener("replayGame", replayGame); icon.addEventListener("submitScores", submitScores); }; if (cpu.id == locked){ icon.icon(2); } else { if (player.id == locked){ icon.icon(3); }; }; addChild(icon); var timer:Timer = new Timer(2000, 1); timer.addEventListener(TimerEvent.TIMER, lockedStage1); timer.start(); } public function randRange(min:Number, max:Number):Number{ return (Math.round(((Math.random() * ((max - min) + 1)) + (min - 0.5)))); } private function victory():void{ icon.icon(4); calcScores(); trace(("Scores: " + scores)); var playerFormat:TextFormat = new TextFormat(); var scoresPlayer:TextField = new TextField(); playerFormat.align = "left"; playerFormat.bold = true; scoresPlayer.defaultTextFormat = playerFormat; scoresPlayer.selectable = false; scoresPlayer.x = 270; scoresPlayer.y = 200; scoresPlayer.width = 140; scoresPlayer.height = 20; scoresPlayer.textColor = 0xFFFFFF; scoresPlayer.text = ("YOUR SCORES: " + scores); icon.addChild(scoresPlayer); } private function processCatchedBonuses(id:String):void{ var cube:Cube; isBonusProcessing = true; while (catchedBonus.length > 0) { cube = catchedBonus.pop(); switch (cube.bonusType){ case "RNDCOLOR": bonusRandomColor(id, cube); break; }; }; isBonusProcessing = false; } private function lockedStage1(event:TimerEvent):void{ var playerPercents:Number = ((player.captured / totalCount) * 100); var cpuPercents:Number = ((cpu.captured / totalCount) * 100); if (player.id == lockedId){ if (playerPercents < 50){ defeat(); } else { victory(); }; } else { if (cpu.id == lockedId){ if (cpuPercents < 50){ victory(); } else { defeat(); }; }; }; trace(("player.captured=" + player.captured)); trace(("cpu.captured=" + cpu.captured)); trace(("player.%=" + playerPercents)); trace(("cpu.%=" + cpuPercents)); } private function calculateH(a:Cube, b:Cube):uint{ return ((Math.abs((a.posX - b.posX)) + Math.abs((a.posY - b.posY)))); } public function availableMoves(id:String):Array{ var baseX:uint; var baseY:uint; var enemyColor:uint; var j:uint; var temp:Cube; var notVisited:Array = new Array(); var available:Array = new Array(); var cube:Cube; var i:uint; while (i < countX) { j = 0; while (j < countY) { cube = cubes[i][j]; cube.visited = false; j++; }; i++; }; if (id == player.id){ baseX = player.baseX; baseY = player.baseY; enemyColor = cpu.color; } else { if (id == cpu.id){ baseX = cpu.baseX; baseY = cpu.baseY; enemyColor = player.color; }; }; notVisited.push(cubes[baseX][baseY]); while (notVisited.length > 0) { cube = notVisited.pop(); cube.visited = true; if (cube.player != id){ available.push(cube); } else { temp = null; if (cube.posY > 0){ temp = cubes[cube.posX][(cube.posY - 1)]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && (!((temp.color == enemyColor))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; if (cube.posX > 0){ temp = cubes[(cube.posX - 1)][cube.posY]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && (!((temp.color == enemyColor))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; if (cube.posY < (countY - 1)){ temp = cubes[cube.posX][(cube.posY + 1)]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && (!((temp.color == enemyColor))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; if (cube.posX < (countX - 1)){ temp = cubes[(cube.posX + 1)][cube.posY]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && (!((temp.color == enemyColor))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; }; }; return (available); } private function calculateColorStatistics():Array{ var i:uint; var current:Cube; var posX:uint; var posY:uint; var cube:Cube; var calc:Array = new Array(); var opened:Array = new Array(); var closed:Array = new Array(); var startCube:Cube = cubes[cpu.baseX][cpu.baseY]; opened.push(startCube); while (opened.length > 0) { current = opened.pop(); posX = current.posX; posY = current.posY; closed.push(current); if (posY > 0){ processNeighForStat(calc, opened, closed, cubes[posX][(posY - 1)]); }; if (posX > 0){ processNeighForStat(calc, opened, closed, cubes[(posX - 1)][posY]); }; if (posY < (countY - 1)){ processNeighForStat(calc, opened, closed, cubes[posX][(posY + 1)]); }; if (posX < (countX - 1)){ processNeighForStat(calc, opened, closed, cubes[(posX + 1)][posY]); }; }; var counters:Array = new Array(); i = 0; while (i < numberOfColors) { counters.push(0); i++; }; i = 0; while (i < calc.length) { cube = calc[i]; var _local11 = counters; var _local12 = cube.color; var _local13 = (_local11[_local12] + 1); _local11[_local12] = _local13; i++; }; return (counters); } private function fixSingleBase(base:Cube):void{ var cube:Cube; var color:uint; if (base.posY > 0){ cube = cubes[base.posX][(base.posY - 1)]; color = cube.color; while ((((color == player.color)) || ((color == cpu.color)))) { color = randomColor(); }; cube.color = color; cube.draw(); }; if (base.posX > 0){ cube = cubes[(base.posX - 1)][base.posY]; color = cube.color; while ((((color == player.color)) || ((color == cpu.color)))) { color = randomColor(); }; cube.color = color; cube.draw(); }; if (base.posY < (countY - 1)){ cube = cubes[base.posX][(base.posY + 1)]; color = cube.color; while ((((color == player.color)) || ((color == cpu.color)))) { color = randomColor(); }; cube.color = color; cube.draw(); }; if (base.posX < (countX - 1)){ cube = cubes[(base.posX + 1)][base.posY]; color = cube.color; while ((((color == player.color)) || ((color == cpu.color)))) { color = randomColor(); }; cube.color = color; cube.draw(); }; } public function getCube(x:uint, y:uint):Cube{ return (cubes[x][y]); } private function equal(base:Cube, current:Cube, color:uint):Boolean{ return ((((base == current)) && ((color == base.color)))); } private function traceColor(color:uint):String{ switch (color){ case 0: return ("Green"); case 1: return ("Yellow"); case 2: return ("Orange"); case 3: return ("Blue"); case 4: return ("Magenta"); case 5: return ("Red"); default: return ("undefined"); }; } private function defeat():void{ icon.icon(5); } private function cpuStage1(event:TimerEvent):void{ stage1Color = makeCpuDecision(); stage1Moves = potectialMoves(cpu.id, stage1Color); var i:uint; while (i < stage1Moves.length) { (stage1Moves[i] as Cube).select(); i++; }; var timer:Timer = new Timer(250, 1); timer.addEventListener(TimerEvent.TIMER, cpuStage2); timer.start(); } private function cpuStage2(event:TimerEvent):void{ var i:uint; while (i < stage1Moves.length) { (stage1Moves[i] as Cube).unselect(); i++; }; if (stage1Color != -1){ captureTheField(cpu.id, stage1Color); }; removeChild(icon); checkGameFinish(); } private function defineColorUsingAStar(base:Cube, target:Cube):int{ var current:Cube; var posX:uint; var posY:uint; var neighbour:Cube; var check:Cube; var preLastColor:int; var lastColor:uint; var opened:Array = new Array(); var closed:Array = new Array(); if (target.player != "NONE"){ return (-1); }; base.parrent = null; base.F = 0; base.G = 0; base.H = 0; opened.push(base); while ((((opened.length > 0)) && ((opened.indexOf(target) == -1)))) { opened.sort(sortByF, Array.DESCENDING); current = opened.pop(); posX = current.posX; posY = current.posY; closed.push(current); if (current.player == "EMPTY"){ } else { neighbour = null; if (posY > 0){ processNeighbour(opened, closed, current, cubes[posX][(posY - 1)], target); }; if (posX > 0){ processNeighbour(opened, closed, current, cubes[(posX - 1)][posY], target); }; if (posY < (countY - 1)){ processNeighbour(opened, closed, current, cubes[posX][(posY + 1)], target); }; if (posX < (countX - 1)){ processNeighbour(opened, closed, current, cubes[(posX + 1)][posY], target); }; }; }; if (opened.indexOf(target) != -1){ check = target; preLastColor = -1; lastColor = target.color; while (check != null) { if (check.parrent != null){ if (lastColor != check.parrent.color){ preLastColor = lastColor; lastColor = check.parrent.color; }; }; check = check.parrent; }; return (preLastColor); }; return (-1); } private function bonusRandomColor(id:String, cube:Cube):void{ var rndColor:uint; do { rndColor = randomColor(); } while ((((rndColor == cpu.color)) || ((rndColor == player.color)))); cube.bonusType = null; captureTheField(id, rndColor); } public function draw():void{ progress.draw(); } public function checkGameFinish():void{ playerMoves = availableMoves(player.id); cpuMoves = availableMoves(cpu.id); trace(("availableMoves-player=" + playerMoves.length)); trace(("availableMoves-cpu=" + cpuMoves.length)); if ((((playerMoves.length == 0)) && (!((cpuMoves.length == 0))))){ lockedPlayer(player.id); }; if (((!((playerMoves.length == 0))) && ((cpuMoves.length == 0)))){ lockedPlayer(cpu.id); }; if ((((playerMoves.length == 0)) && ((cpuMoves.length == 0)))){ finishTheGame(); }; } public function generateBonuses():void{ var x:int; var y:int; var cube:Cube; var estimated:uint = 5; while (estimated > 0) { x = randRange((player.baseX + 1), (cpu.baseX - 1)); y = randRange((player.baseY - 1), (cpu.baseY + 1)); cube = (cubes[x][y] as Cube); if (cube.player != "EMPTY"){ cube.player = "BONUS"; cube.bonusType = "RNDCOLOR"; cube.color = 9999; cube.draw(); estimated--; }; }; } public function makeCpuDecision():int{ var idx:uint; trace("--"); var capturedColor:int = defineAStar(); var counters:Array = calculateColorStatistics(); counters[player.color] = -1; var colorsStat:Array = new Array(); var i:uint; while (i < numberOfColors) { colorsStat.push(new ColorStat(i, counters[i])); i++; }; colorsStat.sort(sortByCount, Array.DESCENDING); i = 0; while (i < colorsStat.length) { trace(((traceColor((colorsStat[i] as ColorStat).color) + ": ") + (colorsStat[i] as ColorStat).count)); i++; }; trace(("== A*: " + traceColor(capturedColor))); trace(("== Statistics: " + traceColor((colorsStat[0] as ColorStat).color))); if ((((((capturedColor == -1)) && (((colorsStat[0] as ColorStat).count > 0)))) || ((capturedColor == player.color)))){ capturedColor = (colorsStat[0] as ColorStat).color; } else { idx = 0; i = 0; while (i < colorsStat.length) { if ((colorsStat[i] as ColorStat).color == capturedColor){ idx = i; }; i++; }; }; trace(("== Final: " + traceColor(capturedColor))); return (capturedColor); } private function defineAStar():int{ var temp:Cube; var base:Cube = cubes[cpu.baseX][cpu.baseY]; var target:Cube = level.getPrimaryTarget(this); var result = -1; var alter:Array = level.getAlterTarget(this); result = defineColorUsingAStar(base, target); if (result == -1){ trace("BASE to TARGET is not found, trying ALTER"); if (target.player != "NONE"){ while (alter.length > 0) { temp = alter[randRange(0, (alter.length - 1))]; result = defineColorUsingAStar(base, temp); if (result != -1){ trace("BASE to ALTER is found"); break; } else { alter.splice(alter.indexOf(temp), 1); }; }; }; }; return (result); } private function submitScores(event:Event):void{ trace("1. submit"); dispatchEvent(new Event("submitScores")); } public function startCpuDecision():void{ icon.icon(1); addChild(icon); var timer:Timer = new Timer(250, 1); timer.addEventListener(TimerEvent.TIMER, cpuStage1); timer.start(); } private function calcScores():void{ scores = (((player.captured / totalCount) * 2000) * (1 + (0.2 * (level.getDifficult() - 1)))); } private function sortByF(a:Cube, b:Cube):Number{ if (a.F > b.F){ return (1); }; if (a.F < b.F){ return (-1); }; return (0); } private function processNeighbour(opened:Array, closed:Array, current:Cube, neighbour:Cube, targetCube:Cube):void{ var addG:int; if (closed.indexOf(neighbour) != -1){ return; }; if (opened.indexOf(neighbour) == -1){ opened.push(neighbour); neighbour.parrent = current; neighbour.H = calculateH(neighbour, targetCube); neighbour.G = ((((current.color == neighbour.color)) || ((neighbour.player == "BONUS")))) ? 10 : 20; neighbour.F = (neighbour.G + neighbour.H); } else { addG = ((((current.color == neighbour.color)) || ((neighbour.player == "BONUS")))) ? 10 : 20; if ((neighbour.G + addG) < current.G){ neighbour.parrent = current; neighbour.G = (neighbour.G + addG); neighbour.F = (neighbour.G + neighbour.H); }; }; } public function captureTheField(id:String, captureColor:int):void{ var baseX:uint; var baseY:uint; var j:uint; var temp:Cube; var notVisited:Array = new Array(); var cube:Cube; var i:uint; while (i < countX) { j = 0; while (j < countY) { cube = cubes[i][j]; cube.visited = false; j++; }; i++; }; if (id == player.id){ baseX = player.baseX; baseY = player.baseY; player.captured = 0; player.color = captureColor; } else { if (id == cpu.id){ baseX = cpu.baseX; baseY = cpu.baseY; cpu.captured = 0; cpu.color = captureColor; }; }; notVisited.push(cubes[baseX][baseY]); while (notVisited.length > 0) { cube = notVisited.pop(); if (cube.player == "BONUS"){ catchedBonus.push(cube); }; cube.player = id; cube.color = captureColor; cube.visited = true; cube.draw(); temp = null; if (cube.posY > 0){ temp = cubes[cube.posX][(cube.posY - 1)]; pushNotVisited(id, captureColor, notVisited, temp); }; if (cube.posX > 0){ temp = cubes[(cube.posX - 1)][cube.posY]; pushNotVisited(id, captureColor, notVisited, temp); }; if (cube.posY < (countY - 1)){ temp = cubes[cube.posX][(cube.posY + 1)]; pushNotVisited(id, captureColor, notVisited, temp); }; if (cube.posX < (countX - 1)){ temp = cubes[(cube.posX + 1)][cube.posY]; pushNotVisited(id, captureColor, notVisited, temp); }; }; i = 0; while (i < countX) { j = 0; while (j < countY) { if ((((id == player.id)) && (((cubes[i][j] as Cube).player == player.id)))){ player.captured++; } else { if ((((id == cpu.id)) && (((cubes[i][j] as Cube).player == cpu.id)))){ cpu.captured++; }; }; j++; }; i++; }; if (!isBonusProcessing){ processCatchedBonuses(id); }; } private function finishTheGame():void{ var message:String; var isVictory:Boolean; trace(("player.captured=" + player.captured)); trace(("cpu.captured=" + cpu.captured)); if (player.captured > cpu.captured){ victory(); } else { if (player.captured <= cpu.captured){ defeat(); }; }; addChild(icon); } private function processNeighForStat(calc:Array, opened:Array, closed:Array, neighbour:Cube):void{ if (neighbour.player == cpu.id){ if (closed.indexOf(neighbour) == -1){ opened.push(neighbour); } else { return; }; } else { if (neighbour.player == "NONE"){ if (calc.indexOf(neighbour) == -1){ calc.push(neighbour); }; } else { return; }; }; } private function fixBaseAround():void{ fixSingleBase(cubes[player.baseX][player.baseY]); fixSingleBase(cubes[cpu.baseX][cpu.baseY]); } public function potectialMoves(id:String, color:int):Array{ var j:uint; var temp:Cube; var notVisited:Array = new Array(); var potential:Array = new Array(); var cube:Cube; var i:uint; while (i < countX) { j = 0; while (j < countY) { cube = cubes[i][j]; cube.visited = false; j++; }; i++; }; if (id == player.id){ notVisited.push(cubes[player.baseX][player.baseY]); } else { if (id == cpu.id){ notVisited.push(cubes[cpu.baseX][cpu.baseY]); }; }; while (notVisited.length > 0) { cube = notVisited.pop(); cube.visited = true; if (cube.color == color){ potential.push(cube); }; temp = null; if (cube.posY > 0){ temp = cubes[cube.posX][(cube.posY - 1)]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && ((((temp.color == color)) || ((temp.player == id)))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; if (cube.posX > 0){ temp = cubes[(cube.posX - 1)][cube.posY]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && ((((temp.color == color)) || ((temp.player == id)))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; if (cube.posY < (countY - 1)){ temp = cubes[cube.posX][(cube.posY + 1)]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && ((((temp.color == color)) || ((temp.player == id)))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; if (cube.posX < (countX - 1)){ temp = cubes[(cube.posX + 1)][cube.posY]; if ((((((((notVisited.indexOf(temp) == -1)) && ((temp.visited == false)))) && ((((temp.color == color)) || ((temp.player == id)))))) && (!((temp.player == "EMPTY"))))){ notVisited.push(temp); }; }; }; return (potential); } private function close(closed:Array, cube:Cube):void{ closed.push(cube); } } }//package com.biox.cubewars.core
Section 5
//Icon (com.biox.cubewars.core.Icon) package com.biox.cubewars.core { import flash.events.*; import flash.display.*; public class Icon extends Sprite { private var icons:Icons; public function Icon(){ icons = new Icons(); super(); icons.addEventListener("replayGame", function ():void{ trace("0. replay"); dispatchEvent(new Event("replayGame")); }); icons.addEventListener("submitScores", function ():void{ trace("0. submit"); dispatchEvent(new Event("submitScores")); }); addChild(icons); } public function icon(value:uint):void{ icons.gotoAndStop(value); } } }//package com.biox.cubewars.core
Section 6
//Player (com.biox.cubewars.core.Player) package com.biox.cubewars.core { public class Player { public var color:uint; public var captured:uint;// = 0 public var baseX:uint; public var baseY:uint; public var id:String; public function Player(id:String, color:uint, baseX:uint, baseY:uint){ super(); this.id = id; this.color = color; this.baseX = baseX; this.baseY = baseY; } } }//package com.biox.cubewars.core
Section 7
//ProgressLine (com.biox.cubewars.core.ProgressLine) package com.biox.cubewars.core { import flash.display.*; import flash.text.*; public class ProgressLine extends Sprite { private var scoresPlayer:TextField;// = null private var line:Array;// = null private var scoresCPU:TextField; private var field:Field;// = null public function ProgressLine(field:Field){ scoresCPU = new TextField(); super(); this.field = field; this.init(); this.draw(); } private function init():void{ var progress:Progress; line = new Array(); var i:uint; while (i < 20) { progress = new Progress(); progress.frameNum = 0; progress.x = ((this.x + 105) + (10 * i)); progress.y = (this.y + 10); line.push(progress); addChild(progress); i++; }; var player:Progress = new Progress(); player.frameNum = 3; player.x = (this.x + 85); player.y = (this.y + 10); addChild(player); var cpu:Progress = new Progress(); cpu.x = (this.x + 315); cpu.y = (this.y + 10); cpu.frameNum = 4; addChild(cpu); scoresPlayer = new TextField(); var playerFormat:TextFormat = new TextFormat(); playerFormat.align = "right"; playerFormat.bold = true; scoresPlayer.defaultTextFormat = playerFormat; scoresPlayer.selectable = false; scoresPlayer.x = this.x; scoresPlayer.y = this.y; scoresPlayer.width = 75; scoresPlayer.height = 20; scoresPlayer.textColor = 16742263; var cpuFormat:TextFormat = new TextFormat(); cpuFormat.align = "left"; cpuFormat.bold = true; scoresCPU.defaultTextFormat = cpuFormat; scoresCPU.selectable = false; scoresCPU.x = (this.x + 330); scoresCPU.y = this.y; scoresCPU.width = 80; scoresCPU.height = 20; scoresCPU.textColor = 10932731; addChild(scoresPlayer); addChild(scoresCPU); } public function draw():void{ var playerPercents:Number = ((field.player.captured / field.totalCount) * 100); var cpuPercents:Number = ((field.cpu.captured / field.totalCount) * 100); var playerElements:uint = Math.round((playerPercents / 5)); var cpuElements:uint = Math.round((cpuPercents / 5)); var i:uint; while (i < 20) { if (i < playerElements){ (line[i] as Progress).frameNum = 1; } else { if (i < (20 - cpuElements)){ (line[i] as Progress).frameNum = 0; } else { (line[i] as Progress).frameNum = 2; }; }; i++; }; scoresPlayer.text = (Math.round(playerPercents) + "%"); scoresCPU.text = (Math.round(cpuPercents) + "%"); } } }//package com.biox.cubewars.core
Section 8
//Game (com.biox.cubewars.game.Game) package com.biox.cubewars.game { import flash.events.*; import flash.display.*; import com.biox.cubewars.core.*; public class Game extends Sprite { private var field:Field;// = null private var level:Level; public function Game(lev:uint, difficult:uint){ super(); trace(((("New game: level=" + lev) + ", difficult=") + difficult)); switch (lev){ case 1: level = new Level1(difficult); break; case 2: level = new Level2(difficult); break; case 3: level = new Level3(difficult); break; case 4: level = new Level4(difficult); break; case 5: level = new Level5(difficult); break; }; } public function start():void{ field = new Field(level); field.x = 20; field.y = 40; field.addEventListener("replayGame", function ():void{ trace("2. replay"); dispatchEvent(new Event("replayGame")); }); field.addEventListener("submitScores", function ():void{ trace("2. submit"); dispatchEvent(new Event("submitScores")); }); addChild(field); } public function finish():void{ } public function getScores():uint{ return (field.scores); } public function getLevel():Level{ return (level); } } }//package com.biox.cubewars.game
Section 9
//Level (com.biox.cubewars.game.Level) package com.biox.cubewars.game { import com.biox.cubewars.core.*; public interface Level { function getAlterTarget(com.biox.cubewars.game:Level/com.biox.cubewars.game:Level:getCPU:Field):Array; function getCPU():Player; function generateField(com.biox.cubewars.game:Level/com.biox.cubewars.game:Level:getPlayer:Field):void; function getPlayer():Player; function getDifficult():uint; function getPrimaryTarget(Player:Field):Cube; } }//package com.biox.cubewars.game
Section 10
//Level1 (com.biox.cubewars.game.Level1) package com.biox.cubewars.game { import com.biox.cubewars.core.*; public class Level1 implements Level { private var difficult:uint; public function Level1(difficult:uint){ super(); this.difficult = difficult; } public function getDifficult():uint{ return (difficult); } public function generateField(field:Field):void{ var row:Array; var j:uint; var cube:Cube; field.cubes = new Array(); var i:uint; while (i < field.countX) { row = new Array(); j = 0; while (j < field.countY) { cube = null; if ((((i == field.player.baseX)) && ((j == field.player.baseY)))){ cube = new Cube(field, i, j, field.player.color, field.player.id); cube.isBase = true; } else { if ((((i == field.cpu.baseX)) && ((j == field.cpu.baseY)))){ cube = new Cube(field, i, j, field.cpu.color, field.cpu.id); cube.isBase = true; } else { cube = new Cube(field, i, j, field.randomColor(), "NONE"); }; }; row.push(cube); field.addChild(cube); j++; }; field.cubes.push(row); i++; }; } public function getAlterTarget(field:Field):Array{ var alter:Array = new Array(); alter.push(field.cubes[0][9]); alter.push(field.cubes[15][19]); return (alter); } public function getCPU():Player{ var player:Player; switch (difficult){ case 1: player = new Player("CPU", 3, 29, 0); break; case 2: player = new Player("CPU", 3, 28, 1); break; case 3: player = new Player("CPU", 3, 27, 2); break; case 4: player = new Player("CPU", 3, 25, 4); break; }; return (player); } public function getPlayer():Player{ return (new Player("PLAYER", 5, 0, 19)); } public function getPrimaryTarget(field:Field):Cube{ return (field.cubes[15][11]); } } }//package com.biox.cubewars.game
Section 11
//Level2 (com.biox.cubewars.game.Level2) package com.biox.cubewars.game { import com.biox.cubewars.core.*; public class Level2 implements Level { private var difficult:uint; public function Level2(difficult:uint){ super(); this.difficult = difficult; } public function getDifficult():uint{ return (difficult); } public function generateField(field:Field):void{ var row:Array; var j:uint; var cube:Cube; field.cubes = new Array(); var i:uint; while (i < field.countX) { row = new Array(); j = 0; while (j < field.countY) { cube = null; if ((((i == field.player.baseX)) && ((j == field.player.baseY)))){ cube = new Cube(field, i, j, field.player.color, field.player.id); cube.isBase = true; } else { if ((((i == field.cpu.baseX)) && ((j == field.cpu.baseY)))){ cube = new Cube(field, i, j, field.cpu.color, field.cpu.id); cube.isBase = true; } else { if ((((((((i >= 13)) && ((i <= 16)))) && ((j >= 0)))) && ((j <= 5)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((((((i >= 13)) && ((i <= 16)))) && ((j >= 14)))) && ((j <= 19)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { cube = new Cube(field, i, j, field.randomColor(), "NONE"); }; }; }; }; row.push(cube); field.addChild(cube); j++; }; field.cubes.push(row); i++; }; trace(); } public function getAlterTarget(field:Field):Array{ var alter:Array = new Array(); alter.push(field.cubes[0][9]); alter.push(field.cubes[12][19]); return (alter); } public function getCPU():Player{ var player:Player; switch (difficult){ case 1: player = new Player("CPU", 3, 29, 0); break; case 2: player = new Player("CPU", 3, 28, 1); break; case 3: player = new Player("CPU", 3, 27, 2); break; case 4: player = new Player("CPU", 3, 25, 4); break; }; return (player); } public function getPlayer():Player{ return (new Player("PLAYER", 5, 0, 19)); } public function getPrimaryTarget(field:Field):Cube{ return (field.cubes[15][11]); } } }//package com.biox.cubewars.game
Section 12
//Level3 (com.biox.cubewars.game.Level3) package com.biox.cubewars.game { import com.biox.cubewars.core.*; public class Level3 implements Level { private var difficult:uint; public function Level3(difficult:uint){ super(); this.difficult = difficult; } public function getDifficult():uint{ return (difficult); } public function generateField(field:Field):void{ var row:Array; var j:uint; var cube:Cube; field.cubes = new Array(); var i:uint; while (i < field.countX) { row = new Array(); j = 0; while (j < field.countY) { cube = null; if ((((i == field.player.baseX)) && ((j == field.player.baseY)))){ cube = new Cube(field, i, j, field.player.color, field.player.id); cube.isBase = true; } else { if ((((i == field.cpu.baseX)) && ((j == field.cpu.baseY)))){ cube = new Cube(field, i, j, field.cpu.color, field.cpu.id); cube.isBase = true; } else { if ((((i == 12)) && ((j >= 2)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((i == 17)) && ((j <= 17)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { cube = new Cube(field, i, j, field.randomColor(), "NONE"); }; }; }; }; row.push(cube); field.addChild(cube); j++; }; field.cubes.push(row); i++; }; } public function getAlterTarget(field:Field):Array{ var alter:Array = new Array(); alter.push(field.cubes[0][9]); alter.push(field.cubes[15][19]); return (alter); } public function getCPU():Player{ var player:Player; switch (difficult){ case 1: player = new Player("CPU", 3, 29, 0); break; case 2: player = new Player("CPU", 3, 28, 1); break; case 3: player = new Player("CPU", 3, 27, 2); break; case 4: player = new Player("CPU", 3, 25, 4); break; }; return (player); } public function getPlayer():Player{ return (new Player("PLAYER", 5, 0, 19)); } public function getPrimaryTarget(field:Field):Cube{ return (field.cubes[17][19]); } } }//package com.biox.cubewars.game
Section 13
//Level4 (com.biox.cubewars.game.Level4) package com.biox.cubewars.game { import com.biox.cubewars.core.*; public class Level4 implements Level { private var difficult:uint; public function Level4(difficult:uint){ super(); this.difficult = difficult; } public function getDifficult():uint{ return (difficult); } public function generateField(field:Field):void{ var row:Array; var j:uint; var cube:Cube; field.cubes = new Array(); var i:uint; while (i < field.countX) { row = new Array(); j = 0; while (j < field.countY) { cube = null; if ((((i == field.player.baseX)) && ((j == field.player.baseY)))){ cube = new Cube(field, i, j, field.player.color, field.player.id); cube.isBase = true; } else { if ((((i == field.cpu.baseX)) && ((j == field.cpu.baseY)))){ cube = new Cube(field, i, j, field.cpu.color, field.cpu.id); cube.isBase = true; } else { if ((((((((i >= 8)) && ((i <= 10)))) && ((j >= 2)))) && ((j <= 4)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((((((i >= 19)) && ((i <= 21)))) && ((j >= 2)))) && ((j <= 4)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((((((i >= 14)) && ((i <= 15)))) && ((j >= 5)))) && ((j <= 9)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((((((i >= 13)) && ((i <= 16)))) && ((j >= 14)))) && ((j <= 15)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((i == 10)) && ((j == 12)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((i == 11)) && ((j == 13)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((i == 12)) && ((j == 14)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((i == 17)) && ((j == 14)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((i == 18)) && ((j == 13)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((i == 19)) && ((j == 12)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { cube = new Cube(field, i, j, field.randomColor(), "NONE"); }; }; }; }; }; }; }; }; }; }; }; }; row.push(cube); field.addChild(cube); j++; }; field.cubes.push(row); i++; }; } public function getAlterTarget(field:Field):Array{ var alter:Array = new Array(); alter.push(field.cubes[14][9]); return (alter); } public function getCPU():Player{ var player:Player; switch (difficult){ case 1: player = new Player("CPU", 3, 29, 0); break; case 2: player = new Player("CPU", 3, 28, 1); break; case 3: player = new Player("CPU", 3, 27, 2); break; case 4: player = new Player("CPU", 3, 25, 4); break; }; return (player); } public function getPlayer():Player{ return (new Player("PLAYER", 5, 0, 19)); } public function getPrimaryTarget(field:Field):Cube{ return (field.cubes[15][11]); } } }//package com.biox.cubewars.game
Section 14
//Level5 (com.biox.cubewars.game.Level5) package com.biox.cubewars.game { import com.biox.cubewars.core.*; public class Level5 implements Level { private var difficult:uint; public function Level5(difficult:uint){ super(); this.difficult = difficult; } public function getDifficult():uint{ return (difficult); } public function generateField(field:Field):void{ var row:Array; var j:uint; var cube:Cube; field.cubes = new Array(); var i:uint; while (i < field.countX) { row = new Array(); j = 0; while (j < field.countY) { cube = null; if ((((i == field.player.baseX)) && ((j == field.player.baseY)))){ cube = new Cube(field, i, j, field.player.color, field.player.id); cube.isBase = true; } else { if ((((i == field.cpu.baseX)) && ((j == field.cpu.baseY)))){ cube = new Cube(field, i, j, field.cpu.color, field.cpu.id); cube.isBase = true; } else { if ((((((i >= 6)) && ((i <= 23)))) && ((j == 5)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { if ((((((i >= 6)) && ((i <= 23)))) && ((j == 14)))){ cube = new Cube(field, i, j, 0, "EMPTY"); } else { cube = new Cube(field, i, j, field.randomColor(), "NONE"); }; }; }; }; row.push(cube); field.addChild(cube); j++; }; field.cubes.push(row); i++; }; } public function getAlterTarget(field:Field):Array{ var alter:Array = new Array(); alter.push(field.cubes[0][9]); return (alter); } public function getCPU():Player{ var player:Player; switch (difficult){ case 1: player = new Player("CPU", 3, 29, 0); break; case 2: player = new Player("CPU", 3, 28, 1); break; case 3: player = new Player("CPU", 3, 27, 2); break; case 4: player = new Player("CPU", 3, 25, 4); break; }; return (player); } public function getPlayer():Player{ return (new Player("PLAYER", 5, 0, 19)); } public function getPrimaryTarget(field:Field):Cube{ return (field.cubes[15][11]); } } }//package com.biox.cubewars.game
Section 15
//ButtonDifficulty_5 (Menu_fla.ButtonDifficulty_5) package Menu_fla { import flash.events.*; import flash.display.*; import flash.text.*; public dynamic class ButtonDifficulty_5 extends MovieClip { public var butRight:SimpleButton; public var butCenter:SimpleButton; public var butLeft:SimpleButton; public var difficulty:uint; public var textDifficulty:TextField; public function ButtonDifficulty_5(){ addFrameScript(0, frame1); } public function incDifficulty():void{ if (difficulty == 4){ difficulty = 1; } else { difficulty++; }; updateDifficulty(difficulty); } public function decDifficulty():void{ if (difficulty == 1){ difficulty = 4; } else { difficulty--; }; updateDifficulty(difficulty); } public function updateDifficulty(_arg1:uint):void{ difficulty = _arg1; switch (_arg1){ case 1: textDifficulty.text = "EASY"; break; case 2: textDifficulty.text = "NORMAL"; break; case 3: textDifficulty.text = "HARD"; break; case 4: textDifficulty.text = "UNREAL"; break; }; } public function butCenterMouseOver(_arg1:MouseEvent):void{ textDifficulty.textColor = 6750054; } function frame1(){ difficulty = 2; butCenter.addEventListener(MouseEvent.MOUSE_OVER, butCenterMouseOver); butCenter.addEventListener(MouseEvent.MOUSE_OUT, butCenterMouseOut); butLeft.addEventListener(MouseEvent.CLICK, function (){ decDifficulty(); }); butCenter.addEventListener(MouseEvent.CLICK, function (){ incDifficulty(); }); butRight.addEventListener(MouseEvent.CLICK, function (){ incDifficulty(); }); } public function getDifficulty():uint{ return (difficulty); } public function butCenterMouseOut(_arg1:MouseEvent):void{ textDifficulty.textColor = 16777113; } } }//package Menu_fla
Section 16
//MochiAd (mochi.as3.MochiAd) package mochi.as3 { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.net.*; import flash.system.*; public class MochiAd { public function MochiAd(){ super(); } public static function getVersion():String{ return (MochiServices.getVersion()); } 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 (!(clip is DisplayObject)){ trace("Warning: Object passed as container clip not a descendant of the DisplayObject type"); return (null); }; if (MovieClip(clip).stage == null){ trace("Warning: Container clip for ad is not attached to the stage"); return (null); }; 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"); }); if (!options.skip){ 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{ }, progress_override:function (_clip:Object):Number{ return (NaN); }, bar_offset:0}; 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; if (options.skip){ ad_timeout = 0; }; 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 + options.bar_offset); bar.y = (h - 20); }; var bar_w:Number = ((w - bar.x) - 10); 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(bar_w, 0); backing.lineTo(bar_w, 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(bar_w, 0); inside.lineTo(bar_w, 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(bar_w, 0); outline.lineTo(bar_w, 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 progress:Number = Math.min(1, options.progress_override(clip)); var f:Function = function (ev:Event):void{ ev.target.removeEventListener(ev.type, arguments.callee); complete = true; if (unloaded){ MochiAd.unload(clip); }; }; if (!isNaN(progress)){ complete = (progress == 1); } else { 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; var clip_progress:Number = Math.min(1, options.progress_override(_clip)); if (clip_progress == 1){ complete = true; }; if (complete){ clip_loaded = Math.max(1, clip_loaded); clip_total = clip_loaded; }; var clip_pcnt:Number = ((100 * clip_loaded) / clip_total); if (!isNaN(clip_progress)){ clip_pcnt = (100 * clip_progress); }; 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 (unloaded){ MochiAd.unload(_clip); } else { 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.as3
Section 17
//MochiCoins (mochi.as3.MochiCoins) package mochi.as3 { public class MochiCoins { public static const STORE_HIDE:String = "StoreHide"; public static const LOGGED_IN:String = "LoggedIn"; public static const NO_USER:String = "NoUser"; public static const PROPERTIES_SIZE:String = "PropertiesSize"; public static const IO_ERROR:String = "IOError"; public static const STORE_ITEMS:String = "StoreItems"; public static const USER_INFO:String = "UserInfo"; public static const LOGIN_SHOW:String = "LoginShow"; public static const PROFILE_HIDE:String = "ProfileHide"; public static const STORE_SHOW:String = "StoreShow"; public static const ITEM_NEW:String = "ItemNew"; public static const ITEM_OWNED:String = "ItemOwned"; public static const PROPERTIES_SAVED:String = "PropertySaved"; public static const WIDGET_LOADED:String = "WidgetLoaded"; public static const ERROR:String = "Error"; public static const LOGGED_OUT:String = "LoggedOut"; public static const PROFILE_SHOW:String = "ProfileShow"; public static const LOGIN_HIDE:String = "LoginHide"; public static const LOGIN_SHOWN:String = "LoginShown"; public static var _user_info:Object = null; private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher(); public static var _inventory:MochiInventory; public function MochiCoins(){ super(); } public static function getUserInfo():void{ MochiServices.send("coins_getUserInfo"); } public static function requestLogin():void{ MochiServices.send("coins_requestLogin"); } public static function showItem(options:Object=null):void{ if (((!(options)) || (!((typeof(options.item) == "string"))))){ trace("ERROR: showItem call must pass an Object with an item key"); return; }; MochiServices.bringToTop(); MochiServices.send("coins_showItem", {options:options}, null, null); } public static function saveUserProperties(properties:Object):void{ MochiServices.send("coins_saveUserProperties", properties); } public static function get loggedIn():Boolean{ return (!((_user_info == null))); } public static function triggerEvent(eventType:String, args:Object):void{ if (eventType == LOGGED_IN){ _inventory = new MochiInventory(); _user_info = args; } else { if (eventType == LOGGED_OUT){ if (inventory){ _inventory.release(); _inventory = null; }; _user_info = null; }; }; _dispatcher.triggerEvent(eventType, args); } public static function removeEventListener(eventType:String, delegate:Function):void{ _dispatcher.removeEventListener(eventType, delegate); } public static function getVersion():String{ return (MochiServices.getVersion()); } public static function getStoreItems():void{ MochiServices.send("coins_getStoreItems"); } public static function showLoginWidget(options:Object=null):void{ MochiServices.setContainer(); MochiServices.bringToTop(); MochiServices.send("coins_showLoginWidget", {options:options}); } public static function get inventory():MochiInventory{ return (_inventory); } public static function showStore(options:Object=null):void{ MochiServices.bringToTop(); MochiServices.send("coins_showStore", {options:options}, null, null); } public static function addEventListener(eventType:String, delegate:Function):void{ _dispatcher.addEventListener(eventType, delegate); } 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); } public static function showVideo(options:Object=null):void{ if (((!(options)) || (!((typeof(options.item) == "string"))))){ trace("ERROR: showVideo call must pass an Object with an item key"); return; }; MochiServices.bringToTop(); MochiServices.send("coins_showVideo", {options:options}, null, null); } } }//package mochi.as3
Section 18
//MochiDigits (mochi.as3.MochiDigits) package mochi.as3 { public final class MochiDigits { private var Sibling:MochiDigits; private var Fragment:Number; private var Encoder:Number; public function MochiDigits(digit:Number=0, index:uint=0):void{ super(); Encoder = 0; setValue(digit, index); } public function reencode():void{ var newEncode:uint = int((2147483647 * Math.random())); Fragment = (Fragment ^ (newEncode ^ Encoder)); Encoder = newEncode; } public function set value(v:Number):void{ setValue(v); } public function toString():String{ var s:String = String.fromCharCode((Fragment ^ Encoder)); if (Sibling != null){ s = (s + Sibling.toString()); }; return (s); } public function setValue(digit:Number=0, index:uint=0):void{ var s:String = digit.toString(); var _temp1 = index; index = (index + 1); Fragment = (s.charCodeAt(_temp1) ^ Encoder); if (index < s.length){ Sibling = new MochiDigits(digit, index); } else { Sibling = null; }; reencode(); } public function get value():Number{ return (Number(this.toString())); } public function addValue(inc:Number):void{ value = (value + inc); } } }//package mochi.as3
Section 19
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher) package mochi.as3 { public class MochiEventDispatcher { private var eventTable:Object; public function MochiEventDispatcher():void{ super(); eventTable = {}; } public function triggerEvent(event:String, args:Object):void{ var i:Object; if (eventTable[event] == undefined){ return; }; for (i in eventTable[event]) { var _local6 = eventTable[event]; _local6[i](args); }; } public function removeEventListener(event:String, delegate:Function):void{ var s:Object; if (eventTable[event] == undefined){ eventTable[event] = []; return; }; for (s in eventTable[event]) { if (eventTable[event][s] != delegate){ } else { eventTable[event].splice(Number(s), 1); }; }; } public function addEventListener(event:String, delegate:Function):void{ removeEventListener(event, delegate); eventTable[event].push(delegate); } } }//package mochi.as3
Section 20
//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 function MochiEvents(){ super(); } public static function addEventListener(eventType:String, delegate:Function):void{ _dispatcher.addEventListener(eventType, delegate); } public static function removeEventListener(eventType:String, delegate:Function):void{ _dispatcher.removeEventListener(eventType, delegate); } public static function startSession(achievementID:String):void{ MochiServices.send("events_beginSession", {achievementID:achievementID}, null, null); } public static function triggerEvent(eventType:String, args:Object):void{ _dispatcher.triggerEvent(eventType, args); } public static function setNotifications(clip:MovieClip, style:Object):void{ var s:Object; var args:Object = {}; for (s in style) { args[s] = style[s]; }; args.clip = clip; MochiServices.send("events_setNotifications", args, null, null); } public static function endGame():void{ var delta:Number = (new Date().time - gameStart); trigger("end_game", {time:delta}); } public static function startGame():void{ gameStart = new Date().time; trigger("start_game"); } public static function trigger(kind:String, obj:Object=null):void{ if (obj == null){ obj = {}; } else { if (obj["kind"] != undefined){ trace("WARNING: optional arguments package contains key 'id', it will be overwritten"); obj["kind"] = kind; }; }; MochiServices.send("events_triggerEvent", {eventObject:obj}, 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 delta:Number = (new Date().time - levelStart); trigger("end_level", {time:delta}); } } }//package mochi.as3
Section 21
//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 _syncID:Number; private var _consumableProperties: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 CONSUMER_KEY:String = "MochiConsumables"; public static const WRITTEN:String = "InvWritten"; public static const NOT_READY:String = "InvNotReady"; public static const VALUE_ERROR:String = "InvValueError"; private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher(); public function MochiInventory():void{ super(); MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems); MochiCoins.addEventListener(MochiCoins.LOGGED_IN, loggedIn); MochiCoins.addEventListener(MochiCoins.LOGGED_OUT, loggedOut); _syncPending = false; _outstandingID = 0; _syncID = 0; _timer = new Timer(1000); _timer.addEventListener(TimerEvent.TIMER, sync); _timer.start(); if (MochiCoins.loggedIn){ loggedIn(); } else { loggedOut(); }; } private function newItems(event:Object):void{ this[event.id] = (this[event.id] + event.count); } public function release():void{ MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems); MochiCoins.removeEventListener(MochiCoins.LOGGED_IN, loggedIn); MochiCoins.removeEventListener(MochiCoins.LOGGED_OUT, loggedOut); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){ if (_consumableProperties == null){ triggerEvent(ERROR, {type:NOT_READY}); return (-1); }; if (_consumableProperties[name]){ return (MochiDigits(_consumableProperties[name]).value); }; return (undefined); } private function loggedIn(args:Object=null):void{ MochiUserData.get(CONSUMER_KEY, getConsumableBag); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(name):Boolean{ if (_consumableProperties == null){ triggerEvent(ERROR, {type:NOT_READY}); return (false); }; if (_consumableProperties[name] == undefined){ return (false); }; return (true); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(index:int):int{ return (((index)>=_names.length) ? 0 : (index + 1)); } private function putConsumableBag(userData:MochiUserData):void{ _syncPending = false; if (userData.error){ triggerEvent(ERROR, {type:IO_ERROR, error:userData.error}); _outstandingID = -1; }; triggerEvent(WRITTEN, {}); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{ var d:MochiDigits; if (_consumableProperties == null){ triggerEvent(ERROR, {type:NOT_READY}); return; }; if (!(value is Number)){ triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:value}); return; }; if (_consumableProperties[name]){ d = MochiDigits(_consumableProperties[name]); if (d.value == value){ return; }; d.value = value; } else { _names.push(name); _consumableProperties[name] = new MochiDigits(value); }; _syncID++; } private function sync(e:Event=null):void{ var key:String; if (((_syncPending) || ((_syncID == _outstandingID)))){ return; }; _outstandingID = _syncID; var output:Object = {}; for (key in _consumableProperties) { output[key] = MochiDigits(_consumableProperties[key]).value; }; MochiUserData.put(CONSUMER_KEY, output, putConsumableBag); _syncPending = true; } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(index:int):String{ return (_names[(index - 1)]); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(name):Boolean{ if (!_consumableProperties[name]){ return (false); }; _names.splice(_names.indexOf(name), 1); delete _consumableProperties[name]; return (true); } private function getConsumableBag(userData:MochiUserData):void{ var key:String; if (userData.error){ triggerEvent(ERROR, {type:IO_ERROR, error:userData.error}); return; }; _consumableProperties = {}; _names = new Array(); if (userData.data){ for (key in userData.data) { _names.push(key); _consumableProperties[key] = new MochiDigits(userData.data[key]); }; }; triggerEvent(READY, {}); } private function loggedOut(args:Object=null):void{ _consumableProperties = null; } public static function triggerEvent(eventType:String, args:Object):void{ _dispatcher.triggerEvent(eventType, args); } public static function removeEventListener(eventType:String, delegate:Function):void{ _dispatcher.removeEventListener(eventType, delegate); } public static function addEventListener(eventType:String, delegate:Function):void{ _dispatcher.addEventListener(eventType, delegate); } } }//package mochi.as3
Section 22
//MochiScores (mochi.as3.MochiScores) package mochi.as3 { import flash.display.*; import flash.text.*; public class MochiScores { private static var boardID:String; public static var onErrorHandler:Object; public static var onCloseHandler:Object; public function MochiScores(){ super(); } public static function showLeaderboard(options:Object=null):void{ var n:Number; var options = options; if (options != null){ 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(callbackObj:Object, callbackMethod:Object=null):void{ MochiServices.send("scores_getPlayerInfo", null, callbackObj, callbackMethod); } public static function requestList(callbackObj:Object, callbackMethod:Object=null):void{ MochiServices.send("scores_requestList", null, callbackObj, callbackMethod); } public static function scoresArrayToObjects(scores:Object):Object{ var i:Number; var j:Number; var o:Object; var row_obj:Object; var item:String; var param:String; var so:Object = {}; for (item in scores) { if (typeof(scores[item]) == "object"){ if (((!((scores[item].cols == null))) && (!((scores[item].rows == null))))){ so[item] = []; o = scores[item]; j = 0; while (j < o.rows.length) { row_obj = {}; i = 0; while (i < o.cols.length) { row_obj[o.cols[i]] = o.rows[j][i]; i++; }; so[item].push(row_obj); j++; }; } else { so[item] = {}; for (param in scores[item]) { so[item][param] = scores[item][param]; }; }; } else { so[item] = scores[item]; }; }; return (so); } public static function submit(score:Number, name:String, callbackObj:Object=null, callbackMethod:Object=null):void{ score = Number(score); if (isNaN(score)){ trace((("ERROR: Submitted score '" + String(score)) + "' will be rejected, score is 'Not a Number'")); } else { if ((((score == Number.NEGATIVE_INFINITY)) || ((score == Number.POSITIVE_INFINITY)))){ trace((("ERROR: Submitted score '" + String(score)) + "' will be rejected, score is an infinite")); } else { if (Math.floor(score) != score){ trace((("WARNING: Submitted score '" + String(score)) + "' will be truncated")); }; score = Number(score); }; }; MochiServices.send("scores_submit", {score:score, name:name}, callbackObj, callbackMethod); } public static function onClose(args:Object=null):void{ if (((((args) && ((args.error == true)))) && (onErrorHandler))){ if (args.errorCode == null){ args.errorCode = "IOError"; }; onErrorHandler(args.errorCode); MochiServices.doClose(); return; }; onCloseHandler(); MochiServices.doClose(); } public static function setBoardID(boardID:String):void{ MochiServices.warnID(boardID, true); MochiScores.boardID = boardID; MochiServices.send("scores_setBoardID", {boardID:boardID}); } } }//package mochi.as3
Section 23
//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 function MochiServices(){ super(); } public static function isNetworkAvailable():Boolean{ return (!((Security.sandboxType == "localWithFile"))); } public static function get connected():Boolean{ return (_connected); } private static function onReceive(pkg:Object):void{ var methodName:String; var pkg = pkg; var cb:String = pkg.callbackID; var cblst:Object = _clip._callbacks[cb]; if (!cblst){ return; }; var method:* = cblst.callbackMethod; methodName = ""; var obj:Object = cblst.callbackObject; if (((obj) && ((typeof(method) == "string")))){ methodName = method; if (obj[method] != null){ method = obj[method]; } else { trace((("Error: Method " + method) + " does not exist.")); }; }; if (method != undefined){ method.apply(obj, pkg.args); //unresolved jump var _slot1 = error; trace(((("Error invoking callback method '" + methodName) + "': ") + _slot1.toString())); } else { if (obj != null){ obj(pkg.args); //unresolved jump var _slot1 = error; trace(("Error invoking method on object: " + _slot1.toString())); }; }; delete _clip._callbacks[cb]; } public static function get childClip():Object{ return (_clip); } public static function send(methodName:String, args:Object=null, callbackObject:Object=null, callbackMethod:Object=null):void{ if (_connected){ _mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:methodName, args:args, callbackID:_clip._nextcallbackID}); } else { if ((((_clip == null)) || (!(_connecting)))){ trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + methodName)); handleError(args, callbackObject, callbackMethod); flush(true); return; }; _clip._queue.push({methodName:methodName, args:args, callbackID:_clip._nextcallbackID}); }; if (_clip != null){ if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){ _clip._callbacks[_clip._nextcallbackID] = {callbackObject:callbackObject, callbackMethod:callbackMethod}; _clip._nextcallbackID++; }; }; } private static function init(id:String, clip:Object):void{ _id = id; if (clip != null){ _container = clip; loadCommunicator(id, _container); }; } private static function clickMovie(url:String, cb:Function):MovieClip{ var b:int; var loader:Loader; var avm1_bytecode:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23]; var header:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3]; var footer:Array = [0, 64, 0, 0, 0]; var mc:MovieClip = new MovieClip(); var lc:LocalConnection = new LocalConnection(); var lc_name:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time)); lc = new LocalConnection(); mc.lc = lc; mc.click = cb; lc.client = mc; lc.connect(lc_name); var ba:ByteArray = new ByteArray(); var cpool:ByteArray = new ByteArray(); cpool.endian = Endian.LITTLE_ENDIAN; cpool.writeShort(1); cpool.writeUTFBytes(((url + " ") + lc_name)); cpool.writeByte(0); var actionLength:uint = ((avm1_bytecode.length + cpool.length) + 4); var fileLength:uint = (actionLength + 35); ba.endian = Endian.LITTLE_ENDIAN; ba.writeUTFBytes("FWS"); ba.writeByte(8); ba.writeUnsignedInt(fileLength); for each (b in header) { ba.writeByte(b); }; ba.writeUnsignedInt(actionLength); ba.writeByte(136); ba.writeShort(cpool.length); ba.writeBytes(cpool); for each (b in avm1_bytecode) { ba.writeByte(b); }; for each (b in footer) { ba.writeByte(b); }; loader = new Loader(); loader.loadBytes(ba); mc.addChild(loader); return (mc); } public static function stayOnTop():void{ _container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true); if (_clip != null){ _clip.visible = true; }; } public static function addLinkEvent(url:String, burl:String, btn:DisplayObjectContainer, onClick:Function=null):void{ var avm1Click:DisplayObject; var x:String; var req:URLRequest; var loader:Loader; var setURL:Function; var err:Function; var complete:Function; var url = url; var burl = burl; var btn = btn; var onClick = onClick; var vars:Object = new Object(); vars["mav"] = getVersion(); vars["swfv"] = "9"; vars["swfurl"] = btn.loaderInfo.loaderURL; vars["fv"] = Capabilities.version; vars["os"] = Capabilities.os; vars["lang"] = Capabilities.language; vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY); var s = "?"; var i:Number = 0; for (x in vars) { if (i != 0){ s = (s + "&"); }; i = (i + 1); s = (((s + x) + "=") + escape(vars[x])); }; req = new URLRequest("http://x.mochiads.com/linkping.swf"); loader = new Loader(); setURL = function (url:String):void{ if (avm1Click){ btn.removeChild(avm1Click); }; avm1Click = clickMovie(url, onClick); var rect:Rectangle = btn.getBounds(btn); btn.addChild(avm1Click); avm1Click.x = rect.x; avm1Click.y = rect.y; avm1Click.scaleX = (0.01 * rect.width); avm1Click.scaleY = (0.01 * rect.height); }; err = function (ev:Object):void{ netup = false; ev.target.removeEventListener(ev.type, arguments.callee); setURL(burl); }; complete = function (ev:Object):void{ ev.target.removeEventListener(ev.type, arguments.callee); }; if (netup){ setURL((url + s)); } else { setURL(burl); }; if (!((netupAttempted) || (_connected))){ netupAttempted = true; loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete); loader.load(req); }; } public static function warnID(bid:String, leaderboard:Boolean):void{ bid = bid.toLowerCase(); if (bid.length != 16){ trace((("WARNING: " + (leaderboard) ? "board" : "game") + " ID is not the appropriate length")); return; } else { if (bid == "1e113c7239048b3f"){ if (leaderboard){ trace("WARNING: Using testing board ID"); } else { trace("WARNING: Using testing board ID as game ID"); }; return; } else { if (bid == "84993a1de4031cd8"){ if (leaderboard){ trace("WARNING: Using testing game ID as board ID"); } else { trace("WARNING: Using testing game ID"); }; return; }; }; }; var i:Number = 0; while (i < bid.length) { switch (bid.charAt(i)){ case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": case "a": case "b": case "c": case "d": case "e": case "f": break; default: trace(("WARNING: Board ID contains illegal characters: " + bid)); return; }; i++; }; } public static function disconnect():void{ if (((_connected) || (_connecting))){ if (_clip != null){ if (_clip.parent != null){ if ((_clip.parent is Sprite)){ Sprite(_clip.parent).removeChild(_clip); _clip = null; }; }; }; _connecting = (_connected = false); flush(true); _mochiLocalConnection.close(); //unresolved jump var _slot1 = error; }; if (_timer != null){ _timer.stop(); //unresolved jump var _slot1 = error; }; } public static function allowDomains(server:String):String{ var hostname:String; if (Security.sandboxType != "application"){ Security.allowDomain("*"); Security.allowInsecureDomain("*"); }; if (server.indexOf("http://") != -1){ hostname = server.split("/")[2].split(":")[0]; if (Security.sandboxType != "application"){ Security.allowDomain(hostname); Security.allowInsecureDomain(hostname); }; }; return (hostname); } public static function getVersion():String{ return ("3.4 as3"); } public static function doClose():void{ _container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop); } private static function flush(error:Boolean):void{ var request:Object; var callback:Object; if (((_clip) && (_clip._queue))){ while (_clip._queue.length > 0) { request = _clip._queue.shift(); callback = null; if (request != null){ if (request.callbackID != null){ callback = _clip._callbacks[request.callbackID]; }; delete _clip._callbacks[request.callbackID]; if (((error) && (!((callback == null))))){ handleError(request.args, callback.callbackObject, callback.callbackMethod); }; }; }; }; } public static function get id():String{ return (_id); } private static function onEvent(pkg:Object):void{ var target:String = pkg.target; var event:String = pkg.event; switch (target){ case "events": MochiEvents.triggerEvent(pkg.event, pkg.args); break; case "coins": MochiCoins.triggerEvent(pkg.event, pkg.args); break; case "sync": servicesSync.triggerEvent(pkg.event, pkg.args); break; }; } private static function urlOptions(clip:Object):Object{ var options:String; var pairs:Array; var i:Number; var kv:Array; var opts:Object = {}; if (clip.stage){ options = clip.stage.loaderInfo.parameters.mochiad_options; } else { options = clip.loaderInfo.parameters.mochiad_options; }; if (options){ pairs = options.split("&"); i = 0; while (i < pairs.length) { kv = pairs[i].split("="); opts[unescape(kv[0])] = unescape(kv[1]); i++; }; }; return (opts); } public static function setContainer(container:Object=null, doAdd:Boolean=true):void{ if (container != null){ if ((container is Sprite)){ _container = container; }; }; if (doAdd){ if ((_container is Sprite)){ Sprite(_container).addChild(_clip); }; }; } private static function handleError(args:Object, callbackObject:Object, callbackMethod:Object):void{ var args = args; var callbackObject = callbackObject; var callbackMethod = callbackMethod; if (args != null){ if (args.onError != null){ args.onError.apply(null, ["NotConnected"]); }; if (((!((args.options == null))) && (!((args.options.onError == null))))){ args.options.onError.apply(null, ["NotConnected"]); }; }; if (callbackMethod != null){ args = {}; args.error = true; args.errorCode = "NotConnected"; if (((!((callbackObject == null))) && ((callbackMethod is String)))){ var _local5 = callbackObject; _local5[callbackMethod](args); //unresolved jump var _slot1 = error; } else { if (callbackMethod != null){ callbackMethod.apply(args); //unresolved jump var _slot1 = error; }; }; }; } private static function loadError(ev: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, clip:_container, 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(clip:Object):void{ var loader:Loader; var clip = clip; loader = new Loader(); var mochiLCURL:String = (_servURL + _mochiLC); var req:URLRequest = new URLRequest(mochiLCURL); var complete:Function = function (ev: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 (args:Object):void{ MochiServices.comChannelName = args.newChannel; }; trace("Waiting for MochiAds services to connect..."); } public static function get clip():Object{ return (_container); } public static function set comChannelName(val:String):void{ if (val != null){ if (val.length > 3){ _sendChannelName = (val + "_fromgame"); initComChannels(); }; }; } private static function loadCommunicator(id:String, clip:Object):MovieClip{ var clipname:String = ("_mochiservices_com_" + id); if (_clip != null){ return (_clip); }; if (!MochiServices.isNetworkAvailable()){ return (null); }; if (urlOptions(clip).servURL){ _servURL = urlOptions(clip).servURL; }; var servicesURL:String = (_servURL + _services); if (urlOptions(clip).servicesURL){ servicesURL = urlOptions(clip).servicesURL; }; _listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999)))); MochiServices.allowDomains(servicesURL); _clip = createEmptyMovieClip(clip, clipname, 10336, false); loadLCBridge(_clip); _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError); var req:URLRequest = new URLRequest(servicesURL); var vars:URLVariables = new URLVariables(); vars.listenLC = _listenChannelName; vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options; vars.api_version = getVersion(); if (widget){ vars.widget = true; }; req.data = vars; _loader.load(req); _clip.addChild(_loader); _clip._mochiservices_com = _loader; _sendChannel = new LocalConnection(); _clip._queue = []; _clip._nextcallbackID = 0; _clip._callbacks = {}; _timer = new Timer(10000, 1); _timer.addEventListener(TimerEvent.TIMER, connectWait); _timer.start(); return (_clip); } public static function connect(id:String, clip:Object, onError:Object=null):void{ var id = id; var clip = clip; var onError = onError; warnID(id, false); if ((clip is DisplayObject)){ if (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 (errorCode:String):void{ trace(errorCode); }; }; }; } public static function createEmptyMovieClip(parent:Object, name:String, depth:Number, doAdd:Boolean=true):MovieClip{ var parent = parent; var name = name; var depth = depth; var doAdd = doAdd; var mc:MovieClip = new MovieClip(); if (doAdd){ if (((false) && (depth))){ parent.addChildAt(mc, depth); } else { parent.addChild(mc); }; }; parent[name] = mc; //unresolved jump var _slot1 = e; throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic.")); mc["_name"] = name; return (mc); } public static function bringToTop(e:Event=null):void{ var e = e; if (((!((MochiServices.clip == null))) && (!((MochiServices.childClip == null))))){ if (MochiServices.clip.numChildren > 1){ MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1)); }; //unresolved jump var _slot1 = errorObject; trace("Warning: Depth sort error."); _container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop); }; } public static function connectWait(e:TimerEvent):void{ if (!_connected){ _clip._mochiad_ctr_failed = true; trace("MochiServices could not load. (timeout)"); MochiServices.disconnect(); MochiServices.onError("IOError"); }; } } }//package mochi.as3
Section 24
//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{ super(); _syncContainer = {}; } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{ if (_syncContainer[name] == value){ return; }; var n:String = name.toString(); _syncContainer[n] = value; MochiServices.send("sync_propUpdate", {name:n, value:value}); } override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){ return (_syncContainer[name]); } public function triggerEvent(eventType:String, args:Object):void{ switch (eventType){ case SYNC_REQUEST: MochiServices.send("sync_syncronize", _syncContainer); break; case SYNC_PROPERTY: _syncContainer[args.name] = args.value; break; }; } } }//package mochi.as3
Section 25
//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 operation:String;// = null public var error:Event;// = null public var data;// = null public var _loader:URLLoader; public var key:String;// = null public function MochiUserData(key:String="", callback:Function=null){ super(); this.key = key; this.callback = callback; } public function serialize(obj):ByteArray{ var arr:ByteArray = new ByteArray(); arr.objectEncoding = ObjectEncoding.AMF3; arr.writeObject(obj); arr.compress(); return (arr); } public function errorHandler(event:IOErrorEvent):void{ data = null; error = event; if (callback != null){ performCallback(); } else { dispatchEvent(event); }; close(); } public function putEvent(obj):void{ request("put", serialize(obj)); } public function deserialize(arr:ByteArray){ arr.objectEncoding = ObjectEncoding.AMF3; arr.uncompress(); return (arr.readObject()); } public function securityErrorHandler(event:SecurityErrorEvent):void{ errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + event.toString()))); } 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 performCallback():void{ callback(this); //unresolved jump var _slot1 = e; trace(("[MochiUserData] exception during callback: " + _slot1)); } public function request(_operation:String, _data:ByteArray):void{ var _operation = _operation; var _data = _data; operation = _operation; var api_url:String = MochiCoins.getAPIURL(); var api_token:String = MochiCoins.getAPIToken(); if ((((api_url == null)) || ((api_token == null)))){ errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in")); return; }; _loader = new URLLoader(); var args:URLVariables = new URLVariables(); args.op = _operation; args.key = key; var req:URLRequest = new URLRequest((((MochiCoins.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); _loader.load(req); //unresolved jump var _slot1 = e; errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _slot1.toString()))); } public function completeHandler(event:Event):void{ var event = event; if (_loader.data.length){ data = deserialize(_loader.data); } else { data = null; }; //unresolved jump var _slot1 = e; errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + _slot1.toString()))); return; if (callback != null){ performCallback(); } else { dispatchEvent(event); }; close(); } 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 static function get(key:String, callback:Function):void{ var userData:MochiUserData = new MochiUserData(key, callback); userData.getEvent(); } public static function put(key:String, obj, callback:Function):void{ var userData:MochiUserData = new MochiUserData(key, callback); userData.putEvent(obj); } } }//package mochi.as3
Section 26
//IFlexAsset (mx.core.IFlexAsset) package mx.core { public interface IFlexAsset { } }//package mx.core
Section 27
//mx_internal (mx.core.mx_internal) package mx.core { public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal"; }//package mx.core
Section 28
//SoundAsset (mx.core.SoundAsset) package mx.core { import flash.media.*; public class SoundAsset extends Sound implements IFlexAsset { mx_internal static const VERSION:String = "3.0.0.0"; public function SoundAsset(){ super(); } } }//package mx.core
Section 29
//BattleField (BattleField) package { import flash.events.*; import flash.display.*; public dynamic class BattleField extends MovieClip { public var butExit:SimpleButton; public function BattleField(){ addFrameScript(0, frame1); } function frame1(){ butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("stopGame")); }); } } }//package
Section 30
//ColorBox (ColorBox) package { import flash.display.*; public dynamic class ColorBox extends MovieClip { public var border:MovieClip; public var _curColor:uint; public var box:MovieClip; public function ColorBox(){ addFrameScript(0, frame1); } public function select():void{ border.visible = true; } public function get color():uint{ return (_curColor); } function frame1(){ border.visible = false; _curColor = 1; } public function set color(_arg1:uint):void{ if ((((_arg1 >= 0)) && ((_arg1 < 25)))){ _curColor = (_arg1 + 1); box.gotoAndStop(_curColor); }; } public function unselect():void{ border.visible = false; } } }//package
Section 31
//CubeWars (CubeWars) package { import flash.events.*; import flash.display.*; import com.biox.cubewars.game.*; import flash.media.*; import mochi.as3.*; public class CubeWars extends Sprite { private var help:Help; private var tutorial:Tutorial; private var menu:Menu; private var battleField:BattleField; public var music:Sound; private var WarSound:Class; public var musicChannel:SoundChannel; private var levels:Levels; private var game:Game;// = null public function CubeWars(){ WarSound = CubeWars_WarSound; menu = new Menu(); battleField = new BattleField(); help = new Help(); levels = new Levels(); tutorial = new Tutorial(); super(); } private function showHelp(event:Event):void{ removeChild(menu); addChild(help); } private function showScores(event:Event):void{ var event = event; var o:Object = {n:[15, 10, 7, 2, 15, 7, 6, 1, 8, 5, 5, 4, 13, 8, 4, 5], f:function (i:Number, s:String):String{ if (s.length == 16){ return (s); }; return (this.f((i + 1), (s + this.n[i].toString(16)))); }}; var boardID:String = o.f(0, ""); MochiScores.showLeaderboard({boardID:boardID}); } private function closeLevels(event:Event):void{ removeChild(levels); addChild(menu); } private function showLevels(event:Event):void{ removeChild(menu); addChild(levels); } public function init(didLoad:Boolean):void{ MochiBot.track(this, "d35d59e0"); if (didLoad){ startCubeWars(); }; } public function playMusic():void{ musicChannel = music.play(); musicChannel.addEventListener(Event.SOUND_COMPLETE, loopMusic); } private function stopGame(event:Event):void{ if (game != null){ game.finish(); removeChild(game); removeChild(battleField); addChild(menu); game = null; musicChannel.stop(); }; } private function submitScores(event:Event):void{ var event = event; trace("3. submit"); var o:Object = {n:[15, 10, 7, 2, 15, 7, 6, 1, 8, 5, 5, 4, 13, 8, 4, 5], f:function (i:Number, s:String):String{ if (s.length == 16){ return (s); }; return (this.f((i + 1), (s + this.n[i].toString(16)))); }}; var boardID:String = o.f(0, ""); MochiScores.showLeaderboard({boardID:boardID, score:game.getScores()}); game.finish(); removeChild(game); removeChild(battleField); addChild(menu); game = null; musicChannel.stop(); } private function closeHelp(event:Event):void{ removeChild(help); addChild(menu); } public function loopMusic(e:Event):void{ if (musicChannel != null){ musicChannel.removeEventListener(Event.SOUND_COMPLETE, loopMusic); playMusic(); }; } public function startCubeWars():void{ stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 50; menu.x = 0; menu.y = 0; addChild(menu); menu.addEventListener("showLevels", showLevels); menu.addEventListener("showScores", showScores); menu.addEventListener("showHelp", showHelp); levels.addEventListener("startGame", startGame); levels.addEventListener("showTutorial", showTutorial); levels.addEventListener("closeLevels", closeLevels); tutorial.visible = false; levels.addChild(tutorial); battleField.addEventListener("stopGame", stopGame); help.addEventListener("closeHelp", closeHelp); tutorial.addEventListener("closeTutorial", closeTutorial); MochiServices.connect("fdad2dc65376e9a2", root); } private function startGame(event:Event):void{ game = new Game(levels.getLevel(), menu.getDifficulty()); game.addEventListener("replayGame", replayGame); game.addEventListener("submitScores", submitScores); game.x = 0; game.y = 0; game.start(); removeChild(levels); addChild(battleField); addChild(game); music = new WarSound(); playMusic(); } private function replayGame(event:Event):void{ trace("3. replay"); removeChild(game); game = new Game(levels.getLevel(), menu.getDifficulty()); game.addEventListener("replayGame", replayGame); game.addEventListener("submitScores", submitScores); game.x = 0; game.y = 0; game.start(); addChild(game); } private function showTutorial(event:Event):void{ tutorial.gotoAndStop(1); tutorial.visible = true; } private function closeTutorial(event:Event):void{ tutorial.visible = false; } } }//package
Section 32
//CubeWars_WarSound (CubeWars_WarSound) package { import mx.core.*; public class CubeWars_WarSound extends SoundAsset { } }//package
Section 33
//Help (Help) package { import flash.events.*; import flash.display.*; public dynamic class Help extends MovieClip { public var butExit:SimpleButton; public function Help(){ addFrameScript(0, frame1); } function frame1(){ butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeHelp")); }); } } }//package
Section 34
//Icons (Icons) package { import flash.events.*; import flash.display.*; public dynamic class Icons extends MovieClip { public var butSubmitScores:SimpleButton; public var butReplay:SimpleButton; public function Icons(){ addFrameScript(3, frame4, 4, frame5); } function frame4(){ butSubmitScores.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("submitScores")); }); } function frame5(){ butReplay.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("replayGame")); }); } } }//package
Section 35
//Levels (Levels) package { import flash.events.*; import flash.display.*; public dynamic class Levels extends MovieClip { public var butLevelTutorial:SimpleButton; public var butLevel1:SimpleButton; public var butLevel3:SimpleButton; public var butLevel5:SimpleButton; public var butLevel2:SimpleButton; public var butLevel4:SimpleButton; public var butExit:SimpleButton; public var level:uint; public function Levels(){ addFrameScript(0, frame1); } function frame1(){ level = 1; butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeLevels")); }); butLevelTutorial.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("showTutorial")); }); butLevel1.addEventListener(MouseEvent.CLICK, function (){ level = 1; dispatchEvent(new Event("startGame")); }); butLevel2.addEventListener(MouseEvent.CLICK, function (){ level = 2; dispatchEvent(new Event("startGame")); }); butLevel3.addEventListener(MouseEvent.CLICK, function (){ level = 3; dispatchEvent(new Event("startGame")); }); butLevel4.addEventListener(MouseEvent.CLICK, function (){ level = 4; dispatchEvent(new Event("startGame")); }); butLevel5.addEventListener(MouseEvent.CLICK, function (){ level = 5; dispatchEvent(new Event("startGame")); }); } public function getLevel():uint{ return (level); } } }//package
Section 36
//Menu (Menu) package { import flash.events.*; import flash.display.*; import flash.media.*; import flash.text.*; import flash.system.*; import flash.net.*; import adobe.utils.*; import flash.accessibility.*; import flash.errors.*; import flash.external.*; import flash.filters.*; import flash.geom.*; import flash.printing.*; import flash.ui.*; import flash.utils.*; import flash.xml.*; public dynamic class Menu extends MovieClip { public var buttonScores:SimpleButton; public var butDifficulty:MovieClip; public var butHelp:SimpleButton; public var butPlay:SimpleButton; public function Menu(){ addFrameScript(0, frame1); } function frame1(){ butPlay.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("showLevels")); }); butHelp.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("showHelp")); }); buttonScores.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("showScores")); }); } public function setDifficulty(_arg1:uint):void{ butDifficulty.updateDifficulty(_arg1); } public function getDifficulty():uint{ return (butDifficulty.getDifficulty()); } public function getLevel():uint{ return (1); } } }//package
Section 37
//MochiBot (MochiBot) package { import flash.display.*; import flash.system.*; import flash.net.*; public dynamic class MochiBot extends Sprite { public function MochiBot(){ super(); } public static function track(parent:Sprite, tag:String):MochiBot{ if (Security.sandboxType == "localWithFile"){ return (null); }; var self:MochiBot = new (MochiBot); parent.addChild(self); Security.allowDomain("*"); Security.allowInsecureDomain("*"); var server:String = "http://core.mochibot.com/my/core.swf"; var lv:URLVariables = new URLVariables(); lv["sb"] = Security.sandboxType; lv["v"] = Capabilities.version; lv["swfid"] = tag; lv["mv"] = "8"; lv["fv"] = "9"; var url:String = self.root.loaderInfo.loaderURL; if (url.indexOf("http") == 0){ lv["url"] = url; } else { lv["url"] = "local"; }; var req:URLRequest = new URLRequest(server); req.contentType = "application/x-www-form-urlencoded"; req.method = URLRequestMethod.POST; req.data = lv; var loader:Loader = new Loader(); self.addChild(loader); loader.load(req); return (self); } } }//package
Section 38
//Preloader (Preloader) package { import flash.events.*; import flash.display.*; import mochi.as3.*; import flash.utils.*; public dynamic class Preloader extends MovieClip { private var did_load:Boolean; public static var GAME_OPTIONS:Object = {id:"fdad2dc65376e9a2", res:"640x480", background:16769736, color:16301692, outline:15942661, no_bg:true}; public static var MAIN_CLASS:String = "CubeWars"; public function Preloader(){ super(); showMA(); } private function showMA():void{ var k:String; var f:Function = function (ev:IOErrorEvent):void{ }; loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f); var opts:Object = {}; for (k in GAME_OPTIONS) { opts[k] = GAME_OPTIONS[k]; }; opts.ad_started = function ():void{ did_load = true; }; opts.ad_finished = function ():void{ gotoNextFrame(); }; opts.clip = this; MochiAd.showPreGameAd(opts); MochiServices.connect(GAME_OPTIONS.id, this); } private function gotoNextFrame(e:Event=null):void{ var mainClass:Class = Class(getDefinitionByName(MAIN_CLASS)); var app:Object = new (mainClass); addChild((app as DisplayObject)); if (app.init){ app.init(true); }; } } }//package
Section 39
//Progress (Progress) package { import flash.display.*; public dynamic class Progress extends MovieClip { public var progr:MovieClip; public var _curFrame:uint; public function Progress(){ addFrameScript(0, frame1); } function frame1(){ _curFrame = 1; } public function set frameNum(_arg1:uint):void{ if ((((_arg1 >= 0)) && ((_arg1 < 5)))){ _curFrame = (_arg1 + 1); progr.gotoAndStop(_curFrame); }; } public function get frameNum():uint{ return (_curFrame); } } }//package
Section 40
//Tutorial (Tutorial) package { import flash.events.*; import flash.display.*; public dynamic class Tutorial extends MovieClip { public var butNext:SimpleButton; public var butExit:SimpleButton; public var butPrev:SimpleButton; public function Tutorial(){ addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8); } function frame3(){ butPrev.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(2); }); butNext.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(4); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } function frame6(){ butPrev.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(5); }); butNext.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(7); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } function frame7(){ butPrev.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(6); }); butNext.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(8); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } function frame1(){ gotoAndStop(1); butNext.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(2); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } function frame4(){ butPrev.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(3); }); butNext.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(5); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } function frame5(){ butPrev.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(4); }); butNext.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(6); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } function frame8(){ butPrev.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(7); }); butNext.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } function frame2(){ butPrev.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(1); }); butNext.addEventListener(MouseEvent.CLICK, function (){ gotoAndStop(3); }); butExit.addEventListener(MouseEvent.CLICK, function (){ dispatchEvent(new Event("closeTutorial")); }); } } }//package

Library Items

Symbol 1 GraphicUsed by:20
Symbol 2 FontUsed by:3 4 5 6 7 8 11 16 17 18 38
Symbol 3 TextUses:2Used by:20
Symbol 4 TextUses:2Used by:20
Symbol 5 TextUses:2Used by:20
Symbol 6 TextUses:2Used by:20
Symbol 7 TextUses:2Used by:20
Symbol 8 TextUses:2Used by:20
Symbol 9 FontUsed by:10 12 13 14 15
Symbol 10 TextUses:9Used by:20
Symbol 11 TextUses:2Used by:20
Symbol 12 TextUses:9Used by:20
Symbol 13 TextUses:9Used by:20
Symbol 14 TextUses:9Used by:20
Symbol 15 TextUses:9Used by:20
Symbol 16 TextUses:2Used by:20
Symbol 17 TextUses:2Used by:19
Symbol 18 TextUses:2Used by:19
Symbol 19 ButtonUses:17 18Used by:20
Symbol 20 MovieClip {Help} [Help]Uses:1 3 4 5 6 7 8 10 11 12 13 14 15 16 19
Symbol 21 GraphicUsed by:26
Symbol 22 FontUsed by:23 24 38
Symbol 23 TextUses:22Used by:25
Symbol 24 TextUses:22Used by:25
Symbol 25 ButtonUses:23 24Used by:26
Symbol 26 MovieClip {BattleField} [BattleField]Uses:21 25
Symbol 27 BitmapUsed by:28 39 48 53 57 63 68 71
Symbol 28 GraphicUses:27Used by:74
Symbol 29 FontUsed by:30 40 49 54 58 64 69 72
Symbol 30 TextUses:29Used by:74
Symbol 31 FontUsed by:32 33 38
Symbol 32 TextUses:31Used by:34
Symbol 33 TextUses:31Used by:34
Symbol 34 ButtonUses:32 33Used by:74
Symbol 35 GraphicUsed by:37
Symbol 36 GraphicUsed by:37
Symbol 37 ButtonUses:35 36Used by:74
Symbol 38 EditableTextUses:2 22 31 78 105 170Used by:74
Symbol 39 GraphicUses:27Used by:74
Symbol 40 TextUses:29Used by:74
Symbol 41 FontUsed by:42 43 44 50 55 56 59 60 65 70 73
Symbol 42 TextUses:41Used by:74
Symbol 43 TextUses:41Used by:74
Symbol 44 TextUses:41Used by:74
Symbol 45 GraphicUsed by:47
Symbol 46 GraphicUsed by:47
Symbol 47 ButtonUses:45 46Used by:74
Symbol 48 GraphicUses:27Used by:74
Symbol 49 TextUses:29Used by:74
Symbol 50 TextUses:41Used by:74
Symbol 51 BitmapUsed by:53 57
Symbol 52 BitmapUsed by:53 57
Symbol 53 GraphicUses:52 51 27Used by:74
Symbol 54 TextUses:29Used by:74
Symbol 55 TextUses:41Used by:74
Symbol 56 TextUses:41Used by:74
Symbol 57 GraphicUses:52 51 27Used by:74
Symbol 58 TextUses:29Used by:74
Symbol 59 TextUses:41Used by:74
Symbol 60 TextUses:41Used by:74
Symbol 61 BitmapUsed by:63 68 71
Symbol 62 BitmapUsed by:63 68 71
Symbol 63 GraphicUses:62 61 27Used by:74
Symbol 64 TextUses:29Used by:74
Symbol 65 TextUses:41Used by:74
Symbol 66 BitmapUsed by:67
Symbol 67 GraphicUses:66Used by:74
Symbol 68 GraphicUses:62 61 27Used by:74
Symbol 69 TextUses:29Used by:74
Symbol 70 TextUses:41Used by:74
Symbol 71 GraphicUses:62 61 27Used by:74
Symbol 72 TextUses:29Used by:74
Symbol 73 TextUses:41Used by:74
Symbol 74 MovieClip {Tutorial} [Tutorial]Uses:28 30 34 37 38 39 40 42 43 44 47 48 49 50 53 54 55 56 57 58 59 60 63 64 65 67 68 69 70 71 72 73
Symbol 75 Sound {CubeWars_WarSound} [CubeWars_WarSound]
Symbol 76 BitmapUsed by:77
Symbol 77 GraphicUses:76Used by:101
Symbol 78 FontUsed by:38 79 80 82 83 85 86 92 93 95 96
Symbol 79 TextUses:78Used by:81
Symbol 80 TextUses:78Used by:81
Symbol 81 ButtonUses:79 80Used by:101
Symbol 82 TextUses:78Used by:84
Symbol 83 TextUses:78Used by:84
Symbol 84 ButtonUses:82 83Used by:101
Symbol 85 TextUses:78Used by:87
Symbol 86 TextUses:78Used by:87
Symbol 87 ButtonUses:85 86Used by:101
Symbol 88 FontUsed by:89
Symbol 89 EditableTextUses:88Used by:98
Symbol 90 GraphicUsed by:91
Symbol 91 ButtonUses:90Used by:98
Symbol 92 TextUses:78Used by:94
Symbol 93 TextUses:78Used by:94
Symbol 94 ButtonUses:92 93Used by:98
Symbol 95 TextUses:78Used by:97
Symbol 96 TextUses:78Used by:97
Symbol 97 ButtonUses:95 96Used by:98
Symbol 98 MovieClip {Menu_fla.ButtonDifficulty_5} [Menu_fla.ButtonDifficulty_5]Uses:89 91 94 97Used by:101
Symbol 99 FontUsed by:100
Symbol 100 TextUses:99Used by:101
Symbol 101 MovieClip {Menu} [Menu]Uses:77 81 84 87 98 100
Symbol 102 BitmapUsed by:104
Symbol 103 BitmapUsed by:104
Symbol 104 GraphicUses:103 102Used by:128
Symbol 105 FontUsed by:38 106 107 108 111 112 113 114 122 123
Symbol 106 TextUses:105Used by:128
Symbol 107 TextUses:105Used by:128
Symbol 108 TextUses:105Used by:128
Symbol 109 BitmapUsed by:110
Symbol 110 GraphicUses:109Used by:128
Symbol 111 TextUses:105Used by:128
Symbol 112 TextUses:105Used by:128
Symbol 113 TextUses:105Used by:115
Symbol 114 TextUses:105Used by:115
Symbol 115 ButtonUses:113 114Used by:128
Symbol 116 GraphicUsed by:119
Symbol 117 GraphicUsed by:119
Symbol 118 GraphicUsed by:119
Symbol 119 ButtonUses:116 117 118Used by:128
Symbol 120 BitmapUsed by:121
Symbol 121 GraphicUses:120Used by:128
Symbol 122 TextUses:105Used by:128
Symbol 123 TextUses:105Used by:128
Symbol 124 FontUsed by:125
Symbol 125 TextUses:124Used by:128
Symbol 126 BitmapUsed by:127
Symbol 127 GraphicUses:126Used by:128
Symbol 128 MovieClip {Levels} [Levels]Uses:104 106 107 108 110 111 112 115 119 121 122 123 125 127
Symbol 129 GraphicUsed by:154
Symbol 130 GraphicUsed by:154
Symbol 131 GraphicUsed by:154
Symbol 132 GraphicUsed by:154
Symbol 133 GraphicUsed by:154
Symbol 134 GraphicUsed by:154
Symbol 135 GraphicUsed by:154
Symbol 136 GraphicUsed by:154
Symbol 137 GraphicUsed by:154
Symbol 138 GraphicUsed by:154
Symbol 139 GraphicUsed by:154
Symbol 140 GraphicUsed by:154
Symbol 141 GraphicUsed by:154
Symbol 142 GraphicUsed by:154
Symbol 143 GraphicUsed by:154
Symbol 144 GraphicUsed by:154
Symbol 145 GraphicUsed by:154
Symbol 146 GraphicUsed by:154
Symbol 147 GraphicUsed by:154
Symbol 148 GraphicUsed by:154
Symbol 149 GraphicUsed by:154
Symbol 150 GraphicUsed by:154
Symbol 151 GraphicUsed by:154
Symbol 152 GraphicUsed by:154
Symbol 153 GraphicUsed by:154
Symbol 154 MovieClipUses:129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153Used by:157
Symbol 155 GraphicUsed by:156
Symbol 156 MovieClipUses:155Used by:157
Symbol 157 MovieClip {ColorBox} [ColorBox]Uses:154 156
Symbol 158 Sound {com.biox.cubewars.core.Cube_CubeSound} [com.biox.cubewars.core.Cube_CubeSound]
Symbol 159 GraphicUsed by:166
Symbol 160 GraphicUsed by:166
Symbol 161 GraphicUsed by:166
Symbol 162 BitmapUsed by:163 175
Symbol 163 GraphicUses:162Used by:166
Symbol 164 BitmapUsed by:165 173
Symbol 165 GraphicUses:164Used by:166
Symbol 166 MovieClipUses:159 160 161 163 165Used by:167
Symbol 167 MovieClip {Progress} [Progress]Uses:166
Symbol 168 GraphicUsed by:188
Symbol 169 GraphicUsed by:188
Symbol 170 FontUsed by:38 171 174 177 180 181 184 185 186
Symbol 171 TextUses:170Used by:188
Symbol 172 BitmapUsed by:173 175
Symbol 173 GraphicUses:172 164Used by:188
Symbol 174 TextUses:170Used by:188
Symbol 175 GraphicUses:172 162Used by:188
Symbol 176 GraphicUsed by:188
Symbol 177 TextUses:170Used by:188
Symbol 178 GraphicUsed by:179
Symbol 179 MovieClipUses:178Used by:188
Symbol 180 TextUses:170Used by:182
Symbol 181 TextUses:170Used by:182
Symbol 182 ButtonUses:180 181Used by:188
Symbol 183 GraphicUsed by:188
Symbol 184 TextUses:170Used by:188
Symbol 185 TextUses:170Used by:187
Symbol 186 TextUses:170Used by:187
Symbol 187 ButtonUses:185 186Used by:188
Symbol 188 MovieClip {Icons} [Icons]Uses:168 169 171 173 174 175 176 177 179 182 183 184 187

Instance Names

"butExit"Symbol 20 MovieClip {Help} [Help] Frame 1Symbol 19 Button
"butExit"Symbol 26 MovieClip {BattleField} [BattleField] Frame 1Symbol 25 Button
"butExit"Symbol 74 MovieClip {Tutorial} [Tutorial] Frame 1Symbol 34 Button
"butNext"Symbol 74 MovieClip {Tutorial} [Tutorial] Frame 1Symbol 37 Button
"butNext"Symbol 74 MovieClip {Tutorial} [Tutorial] Frame 2Symbol 37 Button
"butPrev"Symbol 74 MovieClip {Tutorial} [Tutorial] Frame 2Symbol 47 Button
"textDifficulty"Symbol 98 MovieClip {Menu_fla.ButtonDifficulty_5} [Menu_fla.ButtonDifficulty_5] Frame 1Symbol 89 EditableText
"butCenter"Symbol 98 MovieClip {Menu_fla.ButtonDifficulty_5} [Menu_fla.ButtonDifficulty_5] Frame 1Symbol 91 Button
"butRight"Symbol 98 MovieClip {Menu_fla.ButtonDifficulty_5} [Menu_fla.ButtonDifficulty_5] Frame 1Symbol 94 Button
"butLeft"Symbol 98 MovieClip {Menu_fla.ButtonDifficulty_5} [Menu_fla.ButtonDifficulty_5] Frame 1Symbol 97 Button
"butHelp"Symbol 101 MovieClip {Menu} [Menu] Frame 1Symbol 81 Button
"buttonScores"Symbol 101 MovieClip {Menu} [Menu] Frame 1Symbol 84 Button
"butPlay"Symbol 101 MovieClip {Menu} [Menu] Frame 1Symbol 87 Button
"butDifficulty"Symbol 101 MovieClip {Menu} [Menu] Frame 1Symbol 98 MovieClip {Menu_fla.ButtonDifficulty_5} [Menu_fla.ButtonDifficulty_5]
"butExit"Symbol 128 MovieClip {Levels} [Levels] Frame 1Symbol 115 Button
"butLevel1"Symbol 128 MovieClip {Levels} [Levels] Frame 1Symbol 119 Button
"butLevel2"Symbol 128 MovieClip {Levels} [Levels] Frame 1Symbol 119 Button
"butLevel3"Symbol 128 MovieClip {Levels} [Levels] Frame 1Symbol 119 Button
"butLevel4"Symbol 128 MovieClip {Levels} [Levels] Frame 1Symbol 119 Button
"butLevelTutorial"Symbol 128 MovieClip {Levels} [Levels] Frame 1Symbol 119 Button
"butLevel5"Symbol 128 MovieClip {Levels} [Levels] Frame 1Symbol 119 Button
"box"Symbol 157 MovieClip {ColorBox} [ColorBox] Frame 1Symbol 154 MovieClip
"border"Symbol 157 MovieClip {ColorBox} [ColorBox] Frame 1Symbol 156 MovieClip
"progr"Symbol 167 MovieClip {Progress} [Progress] Frame 1Symbol 166 MovieClip
"butSubmitScores"Symbol 188 MovieClip {Icons} [Icons] Frame 4Symbol 182 Button
"butReplay"Symbol 188 MovieClip {Icons} [Icons] Frame 5Symbol 187 Button

Special Tags

FileAttributes (69)Timeline Frame 1Access network only, Metadata present, AS3.
SWFMetaData (77)Timeline Frame 1457 bytes "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'><rdf:Description rdf:about='' xmlns ..."
ScriptLimits (65)Timeline Frame 1MaxRecursionDepth: 1000, ScriptTimeout: 60 seconds
ExportAssets (56)Timeline Frame 2Symbol 20 as "Help"
ExportAssets (56)Timeline Frame 2Symbol 26 as "BattleField"
ExportAssets (56)Timeline Frame 2Symbol 74 as "Tutorial"
ExportAssets (56)Timeline Frame 2Symbol 75 as "CubeWars_WarSound"
ExportAssets (56)Timeline Frame 2Symbol 101 as "Menu"
ExportAssets (56)Timeline Frame 2Symbol 128 as "Levels"
ExportAssets (56)Timeline Frame 2Symbol 98 as "Menu_fla.ButtonDifficulty_5"
ExportAssets (56)Timeline Frame 2Symbol 157 as "ColorBox"
ExportAssets (56)Timeline Frame 2Symbol 158 as "com.biox.cubewars.core.Cube_CubeSound"
ExportAssets (56)Timeline Frame 2Symbol 167 as "Progress"
ExportAssets (56)Timeline Frame 2Symbol 188 as "Icons"
EnableDebugger2 (64)Timeline Frame 131 bytes "u.$1$3X$adz1egH897P6BOXblDMZs0."
DebugMX1 (63)Timeline Frame 1
SerialNumber (41)Timeline Frame 1

Labels

"Preloader"Frame 1
"CubeWars"Frame 2




http://swfchan.com/19/92048/info.shtml
Created: 27/3 -2019 15:01:41 Last modified: 27/3 -2019 15:01:41 Server time: 05/11 -2024 06:47:06