Section 1
//MenuCloud1 (Assets.Menu.MenuCloud1)
package Assets.Menu {
import flash.display.*;
public dynamic class MenuCloud1 extends BitmapData {
public function MenuCloud1(w:int=282, h:int=138){
super(w, h);
}
}
}//package Assets.Menu
Section 2
//MenuCloud2 (Assets.Menu.MenuCloud2)
package Assets.Menu {
import flash.display.*;
public dynamic class MenuCloud2 extends BitmapData {
public function MenuCloud2(w:int=210, h:int=138){
super(w, h);
}
}
}//package Assets.Menu
Section 3
//MenuCloud3 (Assets.Menu.MenuCloud3)
package Assets.Menu {
import flash.display.*;
public dynamic class MenuCloud3 extends BitmapData {
public function MenuCloud3(w:int=250, h:int=146){
super(w, h);
}
}
}//package Assets.Menu
Section 4
//MenuCloud4 (Assets.Menu.MenuCloud4)
package Assets.Menu {
import flash.display.*;
public dynamic class MenuCloud4 extends BitmapData {
public function MenuCloud4(w:int=248, h:int=168){
super(w, h);
}
}
}//package Assets.Menu
Section 5
//MenuCloud5 (Assets.Menu.MenuCloud5)
package Assets.Menu {
import flash.display.*;
public dynamic class MenuCloud5 extends BitmapData {
public function MenuCloud5(w:int=219, h:int=83){
super(w, h);
}
}
}//package Assets.Menu
Section 6
//Bing (Assets.Sounds.Bing)
package Assets.Sounds {
import flash.media.*;
public dynamic class Bing extends Sound {
}
}//package Assets.Sounds
Section 7
//Music (Assets.Sounds.Music)
package Assets.Sounds {
import flash.media.*;
public dynamic class Music extends Sound {
}
}//package Assets.Sounds
Section 8
//ClickToBegin (Game.Engine.ClickToBegin)
package Game.Engine {
import flash.display.*;
public dynamic class ClickToBegin extends MovieClip {
}
}//package Game.Engine
Section 9
//ClickToContinue (Game.Engine.ClickToContinue)
package Game.Engine {
import flash.display.*;
public dynamic class ClickToContinue extends MovieClip {
}
}//package Game.Engine
Section 10
//Generating (Game.Engine.Generating)
package Game.Engine {
import flash.display.*;
import flash.events.*;
public class Generating extends MovieClip {
public static var Complete:Boolean;
public function Generating(){
super();
Complete = false;
this.addEventListener(Event.ENTER_FRAME, this.Tick);
}
private function Tick(e:Event):void{
if (Complete){
this.removeEventListener(Event.ENTER_FRAME, this.Tick);
this.parent.removeChild(this);
};
}
}
}//package Game.Engine
Section 11
//Level (Game.Engine.Level)
package Game.Engine {
import flash.display.*;
public class Level {
public var GridSize:int;
public var OneSquares:int;
public var Pieces:Array;
public var Solution:MovieClip;
private static var Pieces:Array;
private static var PieceImages:Array;
public function Level(){
super();
}
public static function Random():Level{
var level:Level;
var i:int;
if (Pieces == null){
Pieces = [Piece1, Piece2, Piece3, Piece4, Piece5, Piece6, Piece7, Piece8, Piece9];
};
if (PieceImages == null){
PieceImages = [PieceImage(new Piece1()), PieceImage(new Piece2()), PieceImage(new Piece3()), PieceImage(new Piece4()), PieceImage(new Piece5()), PieceImage(new Piece6()), PieceImage(new Piece7()), PieceImage(new Piece8()), PieceImage(new Piece9())];
};
var iterations:int;
var candidates:Array = new Array();
do {
level = Generate();
iterations++;
candidates.push(level);
} while (iterations < 100);
var min = 64;
var winner = -1;
i = 0;
while (i < candidates.length) {
if (candidates[i].Pieces.length < min){
min = candidates[i].Pieces.length;
winner = i;
};
i++;
};
Generating.Complete = true;
return (candidates[winner]);
}
private static function Generate():Level{
var pieceimage:BitmapData;
var piecewidth:int;
var pieceheight:int;
var piecenum:int;
var i:int;
var x:int;
var y:int;
var x2:int;
var y2:int;
var good:Boolean;
var level:Level = new (Level);
level.GridSize = 8;
level.Pieces = new Array();
level.OneSquares = 64;
var gridimage:BitmapData = new BitmapData(level.GridSize, level.GridSize, false, 0);
i = 0;
while (i < 200) {
piecenum = RandomPiece(1, 8);
pieceimage = PieceImages[piecenum];
piecewidth = pieceimage.width;
pieceheight = pieceimage.height;
y = 0;
while (y < (level.GridSize - pieceheight)) {
x = 0;
while (x < (level.GridSize - piecewidth)) {
good = true;
x2 = 0;
while ((((x2 < pieceimage.width)) && (good))) {
y2 = 0;
while ((((y2 < pieceimage.height)) && (good))) {
if (((!((pieceimage.getPixel(x2, y2) == 0))) && (!((gridimage.getPixel((x + x2), (y + y2)) == 0))))){
good = false;
};
y2++;
};
x2++;
};
if (good){
x2 = 0;
while (x2 < pieceimage.width) {
y2 = 0;
while (y2 < pieceimage.height) {
if (pieceimage.getPixel(x2, y2) != 0){
level.OneSquares--;
gridimage.setPixel((x + x2), (y + y2), 0xFFFFFF);
};
y2++;
};
x2++;
};
level.Pieces.push(piecenum);
//unresolved jump
};
x++;
};
y++;
};
i++;
};
level.Pieces = Shuffle(level.Pieces);
gridimage = new BitmapData(level.GridSize, level.GridSize, false, 0);
i = 0;
while (i < level.Pieces.length) {
piecenum = level.Pieces[i];
pieceimage = PieceImages[piecenum];
piecewidth = pieceimage.width;
pieceheight = pieceimage.height;
y = 0;
while (y < (level.GridSize - pieceheight)) {
x = 0;
while (x < (level.GridSize - piecewidth)) {
good = true;
x2 = 0;
while ((((x2 < pieceimage.width)) && (good))) {
y2 = 0;
while ((((y2 < pieceimage.height)) && (good))) {
if (((!((pieceimage.getPixel(x2, y2) == 0))) && (!((gridimage.getPixel((x + x2), (y + y2)) == 0))))){
good = false;
};
y2++;
};
x2++;
};
if (good){
x2 = 0;
while (x2 < pieceimage.width) {
y2 = 0;
while (y2 < pieceimage.height) {
if (pieceimage.getPixel(x2, y2) != 0){
gridimage.setPixel((x + x2), (y + y2), 0xFFFFFF);
};
y2++;
};
x2++;
};
//unresolved jump
};
x++;
};
y++;
};
i++;
};
level.Pieces = Shuffle(level.Pieces);
i = 0;
while (i < 200) {
piecenum = RandomPiece(1, 8);
pieceimage = PieceImages[piecenum];
piecewidth = pieceimage.width;
pieceheight = pieceimage.height;
x = 0;
while (x < (level.GridSize - piecewidth)) {
y = 0;
while (y < (level.GridSize - pieceheight)) {
good = true;
x2 = 0;
while ((((x2 < pieceimage.width)) && (good))) {
y2 = 0;
while ((((y2 < pieceimage.height)) && (good))) {
if (((!((pieceimage.getPixel(x2, y2) == 0))) && (!((gridimage.getPixel((x + x2), (y + y2)) == 0))))){
good = false;
};
y2++;
};
x2++;
};
if (good){
x2 = 0;
while (x2 < pieceimage.width) {
y2 = 0;
while (y2 < pieceimage.height) {
if (pieceimage.getPixel(x2, y2) != 0){
level.OneSquares--;
gridimage.setPixel((x + x2), (y + y2), 0xFFFFFF);
};
y2++;
};
x2++;
};
level.Pieces.push(piecenum);
//unresolved jump
};
y++;
};
x++;
};
i++;
};
level.Pieces = Shuffle(level.Pieces);
gridimage = new BitmapData(level.GridSize, level.GridSize, false, 0);
i = 0;
while (i < level.Pieces.length) {
piecenum = level.Pieces[i];
pieceimage = PieceImages[piecenum];
piecewidth = pieceimage.width;
pieceheight = pieceimage.height;
x = 0;
while (x < (level.GridSize - piecewidth)) {
y = 0;
while (y < (level.GridSize - pieceheight)) {
good = true;
x2 = 0;
while ((((x2 < pieceimage.width)) && (good))) {
y2 = 0;
while ((((y2 < pieceimage.height)) && (good))) {
if (((!((pieceimage.getPixel(x2, y2) == 0))) && (!((gridimage.getPixel((x + x2), (y + y2)) == 0))))){
good = false;
};
y2++;
};
x2++;
};
if (good){
x2 = 0;
while (x2 < pieceimage.width) {
y2 = 0;
while (y2 < pieceimage.height) {
if (pieceimage.getPixel(x2, y2) != 0){
gridimage.setPixel((x + x2), (y + y2), 0xFFFFFF);
};
y2++;
};
x2++;
};
//unresolved jump
};
y++;
};
x++;
};
i++;
};
i = 0;
while (i < 200) {
piecenum = RandomPiece(1, 8);
pieceimage = PieceImages[piecenum];
piecewidth = pieceimage.width;
pieceheight = pieceimage.height;
y = 0;
while (y < (level.GridSize - pieceheight)) {
x = 0;
while (x < (level.GridSize - piecewidth)) {
good = true;
x2 = 0;
while ((((x2 < pieceimage.width)) && (good))) {
y2 = 0;
while ((((y2 < pieceimage.height)) && (good))) {
if (((!((pieceimage.getPixel(x2, y2) == 0))) && (!((gridimage.getPixel((x + x2), (y + y2)) == 0))))){
good = false;
};
y2++;
};
x2++;
};
if (good){
x2 = 0;
while (x2 < pieceimage.width) {
y2 = 0;
while (y2 < pieceimage.height) {
if (pieceimage.getPixel(x2, y2) != 0){
level.OneSquares--;
gridimage.setPixel((x + x2), (y + y2), 0xFFFFFF);
};
y2++;
};
x2++;
};
level.Pieces.push(piecenum);
//unresolved jump
};
x++;
};
y++;
};
i++;
};
i = 0;
while (i < level.Pieces.length) {
level.Pieces[i] = Pieces[level.Pieces[i]];
i++;
};
i = 0;
while (i < level.OneSquares) {
level.Pieces.push(Piece1);
i++;
};
return (level);
}
private static function PieceImage(piece:MovieClip):BitmapData{
var y:int;
var bigxcoord:int;
var bigycoord:int;
var piecewidth:int = (piece.width / 100);
var pieceheight:int = (piece.height / 100);
var pieceimage:BitmapData = new BitmapData(piecewidth, pieceheight, false, 0);
var pieceimagebig:BitmapData = new BitmapData(piece.width, piece.height, true, 0);
pieceimagebig.draw(piece);
var x:int;
while (x < piecewidth) {
y = 0;
while (y < pieceheight) {
bigxcoord = ((x * 100) + 50);
bigycoord = ((y * 100) + 50);
if (pieceimagebig.getPixel32(bigxcoord, bigycoord) != 0){
pieceimage.setPixel(x, y, 0xFFFFFF);
};
y++;
};
x++;
};
return (pieceimage);
}
private static function RandomPiece(min:int, max:int):int{
return ((min + Math.round(((max - min) * Math.random()))));
}
private static function Shuffle(arr:Array):Array{
var arr2:Array = [];
while (arr.length > 0) {
arr2.push(arr.splice(Math.round((Math.random() * (arr.length - 1))), 1)[0]);
};
return (arr2);
}
}
}//package Game.Engine
Section 12
//Levels (Game.Engine.Levels)
package Game.Engine {
public class Levels {
public static var List:Array = new Array(20);
List[0] = new Level();
List[0].GridSize = 1;
List[0].Pieces = [Piece1];
List[1] = new Level();
List[1].GridSize = 2;
List[1].Pieces = [Piece1, Piece2];
List[2] = new Level();
List[2].GridSize = 2;
List[2].Pieces = [Piece1, Piece1, Piece3];
List[3] = new Level();
List[3].GridSize = 3;
List[3].Pieces = [Piece1, Piece1, Piece2, Piece3, Piece4];
List[4] = new Level();
List[4].GridSize = 3;
List[4].Pieces = [Piece2, Piece3, Piece4, Piece4];
List[5] = new Level();
List[5].GridSize = 4;
List[5].Pieces = [Piece2, Piece3, Piece3, Piece4, Piece5, Piece6];
List[6] = new Level();
List[6].GridSize = 4;
List[6].Pieces = [Piece1, Piece1, Piece2, Piece3, Piece3, Piece5, Piece6];
List[7] = new Level();
List[7].GridSize = 4;
List[7].Pieces = [Piece1, Piece2, Piece3, Piece5, Piece6, Piece7];
List[8] = new Level();
List[8].GridSize = 4;
List[8].Pieces = [Piece1, Piece3, Piece4, Piece5, Piece6, Piece8];
List[9] = new Level();
List[9].GridSize = 5;
List[9].Pieces = [Piece2, Piece3, Piece4, Piece6, Piece7, Piece7, Piece8, Piece9];
List[10] = new Level();
List[10].GridSize = 5;
List[10].Pieces = [Piece2, Piece3, Piece4, Piece5, Piece6, Piece7, Piece9, Piece9];
List[11] = new Level();
List[11].GridSize = 5;
List[11].Pieces = [Piece2, Piece3, Piece4, Piece5, Piece5, Piece6, Piece9, Piece9];
List[12] = new Level();
List[12].GridSize = 5;
List[12].Pieces = [Piece2, Piece3, Piece3, Piece5, Piece6, Piece7, Piece8, Piece9];
List[13] = new Level();
List[13].GridSize = 6;
List[13].Pieces = [Piece2, Piece3, Piece4, Piece5, Piece6, Piece7, Piece7, Piece8, Piece8, Piece8, Piece9];
List[14] = new Level();
List[14].GridSize = 6;
List[14].Pieces = [Piece2, Piece2, Piece3, Piece5, Piece5, Piece6, Piece7, Piece7, Piece8, Piece8, Piece9];
List[15] = new Level();
List[15].GridSize = 6;
List[15].Pieces = [Piece5, Piece4, Piece3, Piece9, Piece4, Piece6, Piece4, Piece9, Piece6, Piece3, Piece3, Piece3, Piece7];
List[16] = new Level();
List[16].GridSize = 6;
List[16].Pieces = [Piece4, Piece7, Piece4, Piece4, Piece6, Piece2, Piece7, Piece3, Piece9, Piece7, Piece4, Piece4, Piece1, Piece1, Piece3];
List[17] = new Level();
List[17].GridSize = 8;
List[17].Pieces = [Piece3, Piece4, Piece4, Piece5, Piece9, Piece8, Piece7, Piece2, Piece6, Piece7, Piece4, Piece6, Piece7, Piece4, Piece5, Piece4, Piece6, Piece6, Piece3, Piece3, Piece3, Piece1, Piece1, Piece1, Piece1];
List[18] = new Level();
List[18].GridSize = 8;
List[18].Pieces = [Piece5, Piece4, Piece3, Piece4, Piece2, Piece2, Piece4, Piece7, Piece3, Piece7, Piece4, Piece9, Piece7, Piece3, Piece3, Piece8, Piece7, Piece8, Piece4, Piece6, Piece4, Piece7, Piece1, Piece1, Piece1, Piece1];
List[19] = new Level();
List[19].GridSize = 8;
List[19].Pieces = [Piece4, Piece4, Piece3, Piece8, Piece7, Piece7, Piece9, Piece4, Piece3, Piece3, Piece7, Piece6, Piece7, Piece6, Piece5, Piece3, Piece5, Piece4, Piece8, Piece9, Piece7, Piece3, Piece1];
}
}//package Game.Engine
Section 13
//Piece1 (Game.Engine.Piece1)
package Game.Engine {
import flash.display.*;
public dynamic class Piece1 extends MovieClip {
}
}//package Game.Engine
Section 14
//Piece2 (Game.Engine.Piece2)
package Game.Engine {
import flash.display.*;
public dynamic class Piece2 extends MovieClip {
}
}//package Game.Engine
Section 15
//Piece3 (Game.Engine.Piece3)
package Game.Engine {
import flash.display.*;
public dynamic class Piece3 extends MovieClip {
}
}//package Game.Engine
Section 16
//Piece4 (Game.Engine.Piece4)
package Game.Engine {
import flash.display.*;
public dynamic class Piece4 extends MovieClip {
}
}//package Game.Engine
Section 17
//Piece5 (Game.Engine.Piece5)
package Game.Engine {
import flash.display.*;
public dynamic class Piece5 extends MovieClip {
}
}//package Game.Engine
Section 18
//Piece6 (Game.Engine.Piece6)
package Game.Engine {
import flash.display.*;
public dynamic class Piece6 extends MovieClip {
}
}//package Game.Engine
Section 19
//Piece7 (Game.Engine.Piece7)
package Game.Engine {
import flash.display.*;
public dynamic class Piece7 extends MovieClip {
}
}//package Game.Engine
Section 20
//Piece8 (Game.Engine.Piece8)
package Game.Engine {
import flash.display.*;
public dynamic class Piece8 extends MovieClip {
}
}//package Game.Engine
Section 21
//Piece9 (Game.Engine.Piece9)
package Game.Engine {
import flash.display.*;
public dynamic class Piece9 extends MovieClip {
}
}//package Game.Engine
Section 22
//World (Game.Engine.World)
package Game.Engine {
import flash.display.*;
import flash.events.*;
import mochi.as3.*;
import Game.*;
import SWFStats.*;
import flash.geom.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.filters.*;
public class World extends MovieClip {
public var QuitButton:SimpleButton;
public var RestartButton:SimpleButton;
public var LevelDisplay:TextField;
public var PauseButton:SimpleButton;
public var PlayMoreGamesButton:SimpleButton;
public var TimeDisplay:TextField;
public var SoundButton:SimpleButton;
public var MusicButton:SimpleButton;
private var Paused:Boolean;// = false
private var GameTimer:Timer;
private var Time:MochiDigits;
private var CurrentTime:MochiDigits;
private var PauseMessage:ClickToContinue;
private var CurrentLevel:Level;
private var CurrentLevelNumber:MochiDigits;
private var Dragging:MovieClip;// = null
private var Grid:MovieClip;
private var PieceClip:MovieClip;
private var PieceScale:Number;
private var MouseX:int;
private var MouseY:int;
private var Snap:int;
private var OffsetX:Number;
private var OffsetY:Number;
private var Pieces:Array;
private var GoToLeaderboards:Boolean;// = false
private var SubmitScore:Boolean;// = false
private var RandomMode:Boolean;// = false
private var BeginMessage:ClickToBegin;
private var TransitionImage:Bitmap;
private var TransitionMoveAmount:Number;// = 1
public function World(randommode:Boolean=false, level:int=0){
var n:int;
Time = new MochiDigits(0);
CurrentTime = new MochiDigits(0);
CurrentLevelNumber = new MochiDigits(0);
super();
this.RandomMode = randommode;
this.CurrentLevelNumber.setValue(level);
this.SubmitScore = true;
if (level > 0){
n = level;
while (n > 0) {
this.Time.addValue((n * 5));
n--;
};
};
this.SoundButton.addEventListener(MouseEvent.CLICK, this.Sound);
this.MusicButton.addEventListener(MouseEvent.CLICK, this.Music);
this.RestartButton.addEventListener(MouseEvent.CLICK, this.Restart);
this.PauseButton.addEventListener(MouseEvent.CLICK, this.Pause);
this.QuitButton.addEventListener(MouseEvent.CLICK, this.Quit);
this.PlayMoreGamesButton.addEventListener(MouseEvent.CLICK, this.PlayMoreGames);
this.Grid = new MovieClip();
this.Grid.x = 270;
this.Grid.y = 10;
this.addChild(this.Grid);
this.PieceClip = new MovieClip();
this.addChild(this.PieceClip);
if (Main.MusicOn){
SoundManager.StartMusic();
};
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
var i:int;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.y = -380;
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionIn);
}
private function Tick(e:Event){
if (((this.Paused) || ((this.Dragging == null)))){
return;
};
trace("ok ... ");
var prevx:Number = this.Dragging.x;
var prevy:Number = this.Dragging.y;
var oldwidth:Number = this.Dragging.width;
var oldheight:Number = this.Dragging.height;
if (this.MouseX > 274){
if (this.Dragging.scaleX < this.PieceScale){
this.Dragging.scaleX = (this.Dragging.scaleY = (this.Dragging.scaleX + 0.1));
} else {
if (this.Dragging.scaleX > this.PieceScale){
this.Dragging.scaleX = (this.Dragging.scaleY = this.PieceScale);
};
};
} else {
if (this.Dragging.scaleX > 0.5){
this.Dragging.scaleX = (this.Dragging.scaleY = (this.Dragging.scaleX - 0.1));
} else {
this.Dragging.scaleX = (this.Dragging.scaleY = 0.5);
};
};
var ox:int = ((this.Dragging.x > prevx)) ? 1 : -1;
var oy:int = ((this.Dragging.y > prevy)) ? 1 : -1;
this.Dragging.x = (this.Dragging.x + (ox * ((this.Dragging.width > oldwidth)) ? ((this.Dragging.width - oldwidth) / 2) : -(((oldwidth - this.Dragging.width) / 2))));
this.Dragging.y = (this.Dragging.y + (oy * ((this.Dragging.height > oldheight)) ? ((this.Dragging.height - oldheight) / 2) : -(((oldheight - this.Dragging.height) / 2))));
if (this.Dragging.x > 640){
this.Dragging.x = 630;
} else {
if (this.Dragging.x < 0){
this.Dragging.x = 10;
};
};
if (this.Dragging.y > 380){
this.Dragging.y = 370;
} else {
if (this.Dragging.y < 0){
this.Dragging.y = 10;
};
};
}
private function Begin(e:MouseEvent):void{
var generating:Generating;
this.removeChild(this.BeginMessage);
this.Paused = false;
this.GameTimer = new Timer(1000);
this.GameTimer.addEventListener(TimerEvent.TIMER, this.Clock);
this.TimeDisplay.text = FormatTime(0);
if (this.RandomMode){
generating = new Generating();
this.addChild(generating);
setTimeout(this.Begin2, 500);
return;
};
this.SetupLevel();
this.addEventListener(Event.ENTER_FRAME, this.Tick);
this.GameTimer.start();
}
private function Begin2():void{
this.SetupLevel();
this.addEventListener(Event.ENTER_FRAME, this.Tick);
this.GameTimer.start();
}
private function SetupLevel():void{
var i:int;
var piece:MovieClip;
while (this.PieceClip.numChildren > 0) {
this.PieceClip.removeChildAt(0);
};
this.CurrentLevel = (this.RandomMode) ? Level.Random() : Levels.List[this.CurrentLevelNumber.value];
this.LevelDisplay.text = (this.RandomMode) ? "RANDOM" : ("LEVEL " + (this.CurrentLevelNumber.value + 1));
this.CurrentTime.setValue(0);
var lines:int = (this.CurrentLevel.GridSize - 1);
var boxsize:int = (360 / this.CurrentLevel.GridSize);
this.Grid.graphics.clear();
this.Grid.graphics.lineStyle(0.1, 0xFFFFFF, 1);
i = 1;
while (i < (lines + 1)) {
this.Grid.graphics.moveTo((i * boxsize), 0);
this.Grid.graphics.lineTo((i * boxsize), 360);
this.Grid.graphics.moveTo(0, (i * boxsize));
this.Grid.graphics.lineTo(360, (i * boxsize));
i++;
};
this.Grid.graphics.endFill();
this.Snap = boxsize;
this.PieceScale = (boxsize / 100);
this.Pieces = new Array();
i = 0;
while (i < this.CurrentLevel.Pieces.length) {
piece = new (this.CurrentLevel.Pieces[i]);
piece.addEventListener(MouseEvent.MOUSE_DOWN, this.DragPiece);
piece.buttonMode = true;
piece.mouseChildren = false;
piece.useHandCursor = true;
piece.scaleX = (piece.scaleY = 0.5);
piece.x = (14 + (Math.random() * 250));
piece.y = (60 + (Math.random() * 220));
piece.filters = [new BevelFilter(2, 45, 0xFFFFFF)];
piece.Snapped = false;
piece.Colour = (0xFFFFFF * Math.random());
if ((piece.x + piece.width) > 264){
piece.x = (264 - piece.width);
};
if ((piece.y + piece.height) > 310){
piece.y = (310 - piece.height);
};
this.PieceClip.addChild(piece);
this.Pieces.push(piece);
i++;
};
if (this.CurrentLevel.Solution){
this.CurrentLevel.Solution.x = 50;
this.CurrentLevel.Solution.y = 50;
this.CurrentLevel.Solution.scaleX = 0.5;
this.CurrentLevel.Solution.scaleY = 0.5;
this.addChild(this.CurrentLevel.Solution);
};
this.addEventListener(Event.ENTER_FRAME, this.Tick);
}
private function DragPiece(e:MouseEvent):void{
var piece:MovieClip = (e.target as MovieClip);
piece.startDrag(false, new Rectangle(0, 0, 640, 380));
piece.alpha = 0.6;
this.Dragging = piece;
this.Dragging.PreviousX = this.Dragging.x;
this.Dragging.PreviousY = this.Dragging.y;
this.ResetPiece(e);
this.OffsetX = (e.localX / piece.width);
this.OffsetY = (e.localY / piece.height);
Main.STAGE.addEventListener(MouseEvent.MOUSE_UP, this.PutPiece);
Main.STAGE.addEventListener(MouseEvent.MOUSE_MOVE, this.ResetPiece);
this.PieceClip.setChildIndex(this.Dragging, (this.PieceClip.numChildren - 1));
}
private function PutPiece(e:MouseEvent):void{
var localx:int;
var localy:int;
var win:YouHaveWon;
var timage:BitmapData;
this.Dragging.stopDrag();
if (this.MouseX > 274){
this.Dragging.scaleX = (this.Dragging.scaleY = this.PieceScale);
this.Dragging.alpha = 0.7;
this.Dragging.scaleX = (this.Dragging.scaleY = this.PieceScale);
this.Dragging.alpha = 0.7;
localx = (this.Dragging.x - this.Grid.x);
localy = (this.Dragging.y - this.Grid.y);
this.Dragging.x = (this.Grid.x + (Math.round((localx / this.Snap)) * this.Snap));
this.Dragging.y = (this.Grid.y + (Math.round((localy / this.Snap)) * this.Snap));
SoundManager.Play("Bing");
} else {
this.Dragging.scaleX = (this.Dragging.scaleY = 0.5);
this.Dragging.alpha = 1;
};
this.Dragging = null;
Main.STAGE.removeEventListener(MouseEvent.MOUSE_UP, this.PutPiece);
Main.STAGE.removeEventListener(MouseEvent.MOUSE_MOVE, this.ResetPiece);
var clipmatrix:Matrix = new Matrix();
clipmatrix.translate(-(this.Grid.x), -(this.Grid.y));
var pieceimage:BitmapData = new BitmapData(360, 360, true, 4294967295);
pieceimage.draw(this.PieceClip, clipmatrix);
var whitecount:int = pieceimage.threshold(pieceimage, pieceimage.rect, new Point(), "==", 4294967295);
if (whitecount <= 1200){
SaveManager.SaveLevel(this.CurrentLevelNumber.value, this.CurrentTime.value);
this.CurrentLevelNumber.addValue(1);
this.GameTimer.stop();
this.Paused = true;
this.removeEventListener(Event.ENTER_FRAME, this.Tick);
if (((this.RandomMode) || (((!(this.RandomMode)) && ((this.CurrentLevelNumber.value == Levels.List.length)))))){
if (this.RandomMode == false){
this.GoToLeaderboards = true;
};
win = new YouHaveWon();
win.addEventListener(MouseEvent.CLICK, this.Quit);
win.buttonMode = true;
win.mouseChildren = false;
win.useHandCursor = true;
this.addChild(win);
} else {
timage = new BitmapData(360, 360, false, 4294967295);
this.TransitionImage = new Bitmap();
this.TransitionImage.bitmapData = timage;
this.TransitionImage.alpha = 0;
this.TransitionImage.x = this.Grid.x;
this.TransitionImage.y = this.Grid.y;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.EndLevel);
};
};
}
private function EndLevel(e:Event):void{
this.TransitionImage.alpha = (this.TransitionImage.alpha + 0.1);
if (this.TransitionImage.alpha >= 1){
this.removeEventListener(Event.ENTER_FRAME, this.EndLevel);
this.SetupLevel();
this.addEventListener(Event.ENTER_FRAME, this.BeginNextLevel);
};
}
private function BeginNextLevel(e:Event):void{
this.TransitionImage.alpha = (this.TransitionImage.alpha - 0.1);
if (this.TransitionImage.alpha <= 0){
this.removeChild(this.TransitionImage);
this.TransitionImage = null;
this.removeEventListener(Event.ENTER_FRAME, this.BeginNextLevel);
this.Paused = false;
this.GameTimer.start();
this.addEventListener(Event.ENTER_FRAME, this.Tick);
};
}
private function ResetPiece(e:MouseEvent):void{
this.MouseX = e.stageX;
this.MouseY = e.stageY;
}
private function Clock(e:TimerEvent):void{
if (Paused){
return;
};
this.Time.addValue(1);
this.CurrentTime.addValue(1);
this.TimeDisplay.text = FormatTime(this.Time.value);
}
private function Click(e:MouseEvent):void{
this.BeginMessage.removeEventListener(MouseEvent.CLICK, this.Begin);
this.removeChild(this.BeginMessage);
}
private function Pause(e:MouseEvent=null):void{
var i:int;
if (this.Paused){
i = 0;
while (i < this.numChildren) {
this.getChildAt(i).visible = true;
i++;
};
this.Paused = false;
this.removeChild(this.PauseMessage);
this.PauseMessage.removeEventListener(MouseEvent.CLICK, this.Pause);
this.PauseMessage = null;
} else {
i = 0;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.Paused = true;
this.PauseMessage = new ClickToContinue();
this.PauseMessage.addEventListener(MouseEvent.CLICK, this.Pause);
this.PauseMessage.buttonMode = true;
this.PauseMessage.mouseChildren = false;
this.PauseMessage.useHandCursor = true;
this.addChild(this.PauseMessage);
};
}
private function Quit(e:MouseEvent=null):void{
this.Cleanup();
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
var i:int;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionOut);
}
private function PlayMoreGames(e:MouseEvent):void{
Log.CustomMetric("Play more games");
navigateToURL(new URLRequest("http://1pd.org/"), "_blank");
}
private function Restart(e:MouseEvent):void{
this.SetupLevel();
}
private function Sound(e:MouseEvent):void{
Main.SoundOn = !(Main.SoundOn);
}
private function Music(e:MouseEvent):void{
Main.MusicOn = !(Main.MusicOn);
if (Main.MusicOn){
SoundManager.StartMusic();
} else {
SoundManager.StopMusic();
};
}
private function Cleanup():void{
this.GameTimer.stop();
this.GameTimer.removeEventListener(TimerEvent.TIMER, this.Clock);
this.removeEventListener(Event.ENTER_FRAME, this.Tick);
this.QuitButton.removeEventListener(MouseEvent.CLICK, this.Quit);
this.PauseButton.removeEventListener(MouseEvent.CLICK, this.Pause);
this.PlayMoreGamesButton.removeEventListener(MouseEvent.CLICK, this.PlayMoreGames);
SoundManager.StopMusic();
}
private function TransitionIn(e:Event):void{
var i:int;
if (this.TransitionImage.y >= 0){
if (this.BeginMessage == null){
this.BeginMessage = new ClickToBegin();
this.BeginMessage.alpha = 0;
this.BeginMessage.buttonMode = true;
this.BeginMessage.mouseChildren = false;
this.BeginMessage.useHandCursor = true;
this.addChild(this.BeginMessage);
} else {
if (this.BeginMessage.alpha < 1){
this.BeginMessage.alpha = (this.BeginMessage.alpha + 0.1);
} else {
this.removeEventListener(Event.ENTER_FRAME, this.TransitionIn);
this.removeChild(this.TransitionImage);
i = 0;
while (i < this.numChildren) {
this.getChildAt(i).visible = true;
i++;
};
this.BeginMessage.addEventListener(MouseEvent.CLICK, this.Begin);
this.TransitionImage = null;
};
};
return;
};
this.TransitionImage.y = (this.TransitionImage.y + this.TransitionMoveAmount);
if (this.TransitionImage.y > 0){
this.TransitionImage.y = 0;
} else {
if (this.TransitionMoveAmount < 30){
this.TransitionMoveAmount = (this.TransitionMoveAmount * 1.4);
};
};
}
private function TransitionOut(e:Event):void{
if (this.TransitionImage.y > 380){
this.removeEventListener(Event.ENTER_FRAME, this.TransitionOut);
this.parent.addChild(new Menu());
this.parent.removeChild(this);
return;
};
this.TransitionImage.y = (this.TransitionImage.y + this.TransitionMoveAmount);
if (this.TransitionMoveAmount < 30){
this.TransitionMoveAmount = (this.TransitionMoveAmount * 1.4);
};
}
private static function FormatTime(seconds:int):String{
var minutes:int = Math.floor((seconds / 60));
var hours:int = Math.floor((minutes / 60));
seconds = (seconds % 60);
var hoursstr:String = "";
if (hours > 0){
minutes = (minutes % 60);
hoursstr = ((hours < 10)) ? ("0" + hours) : hours.toString();
hoursstr = (hoursstr + ":");
};
var minutesstr:* = ((minutes < 10)) ? ("0" + minutes) : minutes.toString();
var secondsstr:* = ((seconds < 10)) ? ("0" + seconds) : seconds.toString();
return ((((hoursstr + minutesstr) + ":") + secondsstr));
}
}
}//package Game.Engine
Section 23
//YouHaveWon (Game.Engine.YouHaveWon)
package Game.Engine {
import flash.display.*;
public dynamic class YouHaveWon extends MovieClip {
}
}//package Game.Engine
Section 24
//Leaderboards (Game.Leaderboards)
package Game {
import flash.display.*;
public dynamic class Leaderboards extends MovieClip {
}
}//package Game
Section 25
//LevelSelect (Game.LevelSelect)
package Game {
import Game.Engine.*;
import flash.display.*;
import flash.events.*;
import mochi.as3.*;
import SWFStats.*;
import Assets.Menu.*;
import flash.net.*;
public class LevelSelect extends MovieClip {
public var Level13:MovieClip;
public var Level14:MovieClip;
public var Level15:MovieClip;
public var Level1:MovieClip;
public var QuitButton:SimpleButton;
public var Level16:MovieClip;
public var Level2:MovieClip;
public var Level17:MovieClip;
public var Level3:MovieClip;
public var Level18:MovieClip;
public var Level4:MovieClip;
public var Level19:MovieClip;
public var Level5:MovieClip;
public var Level6:MovieClip;
public var Level7:MovieClip;
public var Level8:MovieClip;
public var Level9:MovieClip;
public var Level10:MovieClip;
public var Level20:MovieClip;
public var Level11:MovieClip;
public var Level12:MovieClip;
private var TransitionImage:Bitmap;
private var TransitionMoveAmount:Number;// = 1
private var SelectedLevel:int;// = 0
public function LevelSelect(){
var i:int;
var time:int;
super();
this.QuitButton.addEventListener(MouseEvent.CLICK, this.Quit);
var cookie:SharedObject = SharedObject.getLocal("levels");
i = 1;
while (i < 21) {
this[("Level" + i)].LevelNumber.text = i.toString();
this[("Level" + i)].Level = (i - 1);
if (((!((cookie.data[(i - 1)] == undefined))) || ((((i > 1)) && (!((cookie.data[(i - 2)] == undefined))))))){
time = ((cookie.data[((i - 1) + "_t")])!=undefined) ? cookie.data[((i - 1) + "_t")] : -1;
this[("Level" + i)].gotoAndStop(2);
this[("Level" + i)].BestTime.text = ((time > -1)) ? FormatTime(time) : "";
} else {
if (i == 1){
this[("Level" + i)].gotoAndStop(2);
this[("Level" + i)].LevelNumber.y = (this[("Level" + i)].LevelNumber.y + 4);
} else {
this[("Level" + i)].gotoAndStop(1);
this[("Level" + i)].LevelNumber.y = (this[("Level" + i)].LevelNumber.y + 4);
this[("Level" + i)].LevelNumber.alpha = 0.6;
};
};
if (this[("Level" + i)].currentFrame == 2){
this[("Level" + i)].useHandCursor = true;
this[("Level" + i)].buttonMode = true;
this[("Level" + i)].mouseChildren = false;
this[("Level" + i)].addEventListener(MouseEvent.CLICK, this.StartLevel);
};
i++;
};
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
i = 0;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.y = -380;
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionIn);
}
private function StartLevel(e:MouseEvent):void{
this.SelectedLevel = (e.target as MovieClip).Level;
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
var i:int;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionOutToGame);
}
private function Close(e:MouseEvent):void{
this.QuitButton.removeEventListener(MouseEvent.CLICK, this.Quit);
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
var i:int;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionOut);
}
private function Quit(e:MouseEvent):void{
this.QuitButton.removeEventListener(MouseEvent.CLICK, this.Quit);
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
var i:int;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionOut);
}
private function TransitionIn(e:Event):void{
var i:int;
if (this.TransitionImage.y >= 0){
i = 0;
while (i < this.numChildren) {
this.getChildAt(i).visible = true;
i++;
};
this.removeEventListener(Event.ENTER_FRAME, this.TransitionIn);
this.removeChild(this.TransitionImage);
this.TransitionImage = null;
return;
};
this.TransitionImage.y = (this.TransitionImage.y + this.TransitionMoveAmount);
if (this.TransitionImage.y > 0){
this.TransitionImage.y = 0;
} else {
if (this.TransitionMoveAmount < 30){
this.TransitionMoveAmount = (this.TransitionMoveAmount * 1.4);
};
};
}
private function TransitionOut(e:Event):void{
if (this.TransitionImage.y > 380){
this.removeEventListener(Event.ENTER_FRAME, this.TransitionOut);
this.parent.addChild(new Menu());
this.parent.removeChild(this);
return;
};
this.TransitionImage.y = (this.TransitionImage.y + this.TransitionMoveAmount);
if (this.TransitionMoveAmount < 30){
this.TransitionMoveAmount = (this.TransitionMoveAmount * 1.4);
};
}
private function TransitionOutToGame(e:Event):void{
if (this.TransitionImage.y > 380){
this.removeEventListener(Event.ENTER_FRAME, this.TransitionOutToGame);
this.parent.addChild(new World(false, this.SelectedLevel));
this.parent.removeChild(this);
return;
};
this.TransitionImage.y = (this.TransitionImage.y + this.TransitionMoveAmount);
if (this.TransitionMoveAmount < 30){
this.TransitionMoveAmount = (this.TransitionMoveAmount * 1.4);
};
}
private static function FormatTime(seconds:int):String{
var minutes:int = Math.floor((seconds / 60));
var hours:int = Math.floor((minutes / 60));
seconds = (seconds % 60);
var hoursstr:String = "";
if (hours > 0){
minutes = (minutes % 60);
hoursstr = ((hours < 10)) ? ("0" + hours) : hours.toString();
hoursstr = (hoursstr + ":");
};
var minutesstr:* = ((minutes < 10)) ? ("0" + minutes) : minutes.toString();
var secondsstr:* = ((seconds < 10)) ? ("0" + seconds) : seconds.toString();
return ((((hoursstr + minutesstr) + ":") + secondsstr));
}
}
}//package Game
Section 26
//Main (Game.Main)
package Game {
import flash.display.*;
import flash.events.*;
import SWFStats.*;
public class Main extends MovieClip {
public var _mochiads_game_id:String;
public static var STAGE:Stage;
public static var SoundOn:Boolean = true;
public static var MusicOn:Boolean = true;
public function Main(){
super();
addFrameScript(0, frame1);
this.addEventListener(Event.ADDED_TO_STAGE, PreInitialise);
}
private function PreInitialise(e:Event):void{
this.gotoAndStop(1);
Log.View(93, "f87a8861-74ec-4b1e-84a7-c7975b50e0df", root.loaderInfo.loaderURL);
STAGE = stage;
loaderInfo.addEventListener(Event.COMPLETE, Initialise);
}
private function Initialise(e:Event):void{
this.gotoAndStop(3);
SoundOn = SaveManager.SoundEnabled();
MusicOn = SaveManager.MusicEnabled();
this.addChild(new Menu());
}
function frame1(){
_mochiads_game_id = "ca0ab9a429c2af64";
}
}
}//package Game
Section 27
//Menu (Game.Menu)
package Game {
import Game.Engine.*;
import flash.display.*;
import flash.events.*;
import SWFStats.*;
import flash.net.*;
public class Menu extends MovieClip {
public var PlayGameButton:SimpleButton;
public var PlayMoreGamesButton:SimpleButton;
public var iPhone:MovieClip;
public var RandomLevelButton:SimpleButton;
private var TransitionImage:Bitmap;
private var TransitionMoveAmount:Number;// = 1
private var GoToRandom:Boolean;// = false
public function Menu(){
super();
this.PlayGameButton.addEventListener(MouseEvent.CLICK, this.Play);
this.RandomLevelButton.addEventListener(MouseEvent.CLICK, this.Random);
this.PlayMoreGamesButton.addEventListener(MouseEvent.CLICK, this.PlayMoreGames);
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
var i:int;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.y = -380;
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionIn);
this.iPhone.addEventListener(MouseEvent.CLICK, this.AppStore);
this.iPhone.buttonMode = true;
this.iPhone.useHandCursor = true;
}
private function Play(e:MouseEvent):void{
Log.Play();
this.Close();
}
private function Random(e:MouseEvent):void{
Log.Play();
this.GoToRandom = true;
this.Close();
}
private function AppStore(e:MouseEvent):void{
Log.CustomMetric("Clicked iPhone Link");
navigateToURL(new URLRequest("http://oneappatatime.com/games/18-squarethere/website"), "_blank");
}
private function PlayMoreGames(e:MouseEvent):void{
Log.CustomMetric("Play more games");
navigateToURL(new URLRequest("http://1pd.org/"), "_blank");
}
private function Close():void{
this.PlayGameButton.removeEventListener(MouseEvent.CLICK, this.Play);
this.PlayMoreGamesButton.removeEventListener(MouseEvent.CLICK, this.PlayMoreGames);
var image:BitmapData = new BitmapData(640, 380, false);
image.draw(this);
var i:int;
while (i < this.numChildren) {
this.getChildAt(i).visible = false;
i++;
};
this.TransitionImage = new Bitmap();
this.TransitionImage.bitmapData = image;
this.TransitionImage.smoothing = true;
this.addChild(this.TransitionImage);
this.addEventListener(Event.ENTER_FRAME, this.TransitionOut);
}
private function TransitionIn(e:Event):void{
var i:int;
if (this.TransitionImage.y >= 0){
i = 0;
while (i < this.numChildren) {
this.getChildAt(i).visible = true;
i++;
};
this.removeEventListener(Event.ENTER_FRAME, this.TransitionIn);
this.removeChild(this.TransitionImage);
this.TransitionImage = null;
return;
};
this.TransitionImage.y = (this.TransitionImage.y + this.TransitionMoveAmount);
if (this.TransitionImage.y > 0){
this.TransitionImage.y = 0;
} else {
if (this.TransitionMoveAmount < 30){
this.TransitionMoveAmount = (this.TransitionMoveAmount * 1.4);
};
};
}
private function TransitionOut(e:Event):void{
if (this.TransitionImage.y > 380){
this.removeEventListener(Event.ENTER_FRAME, this.TransitionOut);
if (this.GoToRandom){
this.parent.addChild(new World(this.GoToRandom));
} else {
this.parent.addChild(new LevelSelect());
};
this.parent.removeChild(this);
return;
};
this.TransitionImage.y = (this.TransitionImage.y + this.TransitionMoveAmount);
if (this.TransitionMoveAmount < 30){
this.TransitionMoveAmount = (this.TransitionMoveAmount * 1.4);
};
}
}
}//package Game
Section 28
//SaveManager (Game.SaveManager)
package Game {
import flash.net.*;
public class SaveManager {
public static function SoundEnabled():Boolean{
var cookie:SharedObject = SharedObject.getLocal("settings");
if (cookie.data["sound"] == undefined){
return (true);
};
return ((cookie.data["sound"] == "0"));
}
public static function MusicEnabled():Boolean{
var cookie:SharedObject = SharedObject.getLocal("settings");
if (cookie.data["music"] == undefined){
return (true);
};
return ((cookie.data["music"] == "0"));
}
public static function SaveSettings():void{
var cookie:SharedObject = SharedObject.getLocal("settings");
cookie.data["sound"] = (Main.SoundOn) ? "0" : "1";
cookie.data["music"] = (Main.MusicOn) ? "0" : "1";
cookie.flush();
}
public static function HasLevel(n:int):Boolean{
var cookie:SharedObject = SharedObject.getLocal("levels");
if (cookie.data[n] == undefined){
return (false);
};
return (true);
}
public static function BestTime(n:int):int{
var cookie:SharedObject = SharedObject.getLocal("levels");
if (cookie.data[(n + "_t")] == undefined){
return (-1);
};
return (int(cookie.data[(n + "_t")]));
}
public static function SaveLevel(n:int, time:int):void{
trace(((("Saving level " + n) + ",") + time));
var cookie:SharedObject = SharedObject.getLocal("levels");
cookie.data[n] = "0";
var oldtime:int = BestTime(n);
if ((((oldtime <= 0)) || ((time < oldtime)))){
trace(("Committing time " + time));
cookie.data[(n + "_t")] = time.toString();
};
cookie.flush();
}
}
}//package Game
Section 29
//SoundManager (Game.SoundManager)
package Game {
import flash.events.*;
import Assets.Sounds.*;
import flash.media.*;
import flash.utils.*;
public class SoundManager {
private static var Sounds:Dictionary;
private static var Music:SoundChannel;
private static var Fireworks:SoundChannel;
private static var NumSounds:int;
public static function Play(sound:String):void{
if (Sounds == null){
Init();
};
if ((((Main.SoundOn == false)) || ((NumSounds > 20)))){
return;
};
NumSounds++;
var channel:SoundChannel = Sounds[sound].play(0, 0);
channel.addEventListener(Event.SOUND_COMPLETE, Decrease);
}
private static function Decrease(e:Event):void{
NumSounds--;
}
public static function StartMusic():void{
if (Sounds == null){
Init();
};
var t:SoundTransform = new SoundTransform();
t.volume = 0.1;
Music = new Music().play(0, int.MAX_VALUE);
Music.soundTransform = t;
}
public static function StopMusic():void{
if (Music != null){
Music.stop();
};
}
private static function Init():void{
Sounds = new Dictionary();
Sounds["Bing"] = new Bing();
}
}
}//package Game
Section 30
//Effect (InFlashStudios.Effect)
package InFlashStudios {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Effect extends Bitmap {
private var Target:MovieClip;
private var OnComplete:Function;
private var Acceleration:Number;
private var TempFullImage:BitmapData;
private var TempSmallImage:BitmapData;
private var CopyRegion:Rectangle;
private var ZeroPoint:Point;
private var Tansform:ColorTransform;
private var TransformRegion:Rectangle;
public function Effect(target:MovieClip, oncomplete:Function){
CopyRegion = new Rectangle();
ZeroPoint = new Point(0, 0);
Tansform = new ColorTransform();
TransformRegion = new Rectangle();
super();
this.x = (target.x - 10);
this.y = (target.y - 10);
this.Target = target;
this.OnComplete = oncomplete;
this.Acceleration = 8;
this.CopyRegion.width = 21;
this.CopyRegion.height = (target.height + 20);
this.TransformRegion.x = 0;
this.TransformRegion.y = 0;
this.TransformRegion.width = 1;
this.TransformRegion.height = (target.height + 20);
this.addEventListener(Event.ENTER_FRAME, this.Tick);
target.parent.addChild(this);
this.RenderImage();
}
private function Tick(e:Event):void{
this.x = (this.x + this.Acceleration);
if (this.x < ((this.Target.x + this.Target.width) + 10)){
this.RenderImage();
return;
};
this.removeEventListener(Event.ENTER_FRAME, this.Tick);
this.parent.removeChild(this);
if (this.OnComplete != null){
this.OnComplete();
};
}
private function RenderImage():void{
this.CopyRegion.x = this.x;
this.CopyRegion.y = this.y;
this.visible = false;
this.TempFullImage = new BitmapData(this.Target.parent.width, this.Target.parent.height, true);
this.TempFullImage.draw(this.Target.parent);
this.visible = true;
this.TempSmallImage = new BitmapData(this.CopyRegion.width, this.CopyRegion.height, true);
this.TempSmallImage.copyPixels(this.TempFullImage, this.CopyRegion, this.ZeroPoint);
var xcenter = 11;
var co:Number = 1;
var x:int;
while (x < this.TempSmallImage.width) {
if (x < xcenter){
co = (co + 0.1);
} else {
if (x > xcenter){
co = (co - 0.1);
};
};
this.Tansform.redMultiplier = co;
this.Tansform.blueMultiplier = co;
this.Tansform.greenMultiplier = co;
this.TransformRegion.x = x;
this.TempSmallImage.colorTransform(this.TransformRegion, this.Tansform);
x++;
};
this.bitmapData = this.TempSmallImage;
}
}
}//package InFlashStudios
Section 31
//Splash (InFlashStudios.Splash)
package InFlashStudios {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class Splash extends MovieClip {
public var Logo:MovieClip;
private var Counter:int;// = 0
private var OnComplete:Function;
private var Ticker:Timer;
public function Splash(holder:Stage=null, oncomplete:Function=null){
super();
if ((((holder == null)) || ((oncomplete == null)))){
return;
};
holder.addChild(this);
this.OnComplete = oncomplete;
this.Logo.buttonMode = true;
this.Logo.mouseChildren = false;
this.Logo.useHandCursor = true;
this.addEventListener(MouseEvent.CLICK, this.OpenIFS);
new Effect(this.Logo, this.Initialise);
}
private function Initialise():void{
this.Ticker = new Timer(25);
this.Ticker.addEventListener(TimerEvent.TIMER, this.Tick);
this.Ticker.start();
}
private function Tick(e:Event):void{
this.Counter++;
if (this.alpha <= 0){
this.Ticker.removeEventListener(TimerEvent.TIMER, this.Tick);
this.parent.removeChild(this);
return;
};
if (this.Counter > 50){
this.alpha = (this.alpha - 0.05);
if (this.OnComplete != null){
this.OnComplete();
this.OnComplete = null;
this.mouseChildren = false;
this.cacheAsBitmap = true;
this.parent.setChildIndex(this, (this.parent.numChildren - 1));
};
};
}
private function OpenIFS(e:MouseEvent):void{
navigateToURL(new URLRequest("http://1pd.org/"), "_blank");
}
}
}//package InFlashStudios
Section 32
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Fragment:Number;
private var Sibling:MochiDigits;
private var Encoder:Number;
public function MochiDigits(digit:Number=0, index:uint=0):void{
super();
Encoder = 0;
setValue(digit, index);
}
public function get value():Number{
return (Number(this.toString()));
}
public function set value(v:Number):void{
setValue(v);
}
public function addValue(inc:Number):void{
value = (value + inc);
}
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 reencode():void{
var newEncode:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (newEncode ^ Encoder));
Encoder = newEncode;
}
public function toString():String{
var s:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
s = (s + Sibling.toString());
};
return (s);
}
}
}//package mochi.as3
Section 33
//AssetLoader_1 (SquareThere_fla.AssetLoader_1)
package SquareThere_fla {
import flash.display.*;
public dynamic class AssetLoader_1 extends MovieClip {
public function AssetLoader_1(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package SquareThere_fla
Section 34
//SoundLoader_14 (SquareThere_fla.SoundLoader_14)
package SquareThere_fla {
import flash.display.*;
public dynamic class SoundLoader_14 extends MovieClip {
public function SoundLoader_14(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package SquareThere_fla
Section 35
//Log (SWFStats.Log)
package SWFStats {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.external.*;
public final class Log {
private static const PingF:Timer = new Timer(60000);
private static const PingR:Timer = new Timer(30000);
public static var Enabled:Boolean = false;
public static var Queue:Boolean = true;
public static var SWFID:int = 0;
public static var GUID:String = "";
public static var SourceUrl:String;
private static var Request:LogRequest = new LogRequest();
private static var FirstPing:Boolean = true;
private static var Pings:int = 0;
private static var Plays:int = 0;
private static var HighestGoal:int = 0;
public static function View(swfid:int=0, guid:String="", defaulturl:String=""):void{
if (SWFID > 0){
return;
};
SWFID = swfid;
GUID = guid;
Enabled = true;
if ((((SWFID == 0)) || ((GUID == "")))){
Enabled = false;
return;
};
if (((((!((defaulturl.indexOf("http://") == 0))) && (!((Security.sandboxType == "localWithNetwork"))))) && (!((Security.sandboxType == "localTrusted"))))){
Enabled = false;
return;
};
SourceUrl = GetUrl(defaulturl);
if ((((SourceUrl == null)) || ((SourceUrl == "")))){
Enabled = false;
return;
};
Security.allowDomain("http://tracker.swfstats.com/");
Security.allowInsecureDomain("http://tracker.swfstats.com/");
Security.loadPolicyFile("http://tracker.swfstats.com/crossdomain.xml");
Security.allowDomain("http://utils.swfstats.com/");
Security.allowInsecureDomain("http://utils.swfstats.com/");
Security.loadPolicyFile("http://utils.swfstats.com/crossdomain.xml");
var views:int = GetCookie("views");
views++;
SaveCookie("views", views);
Send(("v/" + views), true);
PingF.addEventListener(TimerEvent.TIMER, PingServer);
PingF.start();
}
public static function Play():void{
if (!Enabled){
return;
};
Plays++;
Send(("p/" + Plays));
}
public static function Goal(n:int, name:String):void{
}
private static function PingServer(... _args):void{
if (!Enabled){
return;
};
Pings++;
Send(((("t/" + (FirstPing) ? "y" : "n") + "/") + Pings), true);
if (FirstPing){
PingF.stop();
PingR.addEventListener(TimerEvent.TIMER, PingServer);
PingR.start();
FirstPing = false;
};
}
public static function CustomMetric(name:String, group:String=null):void{
if (!Enabled){
return;
};
if (group == null){
group = "";
};
Send(((("c/" + Clean(name)) + "/") + Clean(group)));
}
public static function LevelCounterMetric(name:String, level):void{
if (!Enabled){
return;
};
Send(((("lc/" + Clean(name)) + "/") + Clean(level)));
}
public static function LevelRangedMetric(name:String, level, value:int):void{
if (!Enabled){
return;
};
Send(((((("lr/" + Clean(name)) + "/") + Clean(level)) + "/") + value));
}
public static function LevelAverageMetric(name:String, level, value:int):void{
if (!Enabled){
return;
};
Send(((((("la/" + Clean(name)) + "/") + Clean(level)) + "/") + value));
}
private static function Send(s:String, view:Boolean=false):void{
Request.Queue(s);
if (((((Request.Ready) || (view))) || (!(Queue)))){
Request.Send();
Request = new LogRequest();
};
}
private static function Clean(s:String):String{
return (escape(s.replace("/", "\\").replace("~", "-")));
}
private static function GetCookie(n:String):int{
var cookie:SharedObject = SharedObject.getLocal("swfstats");
if (cookie.data[n] == undefined){
return (0);
};
return (int(cookie.data[n]));
}
private static function SaveCookie(n:String, v:int):void{
var cookie:SharedObject = SharedObject.getLocal("swfstats");
cookie.data[n] = v.toString();
cookie.flush();
}
private static function GetUrl(defaulturl:String):String{
var url:String;
var defaulturl = defaulturl;
if (ExternalInterface.available){
url = String(ExternalInterface.call("window.location.href.toString"));
//unresolved jump
var _slot1 = s;
url = defaulturl;
} else {
if (defaulturl.indexOf("http://") == 0){
url = defaulturl;
};
};
if ((((((url == null)) || ((url == "")))) || ((url == "null")))){
if ((((Security.sandboxType == "localWithNetwork")) || ((Security.sandboxType == "localTrusted")))){
url = "http://local-testing/";
} else {
url = null;
};
};
return (escape(url));
}
}
}//package SWFStats
Section 36
//LogRequest (SWFStats.LogRequest)
package SWFStats {
import flash.events.*;
import flash.net.*;
public final class LogRequest {
private var Data:String;// = ""
private var Pieces:int;
public var Ready:Boolean;// = false
private static var Failed:int = 0;
public function LogRequest(){
super();
}
public function Queue(data:String):void{
if (Failed > 3){
return;
};
this.Pieces++;
this.Data = (this.Data + (((this.Data == "")) ? "" : "~" + data));
if ((((this.Pieces == 8)) || ((this.Data.length > 300)))){
this.Ready = true;
};
}
public function Send():void{
var sendaction:URLLoader = new URLLoader();
sendaction.addEventListener(IOErrorEvent.IO_ERROR, this.IOErrorHandler);
sendaction.addEventListener(HTTPStatusEvent.HTTP_STATUS, this.StatusChange);
sendaction.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.SecurityErrorHandler);
sendaction.load(new URLRequest((((((((((("http://tracker.swfstats.com/Games/q.aspx?guid=" + Log.GUID) + "&swfid=") + Log.SWFID) + "&q=") + this.Data) + "&url=") + Log.SourceUrl) + "&") + Math.random()) + "z")));
trace((((((((((("http://tracker.swfstats.com/Games/q.aspx?guid=" + Log.GUID) + "&swfid=") + Log.SWFID) + "&q=") + this.Data) + "&url=") + Log.SourceUrl) + "&") + Math.random()) + "z"));
}
private function IOErrorHandler(e:IOErrorEvent):void{
Failed++;
}
private function SecurityErrorHandler(e:SecurityErrorEvent):void{
}
private function StatusChange(e:HTTPStatusEvent):void{
}
}
}//package SWFStats