Section 1
//KongregateEvent (com.kongregate.as3.client.events.KongregateEvent)
package com.kongregate.as3.client.events {
import flash.events.*;
public class KongregateEvent extends Event {
public static const COMPLETE:String = "component_api_available";
public function KongregateEvent(_arg1:String){
super(_arg1);
}
}
}//package com.kongregate.as3.client.events
Section 2
//AbstractShadowService (com.kongregate.as3.client.services.AbstractShadowService)
package com.kongregate.as3.client.services {
import flash.events.*;
public class AbstractShadowService extends EventDispatcher {
protected function alert(_arg1:String, _arg2:String, _arg3="", _arg4:String=""):void{
trace(((((((("Kongregate API: " + _arg1) + ".") + _arg2) + "(") + _arg3) + ") ") + _arg4));
}
}
}//package com.kongregate.as3.client.services
Section 3
//HighScoreServiceShadow (com.kongregate.as3.client.services.HighScoreServiceShadow)
package com.kongregate.as3.client.services {
public class HighScoreServiceShadow extends AbstractShadowService implements IHighScoreServices {
private var mode:String;
public function HighScoreServiceShadow(){
mode = "";
}
public function submit(_arg1:Number, _arg2:String=null):void{
alert("IHighScoreServices", "submit", arguments);
}
public function connect():Boolean{
alert("IKongregateServices", "connect");
return (true);
}
public function requestList(_arg1:Function):void{
alert("IHighScoreServices", "requestList", "", (("[Mode: " + mode) + "]"));
_arg1({success:false});
}
public function setMode(_arg1:String):void{
alert("IHighScoreServices", "setMode", arguments);
this.mode = _arg1;
}
}
}//package com.kongregate.as3.client.services
Section 4
//IHighScoreServices (com.kongregate.as3.client.services.IHighScoreServices)
package com.kongregate.as3.client.services {
public interface IHighScoreServices {
function setMode(_arg1:String):void;
function submit(_arg1:Number, _arg2:String=null):void;
function requestList(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 5
//IKongregateServices (com.kongregate.as3.client.services.IKongregateServices)
package com.kongregate.as3.client.services {
import flash.events.*;
public interface IKongregateServices extends IEventDispatcher {
function getPlayerInfo(_arg1:Function):void;
function connect(_arg1:Number=-1):Boolean;
}
}//package com.kongregate.as3.client.services
Section 6
//IStatServices (com.kongregate.as3.client.services.IStatServices)
package com.kongregate.as3.client.services {
public interface IStatServices {
function submitArray(_arg1:Array):void;
function submit(_arg1:String, _arg2:Number):void;
}
}//package com.kongregate.as3.client.services
Section 7
//IUserServices (com.kongregate.as3.client.services.IUserServices)
package com.kongregate.as3.client.services {
public interface IUserServices {
function getName():String;
function getPlayerInfo(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 8
//KongregateServiceShadow (com.kongregate.as3.client.services.KongregateServiceShadow)
package com.kongregate.as3.client.services {
public class KongregateServiceShadow extends AbstractShadowService implements IKongregateServices {
public function getName():String{
alert("IKongregateServices", "getName");
return ("Guest");
}
public function connect(_arg1:Number=-1):Boolean{
alert("IKongregateServices", "connect", arguments);
return (true);
}
public function getPlayerInfo(_arg1:Function):void{
alert("IKongregateServices", "getPlayerInfo");
_arg1(new Object());
}
}
}//package com.kongregate.as3.client.services
Section 9
//StatServiceShadow (com.kongregate.as3.client.services.StatServiceShadow)
package com.kongregate.as3.client.services {
public class StatServiceShadow extends AbstractShadowService implements IStatServices {
public function submitArray(_arg1:Array):void{
alert("IStatServices", "submitArray", arguments);
}
public function submit(_arg1:String, _arg2:Number):void{
alert("IStatServices", "submitStat", arguments);
}
}
}//package com.kongregate.as3.client.services
Section 10
//UserServiceShadow (com.kongregate.as3.client.services.UserServiceShadow)
package com.kongregate.as3.client.services {
public class UserServiceShadow extends AbstractShadowService implements IUserServices {
public function getName():String{
alert("UserService", "getName");
return ("Guest");
}
public function getPlayerInfo(_arg1:Function):void{
alert("UserService", "getPlayerInfo");
_arg1({isGuest:true, name:"Guest", points:0, level:0, isMode:false, isAdmin:false, isDeveloper:false, avatarPath:"", chatAvatarPath:""});
}
}
}//package com.kongregate.as3.client.services
Section 11
//IAPIBootstrap (com.kongregate.as3.client.IAPIBootstrap)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
public interface IAPIBootstrap {
function init(_arg1:Event=null, _arg2:Stage=null):void;
function hideLog():void;
function showLog(_arg1:int=0):void;
}
}//package com.kongregate.as3.client
Section 12
//KongregateAPI (com.kongregate.as3.client.KongregateAPI)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
import com.kongregate.as3.client.services.*;
import flash.system.*;
import com.kongregate.as3.client.events.*;
import flash.utils.*;
import flash.errors.*;
import flash.net.*;
public class KongregateAPI extends Sprite {
private const VERSION:Number = 1;
private var loader:Loader;
private var loadedDomain:ApplicationDomain;
private static const CLASS_USER:String = "com.kongregate.as3.client.services.UserServices";
private static const CLASS_STATS:String = "com.kongregate.as3.client.services.StatServices";
private static const CLASS_SERVICES:String = "com.kongregate.as3.client.services.KongregateServices";
private static const CLASS_SCORES:String = "com.kongregate.as3.client.services.HighScoreServices";
private static const DEBUG_API_URL:String = "//Linuxpc/kongregate/public/flash/API_AS3.swf";
private static var _connected:Boolean;
private static var kUser:IUserServices;
private static var _loaded:Boolean;
private static var kServices:IKongregateServices;
private static var kScores:IHighScoreServices;
private static var mInstance:KongregateAPI;
private static var kStats:IStatServices;
private static var kAPI:IAPIBootstrap;
public function KongregateAPI(){
if (mInstance != null){
throw (new Error("Warning: KongregateAPI has been added to stage more than once or accessed improperly. Use getInstance() or a stage reference to access."));
};
mInstance = this;
this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
public function get loaded():Boolean{
return (_loaded);
}
public function get connected():Boolean{
return (_connected);
}
private function alertConnected(_arg1:TimerEvent=null):void{
var _local2:KongregateEvent;
var _local3:Boolean;
_local2 = new KongregateEvent(KongregateEvent.COMPLETE);
_local3 = this.dispatchEvent(_local2);
}
private function init(_arg1:Event):void{
var _local2:Object;
var _local3:String;
var _local4:URLRequest;
var _local5:LoaderContext;
this.removeEventListener(Event.ADDED_TO_STAGE, init);
_loaded = false;
_connected = false;
_local2 = LoaderInfo(root.loaderInfo).parameters;
_local3 = _local2.api_path;
if (_local3 == null){
trace("Alert: Kongregate API could not be loaded, due to local testing. API will load when the game is uploaded.");
createShadowServices();
return;
};
Security.allowDomain("*.kongregate.com");
Security.allowDomain("kongregatetrunk.com");
_local4 = new URLRequest(_local3);
_local5 = new LoaderContext(false);
_local5.applicationDomain = ApplicationDomain.currentDomain;
_local5.securityDomain = SecurityDomain.currentDomain;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(_local4, _local5);
}
public function get api():IAPIBootstrap{
return (kAPI);
}
private function loadComplete(_arg1:Event):void{
getServices();
}
public function get scores():IHighScoreServices{
return (kScores);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
throw (new IOError(("API file not found. " + _arg1)));
}
public function get services():IKongregateServices{
return (kServices);
}
public function get stats():IStatServices{
return (kStats);
}
private function createShadowServices():void{
var _local1:Timer;
trace(">>> Kongregate Shadow Services instantiated for local development..");
kServices = new KongregateServiceShadow();
kScores = new HighScoreServiceShadow();
kStats = new StatServiceShadow();
kUser = new UserServiceShadow();
_local1 = new Timer(200, 1);
_local1.addEventListener(TimerEvent.TIMER_COMPLETE, alertConnected);
_local1.start();
_connected = true;
}
public function get user():IUserServices{
return (kUser);
}
private function getServices():void{
var _local1:ApplicationDomain;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = ApplicationDomain.currentDomain;
kAPI = IAPIBootstrap(loader.getChildAt(0));
this.addChild(loader);
_local2 = _local1.getDefinition(CLASS_SERVICES);
trace(_local2);
kServices = _local2.getInstance();
_local3 = _local1.getDefinition(CLASS_SCORES);
kScores = _local3.getInstance();
_local4 = _local1.getDefinition(CLASS_STATS);
kStats = _local4.getInstance();
_local5 = _local1.getDefinition(CLASS_USER);
kUser = _local5.getInstance();
kServices.connect(VERSION);
_loaded = true;
_connected = true;
alertConnected();
}
public static function getInstance():KongregateAPI{
if (!mInstance){
throw (new IllegalOperationError("You must add the Kongregate API component to the stage before attempting to access it."));
};
return (mInstance);
}
}
}//package com.kongregate.as3.client
Section 13
//Common (faze.Common)
package faze {
public class Common {
public static const RIGHT:uint = 1;
public static const LEFT:uint = 3;
public static const BRIDGE:uint = 4;
public static const ROTATOR:uint = 1;
public static const CORNER:uint = 0;
public static const SPLITTER:uint = 2;
public static const UP:uint = 0;
public static const PRISM:uint = 3;
public static const GREEN:uint = 1;
public static const DOWN:uint = 2;
public static const DIR:Array = [[0, -1], [1, 0], [0, 1], [-1, 0]];
public static const RED:uint = 0;
public static const BLUE:uint = 2;
public function Common(){
super();
}
public static function dec(x:int, y:int, dir:int, count:int=1):Array{
return ([(x - (DIR[dir][0] * count)), (y - (DIR[dir][1] * count))]);
}
public static function inc(x:int, y:int, dir:int, count:int=1):Array{
return ([(x + (DIR[dir][0] * count)), (y + (DIR[dir][1] * count))]);
}
public static function rotate(dir:int, forward:Boolean):int{
dir = (dir + (forward) ? 1 : -1);
if (dir < 0){
dir = 3;
};
if (dir > 3){
dir = 0;
};
return (dir);
}
public static function getOutput(block:Array, dirIn:int, colorIn:int):Array{
var p:Array;
var dirOutData:Array;
var dirOut:int;
var colorOut:int;
var dirOutS:Array;
var dirOutR:Array;
var colorOut0:int;
var colorOut1:int;
var x:int = block[0];
var y:int = block[1];
var rot:int = block[2];
var type:int = block[3];
var splitAndPrismData:Array = [[[LEFT, RIGHT], [RIGHT, DOWN], null, [DOWN, LEFT]], [[LEFT, UP], [UP, DOWN], [DOWN, LEFT], null], [null, [UP, RIGHT], [RIGHT, LEFT], [LEFT, UP]], [[UP, RIGHT], null, [RIGHT, DOWN], [DOWN, UP]]];
if (type == CORNER){
dirOutData = [[RIGHT, -1, -1, DOWN], [LEFT, DOWN, -1, -1], [-1, UP, LEFT, -1], [-1, -1, RIGHT, UP]];
dirOut = dirOutData[rot][dirIn];
if (dirOut == -1){
return ([]);
};
return ([[x, y, dirOut, colorIn]]);
} else {
if (type == ROTATOR){
if ((dirIn % 2) == (rot % 2)){
return ([]);
};
colorOut = ((colorIn + 1) % 3);
return ([[x, y, dirIn, colorOut]]);
} else {
if (type == SPLITTER){
dirOutS = splitAndPrismData[rot][dirIn];
if (!dirOutS){
return ([]);
};
return ([[x, y, dirOutS[0], colorIn], [x, y, dirOutS[1], colorIn]]);
} else {
if (type == PRISM){
dirOutR = splitAndPrismData[rot][dirIn];
if (!dirOutR){
return ([]);
};
colorOut0 = ((colorIn + 1) % 3);
colorOut1 = ((colorIn + 2) % 3);
return ([[x, y, dirOutR[0], colorOut0], [x, y, dirOutR[1], colorOut1]]);
} else {
if (type == BRIDGE){
return ([[x, y, dirIn, colorIn]]);
};
};
};
};
};
throw (Error("uh oh"));
}
public static function clamp(n:int, min:int, max:int):int{
if (n < min){
return (min);
};
if (n > max){
return (max);
};
return (n);
}
}
}//package faze
Section 14
//Level (faze.Level)
package faze {
import flash.display.*;
import flash.geom.*;
import mx.core.*;
public class Level {
public var tiles:BitmapData;
public var blocks:Array;
public var floor:Array;
public var index:int;
public var startPoints:Array;
public var endPoints:Array;
public static const Tiles:Class = Level_Tiles;
public static const TILES:int = 16;
private static const DATA:Array = [["Guide the lazer to the exit. Drag with the mouse to move the block and click to rotate it!", [" Y ", " ", " ", " ", " ", " ", " > ", " ", " ", " ", " ", " ", " ", "U ", " ", " "]], ["Use a rotator block to change the color of a lazer! Red-Green-Blue in a clockwise direction!", [" ", " ", " ", " ", " ", " @ ", " ", " ", "N T", " ", " ", " ", " ", " ", " ", " "]], ["", [" G Y ", " ", " ", " ", " @ ", " ", " @ ", " @ ", " @ ", " ", " ", " ", " ", " ", " ", " B M "]], ["Use a splitter block to make two lazers from one!", [" ", " ", " ", " @ ", " ", "H H", " ", " ", " ", " ", " ", " & ", " ", " ", " ", " M "]], ["", [" Y ", " ", " ", " ", " @ ", " ", " & ", " ", "U ", " ", " ", " ", " > ", " ", " ", " J "]], ["Use a prism block to split a lazer into different colors! Red-Green-Blue in a clockwise direction!", [" ", " ", " ", " > ", " ", " * ", " ", "K <", " ", " ", " T", " ", " ", " ", " ", " "]], ["", [" Y ", " ", " ", " & H", " > ", " ", " ", " * ", " N", " ", " * ", " ", "K ", " ", " ", " Y "]], ["A lazer can pass through another using a bridge block!", [" B ", " ", " ", " ", " ", "T T", " ", " + ", " ", " ", " ", " ", "T T", " + ", " ", " B "]], ["", [" G Y ", " ", " + ", " ", "N N", " ", " ", " + ", " ", " ", " + ", "< <", " ", " + ", " ", " G Y "]], ["", [" ", " ", " * ", " ", " + ", " ", "N ", " ", " ", " ", " ", "H N", " ", " ", " > ", " Y M "]], ["", [" Y ", " * ", " ", " + ", " ", " > ", " ", " ", " H", " ", "T T", " ", " N", " ", " & ", " M "]], ["", [" ", " > ", " + N", " > ", " H", " ", " > T", " ", " > ", "T ", " ", "H + ", " > ", "N ", " > ", " + "]], ["Go you!", [" ", " @ ", " @ ", " ", "N ", " ", " T", " & ", " > ", " ", "K ", " ", " & N", " ", " > ", " @ "]], ["", [" B G ", " ", " *", " ", " ", " + * ", " ", " ", " ", "T N", " ", " ", "< T", " ", " + ", " B G "]], ["", ["U * B R", " ", " ", " ", " > ", " ", " > ", " ", " ", " >", " > ", " ", " ", " + ", " ", "R M * U"]], ["", [" ", " & ", " ", "K N", " ", " * ", " ", " ", " * ", " @ ", " ", "U ", " ", " U", " ", " M "]], ["", [" B G ", " *", " ", " ", " ", " * ", " & ", " ", " > ", " ", " ", "H ", " ", " N", " ", " N"]], ["", [" Y B ", " ", " > ", " ", " ", " ", " * ", " ", "< U", " ", " ", " ", " @ ", " * ", " ", " J Y +"]], ["", [" Y ", " & ", " ", " + ", "> ", " ", " ", " ", " ", "H H", " ", " ", " & ", " *", " ", " Y Y Y M "]]];
public static const TILE_PIXELS:int = 32;
public function Level(index:int){
var line:String;
var x:int;
var v:String;
var b:Array;
var t:Array;
var dir:int;
super();
this.index = index;
tiles = new Tiles().bitmapData;
floor = new Array(TILES);
var fx:int;
while (fx < floor.length) {
floor[fx] = new Array(TILES);
fx++;
};
startPoints = [];
endPoints = [];
blocks = [];
var y:int;
while (y < TILES) {
line = DATA[index][1][y];
x = 0;
while (x < TILES) {
v = line.charAt(x);
floor[x][y] = !((v == "#"));
var _local10:int;
var _local11:* = [[">", Common.CORNER], ["@", Common.ROTATOR], ["&", Common.SPLITTER], ["*", Common.PRISM], ["+", Common.BRIDGE]];
for each (b in [[">", Common.CORNER], ["@", Common.ROTATOR], ["&", Common.SPLITTER], ["*", Common.PRISM], ["+", Common.BRIDGE]]) {
if (v == b[0]){
blocks.push([x, y, Math.floor((Math.random() * 4)), b[1]]);
break;
};
};
_local10 = 0;
_local11 = [["RTYU", Common.RED], ["GHJK", Common.GREEN], ["BNM<", Common.BLUE]];
for each (t in [["RTYU", Common.RED], ["GHJK", Common.GREEN], ["BNM<", Common.BLUE]]) {
dir = t[0].indexOf(v);
if (dir != -1){
(pointsOut(x, y, dir)) ? endPoints : startPoints.push([x, y, dir, t[1]]);
break;
};
};
x++;
};
y++;
};
}
public function help():String{
return (DATA[index][0]);
}
private function blockVacant(x:int, y:int):Boolean{
var a:Array = endPoints.concat(blocks);
var i:int;
while (i < a.length) {
if ((((a[i][0] == x)) && ((a[i][1] == y)))){
return (false);
};
i++;
};
return (floor[x][y]);
}
private function getEndpoint(x:int, y:int):Array{
var cur:Array;
var i:int;
while (i < endPoints.length) {
cur = endPoints[i];
if ((((cur[0] == x)) && ((cur[1] == y)))){
return (cur);
};
i++;
};
return (null);
}
private function drawTile(g:Graphics, tx:int, ty:int, x:int, y:int):void{
var m:Matrix = new Matrix();
m.translate(((x - tx) * TILE_PIXELS), ((y - ty) * TILE_PIXELS));
g.beginBitmapFill(tiles, m, true);
g.drawRect((x * TILE_PIXELS), (y * TILE_PIXELS), TILE_PIXELS, TILE_PIXELS);
g.endFill();
}
public function moveBlock(sx:int, sy:int, dx:int, dy:int):Boolean{
var i:int;
var b:Array;
if (blockVacant(dx, dy)){
i = 0;
while (i < blocks.length) {
b = blocks[i];
if ((((b[0] == sx)) && ((b[1] == sy)))){
b[0] = dx;
b[1] = dy;
return (true);
};
i++;
};
};
return (false);
}
public function calcLazers():Array{
var i:int;
var cur:Array;
var cols:Array;
var y:int;
var p:Array;
var newHeads:Array;
var np:Array;
var cb:Array;
var ep:Array;
var free:Function = function (x:int, y:int):Boolean{
if (((!(inside(x, y))) || (!(floor[x][y])))){
return (false);
};
var obs:Array = endPoints.concat(blocks);
var i:int;
while (i < obs.length) {
if ((((obs[i][0] == x)) && ((obs[i][1] == y)))){
return (false);
};
i++;
};
if (cols[x][y]){
return (false);
};
return (true);
};
cols = new Array(TILES);
var x:int;
while (x < TILES) {
cols[x] = new Array(TILES);
y = 0;
while (y < TILES) {
cols[x][y] = null;
y = (y + 1);
};
x = (x + 1);
};
var heads:Array = [];
i = 0;
while (i < startPoints.length) {
cur = startPoints[i];
p = Common.dec(cur[0], cur[1], cur[2]);
heads.push([p[0], p[1], cur[2], cur[3]]);
i = (i + 1);
};
while (heads.length) {
newHeads = [];
while (heads.length) {
cur = heads.pop();
np = Common.inc(cur[0], cur[1], cur[2]);
cb = getBlock(np[0], np[1]);
if (!cb){
if (free(np[0], np[1])){
cols[np[0]][np[1]] = [false, cur[2], cur[3]];
newHeads.push([np[0], np[1], cur[2], cur[3]]);
} else {
ep = getEndpoint(np[0], np[1]);
if (((((ep) && ((ep[2] == cur[2])))) && ((ep[3] == cur[3])))){
cols[np[0]][np[1]] = [true, cur[2], cur[3]];
};
};
} else {
newHeads = newHeads.concat(Common.getOutput(cb, cur[2], cur[3]));
};
};
heads = newHeads;
};
var complete:Boolean;
i = 0;
while (i < endPoints.length) {
cur = endPoints[i];
if (!cols[cur[0]][cur[1]]){
complete = false;
break;
};
i = (i + 1);
};
return ([cols, complete]);
}
private function getBlock(x:int, y:int):Array{
var cur:Array;
var i:int;
while (i < blocks.length) {
cur = blocks[i];
if ((((cur[0] == x)) && ((cur[1] == y)))){
return (cur);
};
i++;
};
return (null);
}
public function isLast():Boolean{
return ((index == (DATA.length - 1)));
}
public function drawFloor(g:Graphics):void{
var y:int;
g.lineStyle();
var x:int;
while (x < TILES) {
y = 0;
while (y < TILES) {
if (floor[x][y]){
drawTile(g, 0, 0, x, y);
};
y++;
};
x++;
};
}
private function pointsOut(x:int, y:int, dir:int):Boolean{
x = (x + Common.DIR[dir][0]);
y = (y + Common.DIR[dir][1]);
return ((((((((x < 0)) || ((y < 0)))) || ((x >= TILES)))) || ((y >= TILES))));
}
public function pixelToTile(x:int, y:int):Array{
return ([Common.clamp((x / TILE_PIXELS), 0, (TILES - 1)), Common.clamp((y / TILE_PIXELS), 0, (TILES - 1))]);
}
public function drawObjects(g:Graphics):void{
var i:int;
var x:int;
var y:int;
var sp:Array;
var b:Array;
var c:Array;
g.lineStyle();
i = 0;
while (i < endPoints.length) {
sp = endPoints[i];
drawTile(g, sp[2], (7 + sp[3]), sp[0], sp[1]);
i++;
};
i = 0;
while (i < blocks.length) {
b = blocks[i];
drawTile(g, b[2], (2 + b[3]), b[0], b[1]);
i++;
};
var lz:Array = calcLazers()[0];
x = 0;
while (x < TILES) {
y = 0;
while (y < TILES) {
c = lz[x][y];
if (c){
drawTile(g, c[1], ((c[0]) ? 13 : 10 + c[2]), x, y);
};
y++;
};
x++;
};
}
public function rotateBlock(x:int, y:int, forward:Boolean):void{
var b:Array;
var i:int;
while (i < blocks.length) {
b = blocks[i];
if ((((b[0] == x)) && ((b[1] == y)))){
b[2] = Common.rotate(b[2], forward);
};
i++;
};
}
public function complete():Boolean{
return (calcLazers()[1]);
}
private function inside(x:int, y:int):Boolean{
return ((((((((x >= 0)) && ((x < TILES)))) && ((y >= 0)))) && ((y < TILES))));
}
public static function numLevels():int{
return (DATA.length);
}
}
}//package faze
Section 15
//Level_Tiles (faze.Level_Tiles)
package faze {
import mx.core.*;
public class Level_Tiles extends BitmapAsset {
}
}//package faze
Section 16
//LevelChangeMask (faze.LevelChangeMask)
package faze {
import flash.events.*;
import flash.display.*;
public class LevelChangeMask extends Sprite {
private var length:int;
private var secondHalf:Boolean;
private var from:Level;
private var startTime:Number;
private var to:Level;
public function LevelChangeMask(parent:Sprite, from:Level, to:Level, length:Number){
var i:int;
var cur:Array;
super();
this.from = from;
this.to = to;
this.length = length;
if (from){
i = 0;
while (i < from.endPoints.length) {
cur = from.endPoints[i];
addSprite(cur[0], cur[1]);
i++;
};
};
addEventListener(Event.ENTER_FRAME, enterFrame);
startTime = new Date().getTime();
parent.addChild(this);
parent.mask = this;
redraw();
}
private function addSprite(tx:int, ty:int):void{
var v:int = (Level.TILES * Level.TILE_PIXELS);
var s:Sprite = new Sprite();
addChild(s);
s.graphics.beginFill(0);
s.graphics.drawCircle(0, 0, (v * 2));
s.x = ((tx + 0.5) * Level.TILE_PIXELS);
s.y = ((ty + 0.5) * Level.TILE_PIXELS);
}
private function enterFrame(e:Event):void{
var i:int;
var cur:Array;
var d:int = (new Date().getTime() - startTime);
if ((((d >= (length / 2))) && (!(secondHalf)))){
while (numChildren) {
removeChildAt(0);
};
if (to){
i = 0;
while (i < to.startPoints.length) {
cur = to.startPoints[i];
addSprite(cur[0], cur[1]);
i++;
};
};
secondHalf = true;
} else {
if (d >= length){
removeEventListener(Event.ENTER_FRAME, enterFrame);
if (parent != null){
parent.mask = null;
parent.removeChild(this);
};
};
};
redraw();
}
private function redraw():void{
var s:Sprite;
var d:Number = (new Date().getTime() - startTime);
var f:Number = (d / length);
f = ((f < 0)) ? 0 : ((f > 1)) ? 1 : f;
f = (secondHalf) ? ((f - 0.5) * 2) : (1 - (f * 2));
var i:int;
while (i < numChildren) {
s = Sprite(getChildAt(i));
s.scaleX = (s.scaleY = f);
i++;
};
}
}
}//package faze
Section 17
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.3.0.4852";
public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
super(bitmapData, pixelSnapping, smoothing);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
}
}//package mx.core
Section 18
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.3.0.4852";
public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
var bitmapData = bitmapData;
var pixelSnapping = pixelSnapping;
var smoothing = smoothing;
super(bitmapData, pixelSnapping, smoothing);
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 19
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.3.0.4852";
public function FontAsset(){
super();
}
}
}//package mx.core
Section 20
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 21
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(void:Point):Point;
function get name():String;
function set width(flash.display:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(flash.display:String):void;
function set scaleX(flash.display:Number):void;
function set scaleY(flash.display:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(flash.display:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(void:Point):Point;
function get height():Number;
function set blendMode(flash.display:String):void;
function get parent():DisplayObjectContainer;
function getBounds(String:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(flash.display:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(flash.display:Number):void;
function set accessibilityProperties(flash.display:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(flash.display:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(flash.display:Number):void;
function set mask(flash.display:DisplayObject):void;
function getRect(String:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(flash.display:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean;
function set opaqueBackground(flash.display:Object):void;
function set visible(flash.display:Boolean):void;
function get mask():DisplayObject;
function set x(flash.display:Number):void;
function set y(flash.display:Number):void;
function get transform():Transform;
function set filters(flash.display:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(flash.display:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 22
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get isDocument():Boolean;
function set repeaters(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function initializeRepeaterArrays(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 23
//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 24
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.3.0.4852";
private static var counter:int = 0;
public function NameUtil(){
super();
}
public static function displayObjectToString(displayObject:DisplayObject):String{
var result:String;
var o:DisplayObject;
var s:String;
var indices:Array;
var displayObject = displayObject;
o = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
//unresolved jump
var _slot1 = e;
return (result);
}
public static function createUniqueName(object:Object):String{
if (!object){
return (null);
};
var name:String = getQualifiedClassName(object);
var index:int = name.indexOf("::");
if (index != -1){
name = name.substr((index + 2));
};
var charCode:int = name.charCodeAt((name.length - 1));
if ((((charCode >= 48)) && ((charCode <= 57)))){
name = (name + "_");
};
return ((name + counter++));
}
}
}//package mx.utils
Section 25
//faze (faze)
package {
import flash.events.*;
import flash.display.*;
import com.kongregate.as3.client.*;
import faze.*;
import mx.core.*;
import flash.text.*;
import flash.utils.*;
public class faze extends Sprite {
private var TuffyItalic:Class;
private var lvlLocked:Boolean;
private var lvl:Level;
private var dragX:int;
private var dragY:int;
private var text:TextField;
private var floorSprite:Sprite;
private var downX:int;
private var Tuffy:Class;
private var objectsSprite:Sprite;
private var downY:int;
public static const LEVEL_CHANGE_LENGTH:int = 4000;
public function faze(){
Tuffy = faze_Tuffy;
TuffyItalic = faze_TuffyItalic;
super();
floorSprite = new Sprite();
addChild(floorSprite);
text = new TextField();
addChild(text);
text.x = 16;
text.y = 8;
text.width = 280;
text.height = 300;
text.selectable = false;
text.embedFonts = true;
text.multiline = true;
text.wordWrap = true;
objectsSprite = new Sprite();
addChild(objectsSprite);
addEventListener(MouseEvent.MOUSE_WHEEL, function (e:MouseEvent):void{
var p:Array;
if (!lvlLocked){
p = lvl.pixelToTile(e.localX, e.localY);
lvl.rotateBlock(p[0], p[1], (e.delta < 0));
levelModified();
};
});
addEventListener(MouseEvent.MOUSE_DOWN, function (e:MouseEvent):void{
var p:Array;
if (!lvlLocked){
p = lvl.pixelToTile(e.localX, e.localY);
dragX = p[0];
dragY = p[1];
downX = p[0];
downY = p[1];
};
});
addEventListener(MouseEvent.MOUSE_MOVE, function (e:MouseEvent):void{
var p:Array;
if (((!(lvlLocked)) && (e.buttonDown))){
p = lvl.pixelToTile(e.localX, e.localY);
if (lvl.moveBlock(dragX, dragY, p[0], p[1])){
dragX = p[0];
dragY = p[1];
levelModified();
};
};
});
addEventListener(MouseEvent.MOUSE_UP, function (e:MouseEvent):void{
var p:Array;
if (!lvlLocked){
p = lvl.pixelToTile(e.localX, e.localY);
if ((((p[0] == downX)) && ((p[1] == downY)))){
lvl.rotateBlock(p[0], p[1], true);
levelModified();
};
};
});
lvl = new Level(0);
redraw();
redrawText();
new LevelChangeMask(this, null, lvl, LEVEL_CHANGE_LENGTH);
addChild(new KongregateAPI());
}
private function redrawText():void{
text.htmlText = (((("<font face='tuffy' size='48' color='#AAAAAA'>Level " + (lvl.index + 1)) + "</font><br><font face='tuffy' size='24' color='#AAAAAA'>") + lvl.help()) + "</font>");
}
private function levelModified():void{
var kong:KongregateAPI;
var newLvl:Level;
redraw();
if (lvl.complete()){
lvlLocked = true;
kong = KongregateAPI.getInstance();
kong.stats.submit("HighestLevelCompleted", (lvl.index + 1));
if (!lvl.isLast()){
newLvl = new Level((lvl.index + 1));
new LevelChangeMask(this, lvl, newLvl, LEVEL_CHANGE_LENGTH);
setTimeout(function ():void{
lvl = newLvl;
redraw();
redrawText();
lvlLocked = false;
}, (LEVEL_CHANGE_LENGTH / 2));
} else {
kong.stats.submit("GameCompleted", 1);
new LevelChangeMask(this, lvl, null, LEVEL_CHANGE_LENGTH);
setTimeout(function ():void{
var n:int = (Level.TILES * Level.TILE_PIXELS);
var s:Shape = new Shape();
addChild(s);
s.graphics.beginFill(0);
s.graphics.drawRect(0, 0, n, n);
var t:TextField = new TextField();
addChild(t);
t.selectable = false;
t.embedFonts = true;
t.x = 0;
t.y = (0x0100 - 40);
t.width = n;
t.height = 40;
t.htmlText = "<p align='center'><font face='tuffy' size='40' color='#ffffff'><i>fin</i></font></p>";
}, (LEVEL_CHANGE_LENGTH / 2));
};
};
}
private function redraw():void{
floorSprite.graphics.clear();
objectsSprite.graphics.clear();
lvl.drawFloor(floorSprite.graphics);
lvl.drawObjects(objectsSprite.graphics);
}
}
}//package
Section 26
//faze_Tuffy (faze_Tuffy)
package {
import mx.core.*;
public class faze_Tuffy extends FontAsset {
}
}//package
Section 27
//faze_TuffyItalic (faze_TuffyItalic)
package {
import mx.core.*;
public class faze_TuffyItalic extends FontAsset {
}
}//package