Section 1
//TweenLite (gs.TweenLite)
package gs {
import flash.events.*;
import flash.media.*;
import flash.geom.*;
import flash.display.*;
import flash.utils.*;
public class TweenLite {
public var delay:Number;
protected var _endTarget:Object;
private var _sound:SoundTransform;
public var target:Object;
public var duration:Number;
public var startTime:uint;
public var extraTweens:Object;
protected var _color:ColorTransform;
protected var _active:Boolean;
protected var _endColor:ColorTransform;
public var vars:Object;
public var tweens:Object;
public var initTime:uint;
private static var _sprite:Sprite = new Sprite();
private static var _timer:Timer = new Timer(2000);
protected static var _all:Dictionary = new Dictionary();
public static var killDelayedCallsTo:Function = killTweensOf;
public static var version:Number = 5.85;
private static var _listening:Boolean;
public function TweenLite(_arg1:Object, _arg2:Number, _arg3:Object){
if (_arg1 == null){
return;
};
if (((((!((_arg3.overwrite == false))) && (!((_arg1 == null))))) || ((_all[_arg1] == undefined)))){
delete _all[_arg1];
_all[_arg1] = new Dictionary();
};
_all[_arg1][this] = this;
this.vars = _arg3;
this.duration = _arg2;
this.delay = ((_arg3.delay) || (0));
if (_arg2 == 0){
this.duration = 0.001;
if (this.delay == 0){
this.vars.runBackwards = true;
};
};
this.target = (_endTarget = _arg1);
if (!(this.vars.ease is Function)){
this.vars.ease = easeOut;
};
if (this.vars.easeParams != null){
this.vars.proxiedEase = this.vars.ease;
this.vars.ease = easeProxy;
};
if (this.vars.mcColor != null){
this.vars.tint = this.vars.mcColor;
};
if (!isNaN(Number(this.vars.autoAlpha))){
this.vars.alpha = Number(this.vars.autoAlpha);
};
this.tweens = {};
this.extraTweens = {};
this.initTime = getTimer();
if (this.vars.runBackwards == true){
initTweenVals();
};
_active = false;
if ((((_arg2 == 0)) && ((this.delay == 0)))){
complete(true);
} else {
if (!_listening){
_sprite.addEventListener(Event.ENTER_FRAME, executeAll);
_timer.addEventListener("timer", killGarbage);
_timer.start();
_listening = true;
};
};
}
public function set endTarget(_arg1:Object):void{
delete _all[_endTarget][this];
_endTarget = _arg1;
if (_all[_arg1] == undefined){
_all[_arg1] = new Dictionary();
};
_all[_arg1][this] = this;
}
public function get colorProxy():Number{
return (0);
}
public function get endTarget():Object{
return (_endTarget);
}
public function get active():Boolean{
if (_active){
return (true);
};
if (((getTimer() - this.initTime) / 1000) > this.delay){
_active = true;
this.startTime = (this.initTime + (this.delay * 1000));
if (this.vars.runBackwards != true){
initTweenVals();
} else {
if (typeof(this.vars.autoAlpha) == "number"){
this.target.visible = true;
};
};
if (this.vars.onStart != null){
this.vars.onStart.apply(null, this.vars.onStartParams);
};
if (this.duration == 0.001){
this.startTime = (this.startTime - 1);
};
return (true);
//unresolved jump
};
return (false);
}
public function initTweenVals():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Array;
var _local5:int;
var _local6:TweenLite;
var _local7:TweenLite;
var _local8:Object;
_local1 = (this.delay - ((getTimer() - this.initTime) / 1000));
if ((this.target is Array)){
_local4 = ((this.vars.endArray) || ([]));
_local5 = 0;
while (_local5 < _local4.length) {
if (((!((this.target[_local5] == _local4[_local5]))) && (!((this.target[_local5] == undefined))))){
this.tweens[_local5.toString()] = {o:this.target, s:this.target[_local5], c:(_local4[_local5] - this.target[_local5])};
};
_local5++;
};
} else {
for (_local2 in this.vars) {
if ((((((((((((((((((((((((((((_local2 == "delay")) || ((_local2 == "ease")))) || ((_local2 == "overwrite")))) || ((_local2 == "onComplete")))) || ((_local2 == "onCompleteParams")))) || ((_local2 == "runBackwards")))) || ((_local2 == "onUpdate")))) || ((_local2 == "onUpdateParams")))) || ((_local2 == "autoAlpha")))) || ((_local2 == "onStart")))) || ((_local2 == "onStartParams")))) || ((_local2 == "easeParams")))) || ((_local2 == "mcColor")))) || ((_local2 == "type")))){
} else {
if ((((_local2 == "tint")) && ((this.target is DisplayObject)))){
_color = this.target.transform.colorTransform;
_endColor = new ColorTransform();
if (this.vars.alpha != undefined){
_endColor.alphaMultiplier = this.vars.alpha;
delete this.vars.alpha;
delete this.tweens.alpha;
} else {
_endColor.alphaMultiplier = this.target.alpha;
};
if (((!((this.vars[_local2] == null))) && (!((this.vars[_local2] == ""))))){
_endColor.color = this.vars[_local2];
};
_local6 = new TweenLite(this, this.duration, {colorProxy:1, delay:_local1, overwrite:false, ease:this.vars.ease, runBackwards:this.vars.runBackwards});
_local6.endTarget = this.target;
} else {
if ((((_local2 == "volume")) && ((this.target is MovieClip)))){
_sound = this.target.soundTransform;
_local7 = new TweenLite(this, this.duration, {volumeProxy:this.vars[_local2], ease:easeOut, delay:_local1, overwrite:false, runBackwards:this.vars.runBackwards});
_local7.endTarget = this.target;
} else {
if (this.target.hasOwnProperty(_local2)){
if (typeof(this.vars[_local2]) == "number"){
_local3 = (this.vars[_local2] - this.target[_local2]);
} else {
_local3 = Number(this.vars[_local2]);
};
this.tweens[_local2] = {o:this.target, s:this.target[_local2], c:_local3};
} else {
this.extraTweens[_local2] = {o:this.target, s:0, c:0, v:this.vars[_local2]};
};
};
};
};
};
};
if (this.vars.runBackwards == true){
for (_local2 in this.tweens) {
_local8 = this.tweens[_local2];
this.tweens[_local2].s = (_local8.s + _local8.c);
_local8.c = (_local8.c * -1);
if (_local8.c != 0){
_local8.o[_local2] = _local8.s;
};
};
if (this.vars.onUpdate != null){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
};
if (typeof(this.vars.autoAlpha) == "number"){
this.target.visible = !((((this.vars.runBackwards == true)) && ((this.target.alpha == 0))));
};
}
public function render(_arg1:int):void{
var _local2:Number;
var _local3:Number;
var _local4:Object;
var _local5:String;
_local2 = ((_arg1 - this.startTime) / 1000);
if (_local2 > this.duration){
_local2 = this.duration;
};
_local3 = this.vars.ease(_local2, 0, 1, this.duration);
for (_local5 in this.tweens) {
_local4 = this.tweens[_local5];
_local4.o[_local5] = (_local4.s + (_local3 * _local4.c));
};
if (this.vars.onUpdate != null){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
if (_local2 == this.duration){
complete(true);
};
}
public function set colorProxy(_arg1:Number):void{
var _local2:Number;
_local2 = (1 - _arg1);
this.target.transform.colorTransform = new ColorTransform(((_color.redMultiplier * _local2) + (_endColor.redMultiplier * _arg1)), ((_color.greenMultiplier * _local2) + (_endColor.greenMultiplier * _arg1)), ((_color.blueMultiplier * _local2) + (_endColor.blueMultiplier * _arg1)), ((_color.alphaMultiplier * _local2) + (_endColor.alphaMultiplier * _arg1)), ((_color.redOffset * _local2) + (_endColor.redOffset * _arg1)), ((_color.greenOffset * _local2) + (_endColor.greenOffset * _arg1)), ((_color.blueOffset * _local2) + (_endColor.blueOffset * _arg1)), ((_color.alphaOffset * _local2) + (_endColor.alphaOffset * _arg1)));
}
public function get volumeProxy():Number{
return (_sound.volume);
}
public function set volumeProxy(_arg1:Number):void{
_sound.volume = _arg1;
this.target.soundTransform = _sound;
}
protected function easeProxy(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams)));
}
public function complete(_arg1:Boolean=false):void{
if (!_arg1){
this.startTime = 0;
render((this.duration * 1000));
return;
};
if ((((typeof(this.vars.autoAlpha) == "number")) && ((this.target.alpha == 0)))){
this.target.visible = false;
};
if (this.vars.onComplete != null){
this.vars.onComplete.apply(null, this.vars.onCompleteParams);
};
removeTween(this);
}
public static function delayedCall(_arg1:Number, _arg2:Function, _arg3:Array=null):TweenLite{
return (new TweenLite(_arg2, 0, {delay:_arg1, onComplete:_arg2, onCompleteParams:_arg3, overwrite:false}));
}
public static function from(_arg1:Object, _arg2:Number, _arg3:Object):TweenLite{
_arg3.runBackwards = true;
return (new TweenLite(_arg1, _arg2, _arg3));
}
public static function removeTween(_arg1:TweenLite=null):void{
if (((!((_arg1 == null))) && (!((_all[_arg1.endTarget] == undefined))))){
delete _all[_arg1.endTarget][_arg1];
};
}
protected static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function killGarbage(_arg1:TimerEvent):void{
var _local2:Object;
var _local3:int;
var _local4:Boolean;
var _local5:Object;
var _local6:Object;
var _local7:Object;
_local2 = _all;
_local3 = 0;
for (_local5 in _local2) {
_local4 = false;
for (_local6 in _local2[_local5]) {
_local4 = true;
break;
};
if (!_local4){
delete _local2[_local5];
} else {
_local3++;
};
};
if (_local3 == 0){
_sprite.removeEventListener(Event.ENTER_FRAME, executeAll);
_timer.removeEventListener("timer", killGarbage);
_timer.stop();
_listening = false;
};
}
public static function executeAll(_arg1:Event):void{
var _local2:Object;
var _local3:int;
var _local4:Object;
var _local5:Object;
var _local6:Object;
_local2 = _all;
_local3 = getTimer();
for (_local4 in _local2) {
for (_local5 in _local2[_local4]) {
_local6 = _local2[_local4][_local5];
if (((!((_local6 == null))) && (_local6.active))){
_local6.render(_local3);
};
};
};
}
public static function to(_arg1:Object, _arg2:Number, _arg3:Object):TweenLite{
return (new TweenLite(_arg1, _arg2, _arg3));
}
public static function killTweensOf(_arg1:Object=null, _arg2:Boolean=false):void{
var _local3:Object;
var _local4:*;
if (((!((_arg1 == null))) && (!((_all[_arg1] == undefined))))){
if (_arg2){
_local3 = _all[_arg1];
for (_local4 in _local3) {
_local3[_local4].complete(false);
};
};
delete _all[_arg1];
};
}
}
}//package gs
Section 2
//GameBoard (GameBoard)
package {
import gs.*;
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class GameBoard extends Sprite {
private var gameBoard:Array;
private var selectedToken:SelectedToken;
private var boardHolder:Sprite;
private var curToken:int;// = -1
private var tokenSize:int;
public var totalTxt:TextField;
private var isSelected:Boolean;// = false
private var boardRows:int;
private var removeQueue:Array;
private var boardCols:int;
public function GameBoard(){
boardRows = ((root.loaderInfo.parameters.boardRows) || (8));
boardCols = ((root.loaderInfo.parameters.boardCols) || (8));
tokenSize = ((root.loaderInfo.parameters.tokenSize) || (40));
boardHolder = new Sprite();
selectedToken = new SelectedToken();
isSelected = false;
curToken = -1;
super();
buildBoard();
checkBoard();
selectedToken.scaleX = (selectedToken.scaleY = (tokenSize / selectedToken.width));
selectedToken.x = (selectedToken.y = (tokenSize / 2));
boardHolder.addChild(selectedToken);
}
private function sweep(_arg1:Boolean):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:int;
_local2 = 0;
_local3 = 0;
if (_arg1){
_local5 = 0;
while (_local5 < removeQueue.length) {
if (removeQueue[_local5] == true){
removeSpot(_local5);
removeQueue[_local5] = false;
_local3++;
};
_local5++;
};
shiftDown();
repopulate();
};
_local2 = (_local2 + Math.floor((Math.pow(Number(_local3), 1.1) * 100)));
_local4 = Number(totalTxt.text.valueOf());
trace(("Sweep Points:" + _local2));
_local4 = (_local4 + _local2);
totalTxt.text = String(_local4);
}
private function checkUpFrom(_arg1:int):int{
var _local2:int;
if ((_arg1 - boardRows) <= 0){
return (0);
};
_local2 = 0;
if (gameBoard[_arg1].currentFrame == gameBoard[(_arg1 - boardRows)].currentFrame){
_local2++;
_local2 = (_local2 + checkUpFrom((_arg1 - boardRows)));
return (_local2);
};
return (0);
}
private function swapBack(_arg1:int, _arg2:int):void{
var _local3:MovieClip;
TweenLite.to(gameBoard[_arg1], 0.5, {x:gameBoard[_arg2].x, y:gameBoard[_arg2].y});
TweenLite.to(gameBoard[_arg2], 0.5, {x:gameBoard[_arg1].x, y:gameBoard[_arg1].y});
boardHolder.swapChildren(gameBoard[_arg1], gameBoard[_arg2]);
_local3 = gameBoard[_arg1];
gameBoard[_arg1] = gameBoard[_arg2];
gameBoard[_arg2] = _local3;
}
private function repopulate():void{
var _local1:Array;
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
_local1 = new Array(boardCols);
_local2 = 0;
while (_local2 < _local1.length) {
_local1[_local2] = 0;
_local2++;
};
_local3 = 0;
while (_local3 < gameBoard.length) {
if (gameBoard[_local3] == null){
var _local6 = _local1;
var _local7 = Math.floor((_local3 % boardCols));
var _local8 = (_local6[_local7] + 1);
_local6[_local7] = _local8;
};
_local3++;
};
_local4 = 0;
while (_local4 < _local1.length) {
_local2 = 0;
while (_local2 < _local1[_local4]) {
_local5 = (_local4 + (_local2 * boardRows));
gameBoard[_local5] = new tokenIcon();
gameBoard[_local5].mouseChildren = false;
gameBoard[_local5].gotoAndStop(Math.floor((Math.random() * 8)));
gameBoard[_local5].scaleX = (gameBoard[_local5].scaleY = (tokenSize / gameBoard[_local5].width));
gameBoard[_local5].x = (_local4 * tokenSize);
gameBoard[_local5].y = (_local2 * tokenSize);
addTokenListeners(_local5);
TweenLite.from(gameBoard[_local5], 0.7, {y:(gameBoard[_local5].y - (boardRows * tokenSize)), onComplete:checkBoard});
boardHolder.addChild(gameBoard[_local5]);
_local2++;
};
_local4++;
};
}
private function tokenClick(_arg1:MouseEvent):void{
if (isSelected){
trySwap(_arg1);
isSelected = false;
} else {
curToken = gameBoard.indexOf(_arg1.currentTarget);
isSelected = true;
};
}
private function shiftDown():void{
var _local1:int;
var _local2:int;
var _local3:int;
_local1 = 63;
while (_local1 > -1) {
if (gameBoard[_local1] == null){
_local2 = findNextHighest(_local1);
if (_local2 != -1){
_local3 = Math.floor((_local1 / boardRows));
TweenLite.to(gameBoard[_local2], 0.5, {y:(_local3 * tokenSize)});
gameBoard[_local1] = gameBoard[_local2];
gameBoard[_local2] = null;
};
};
_local1--;
};
}
function addTokenListeners(_arg1:int):void{
gameBoard[_arg1].addEventListener(MouseEvent.ROLL_OVER, tokenOver);
gameBoard[_arg1].addEventListener(MouseEvent.CLICK, tokenClick);
}
private function checkLeftOf(_arg1:int):int{
var _local2:int;
if ((_arg1 % boardCols) == 0){
return (0);
};
_local2 = 0;
if (gameBoard[_arg1].currentFrame == gameBoard[(_arg1 - 1)].currentFrame){
_local2++;
_local2 = (_local2 + checkLeftOf((_arg1 - 1)));
return (_local2);
};
return (0);
}
private function checkBlock(_arg1:int):Boolean{
var _local2:int;
var _local3:int;
var _local4:Boolean;
_local2 = 0;
_local3 = 0;
_local4 = false;
_local2 = (_local2 + checkLeftOf(_arg1));
_local2 = (_local2 + checkRightOf(_arg1));
_local3 = (_local3 + checkUpFrom(_arg1));
_local3 = (_local3 + checkDownFrom(_arg1));
if ((((_local2 >= 2)) || ((_local3 >= 2)))){
removeQueue[_arg1] = true;
_local4 = true;
};
return (_local4);
}
private function buildBoard():void{
var _local1:int;
var _local2:int;
var _local3:int;
gameBoard = new Array((boardRows * boardCols));
removeQueue = new Array((boardRows * boardCols));
_local1 = 0;
while (_local1 < boardRows) {
_local2 = 0;
while (_local2 < boardCols) {
_local3 = ((_local1 * boardCols) + _local2);
gameBoard[_local3] = new tokenIcon();
gameBoard[_local3].mouseChildren = false;
gameBoard[_local3].gotoAndStop(Math.floor((Math.random() * 8)));
gameBoard[_local3].scaleX = (gameBoard[((_local1 * boardCols) + _local2)].scaleY = (tokenSize / gameBoard[_local3].width));
gameBoard[_local3].x = (_local2 * tokenSize);
gameBoard[_local3].y = (_local1 * tokenSize);
addTokenListeners(_local3);
boardHolder.addChild(gameBoard[((_local1 * boardCols) + _local2)]);
boardHolder.addEventListener(MouseEvent.ROLL_OUT, tokenOut);
_local2++;
};
_local1++;
};
boardHolder.x = (boardHolder.x + ((tokenSize / 2) + 40));
boardHolder.y = (boardHolder.y + ((tokenSize / 2) + 40));
addChild(boardHolder);
}
private function tokenOver(_arg1:MouseEvent):void{
var _local2:int;
if (!isSelected){
_local2 = gameBoard.indexOf(_arg1.target);
selectedToken.visible = true;
selectedToken.x = (gameBoard[_local2].x - (tokenSize / 2));
selectedToken.y = (gameBoard[_local2].y - (tokenSize / 2));
};
}
private function tokenOut(_arg1:MouseEvent):void{
if (!isSelected){
selectedToken.visible = false;
};
}
private function removeSpot(_arg1:int):void{
gameBoard[_arg1].removeEventListener(MouseEvent.ROLL_OVER, tokenOver);
gameBoard[_arg1].removeEventListener(MouseEvent.CLICK, tokenClick);
TweenLite.to(gameBoard[_arg1], 1, {scaleX:0, scaleY:0});
gameBoard[_arg1] = null;
}
private function checkDownFrom(_arg1:int):int{
var _local2:int;
if ((_arg1 + boardRows) >= gameBoard.length){
return (0);
};
_local2 = 0;
if (gameBoard[_arg1].currentFrame == gameBoard[(_arg1 + boardRows)].currentFrame){
_local2++;
_local2 = (_local2 + checkDownFrom((_arg1 + boardRows)));
return (_local2);
};
return (0);
}
private function swapCheckBoard(_arg1:int, _arg2:int):void{
var _local3:Boolean;
var _local4:int;
_local3 = false;
_local4 = 0;
while (_local4 < gameBoard.length) {
if (checkBlock(_local4)){
_local3 = true;
};
_local4++;
};
if (_local3){
sweep(true);
return;
};
swapBack(_arg1, _arg2);
}
private function checkBoard():void{
var _local1:Boolean;
var _local2:int;
_local1 = false;
_local2 = 0;
while (_local2 < gameBoard.length) {
if (checkBlock(_local2)){
_local1 = true;
};
_local2++;
};
if (_local1){
sweep(true);
};
}
private function findNextHighest(_arg1:int):int{
var _local2:int;
var _local3:int;
_local2 = -1;
_local3 = 1;
while (_local2 == -1) {
if ((_arg1 - (boardRows * _local3)) < 0){
break;
};
if (gameBoard[(_arg1 - (boardRows * _local3))] != null){
_local2 = (_arg1 - (boardRows * _local3));
};
_local3++;
};
return (_local2);
}
private function checkRightOf(_arg1:int):int{
var _local2:int;
if ((_arg1 % boardCols) == 7){
return (0);
};
_local2 = 0;
if (gameBoard[_arg1].currentFrame == gameBoard[(_arg1 + 1)].currentFrame){
_local2++;
_local2 = (_local2 + checkRightOf((_arg1 + 1)));
return (_local2);
};
return (0);
}
private function trySwap(_arg1:MouseEvent):Boolean{
var _local2:int;
var _local3:Boolean;
var _local4:Boolean;
var _local5:Boolean;
var _local6:Boolean;
var _local7:MovieClip;
_local2 = gameBoard.indexOf(_arg1.currentTarget);
trace(((("index: " + _local2) + ", curToken: ") + curToken));
_local3 = ((((curToken - 1) == _local2)) && (!(((curToken % boardCols) == 0))));
_local4 = ((((curToken + 1) == _local2)) && (!(((curToken % boardCols) == 7))));
_local5 = ((curToken - boardCols) == _local2);
_local6 = ((curToken + boardCols) == _local2);
if (((((((_local3) || (_local4))) || (_local5))) || (_local6))){
_local7 = gameBoard[_local2];
gameBoard[_local2] = gameBoard[curToken];
gameBoard[curToken] = _local7;
TweenLite.to(gameBoard[curToken], 0.5, {x:gameBoard[_local2].x, y:gameBoard[_local2].y});
TweenLite.to(gameBoard[_local2], 0.5, {x:gameBoard[curToken].x, y:gameBoard[curToken].y, onComplete:swapCheckBoard, onCompleteParams:[curToken, _local2]});
return (true);
};
return (false);
}
}
}//package
Section 3
//icon1 (icon1)
package {
import flash.display.*;
public dynamic class icon1 extends MovieClip {
}
}//package
Section 4
//icon2 (icon2)
package {
import flash.display.*;
public dynamic class icon2 extends MovieClip {
}
}//package
Section 5
//icon3 (icon3)
package {
import flash.display.*;
public dynamic class icon3 extends MovieClip {
}
}//package
Section 6
//icon4 (icon4)
package {
import flash.display.*;
public dynamic class icon4 extends MovieClip {
}
}//package
Section 7
//icon5 (icon5)
package {
import flash.display.*;
public dynamic class icon5 extends MovieClip {
}
}//package
Section 8
//icon6 (icon6)
package {
import flash.display.*;
public dynamic class icon6 extends MovieClip {
}
}//package
Section 9
//icon7 (icon7)
package {
import flash.display.*;
public dynamic class icon7 extends MovieClip {
}
}//package
Section 10
//SelectedToken (SelectedToken)
package {
import flash.display.*;
public dynamic class SelectedToken extends MovieClip {
}
}//package
Section 11
//tokenIcon (tokenIcon)
package {
import flash.display.*;
public dynamic class tokenIcon extends MovieClip {
public function tokenIcon(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7);
}
function frame3(){
stop();
}
function frame6(){
stop();
}
function frame7(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame5(){
stop();
}
function frame2(){
stop();
}
}
}//package