Section 1
//bonus (classes.bonus)
package classes {
import flash.events.*;
public class bonus extends bonusMC {
public function bonus(_arg1, _arg2, _arg3, _arg4):void{
x = _arg1;
y = _arg2;
txt.text = _arg3;
txt2.text = String(_arg4);
addEventListener(Event.ENTER_FRAME, enter_frame);
}
private function enter_frame(_arg1:Event):void{
y--;
alpha = (alpha - 0.05);
if (alpha <= 0){
removeEventListener(Event.ENTER_FRAME, enter_frame);
parent.removeChild(this);
};
}
}
}//package classes
Section 2
//game (classes.game)
package classes {
import flash.events.*;
import flash.media.*;
import flash.display.*;
import flash.utils.*;
public class game extends MovieClip {
const START_DELAY:Number = 500;
var delayTick:Number;// = 500
var level:Number;// = 1
var timer:Timer;
var Menu:menu;
var count:Number;// = 0
var multiplyer:Number;// = 9
var gameBoard:Array;
var Hud;
var Parent;
var soundFX:Sound;
var perfectStreak:Number;// = -1
var rowAt:Number;// = 14
var gameEnabled:Boolean;// = true
var nbLights:Number;// = 3
var startWithOnes:Boolean;// = false
var Arrows:MovieClip;
var lastLeft:Boolean;// = true
var direction:Number;// = 1
public function game(_arg1, _arg2, _arg3):void{
gameBoard = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]];
timer = new Timer(0);
soundFX = new buzz();
Menu = new menu(this);
super();
Parent = _arg1;
Hud = _arg2;
Arrows = _arg3;
Menu.x = 30;
Menu.y = 200;
Parent.addChild(Menu);
Arrows.x = 30;
Parent.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
Parent.addEventListener(KeyboardEvent.KEY_UP, key_up);
gameOver();
}
private function key_down(_arg1:KeyboardEvent):void{
var _local2:int;
if ((((_arg1.keyCode == 32)) && (gameEnabled))){
gameEnabled = false;
if (rowAt < 13){
_local2 = 0;
while (_local2 < 7) {
if (gameBoard[rowAt][_local2] == 1){
if (gameBoard[(rowAt + 1)][_local2] != 1){
nbLights--;
gameBoard[rowAt][_local2] = 0;
animationLoseLight(rowAt, _local2);
};
};
_local2++;
};
Hud.edit("score", (nbLights * 100), 50, (rowAt * 32), " ");
Hud.edit("score", (multiplyer * 100), 150, ((rowAt * 32) - 32), "Speed bonus!");
};
render();
if (rowAt > 0){
addRow();
render();
} else {
if (nbLights >= 1){
if (nbLights == 3){
Hud.edit("score", 15000, 200, 100, "Perfect tower!");
perfectStreak++;
Hud.edit("score", (perfectStreak * 10000), 200, 200, ("Perfect streak x" + String(perfectStreak)));
} else {
perfectStreak = -1;
if (nbLights == 1){
if (startWithOnes){
Hud.edit("score", 15000, 200, 100, "Slim tower");
};
};
};
levelUp();
} else {
gameOver();
};
};
if (nbLights <= 0){
gameOver();
};
};
}
private function levelUp():void{
Hud.edit("level", 1);
Hud.edit("score", 10000, 75, 100, "Level up!");
rowAt = 14;
level++;
direction = 1;
nbLights = 3;
lastLeft = true;
delayTick = (START_DELAY - (level * 15));
startWithOnes = false;
reset(gameBoard);
addRow();
render();
}
private function gameOver():void{
timer.removeEventListener(TimerEvent.TIMER, gameTick);
Parent.removeEventListener(KeyboardEvent.KEY_DOWN, key_down);
Menu.addEvent();
Hud.save();
Menu.visible = true;
rowAt = 14;
placeArrows();
render();
}
private function addRow():void{
var _local1:Number = 0;
if ((((rowAt == 12)) && ((nbLights == 1)))){
startWithOnes = true;
};
soundFX.play();
multiplyer = 6;
placeArrows();
rowAt--;
delayTick = (delayTick - (delayTick / 10));
trace(("Tick delay : " + Math.round(delayTick)));
timer.removeEventListener(TimerEvent.TIMER, gameTick);
timer = new Timer(delayTick);
timer.addEventListener(TimerEvent.TIMER, gameTick);
timer.start();
lastLeft = !(lastLeft);
if (lastLeft){
_local1 = (7 - nbLights);
};
var _local2:int;
while (_local2 < nbLights) {
gameBoard[rowAt][(_local2 + _local1)] = 1;
_local2++;
};
}
private function animationLoseLight(_arg1, _arg2):void{
var enter_frame:Function;
var i = _arg1;
var j = _arg2;
enter_frame = function ():void{
count++;
if (gameBoard[i][j] == 0){
gameBoard[i][j] = 2;
} else {
if (gameBoard[i][j] == 2){
gameBoard[i][j] = 0;
};
};
if (count > 20){
removeEventListener(Event.ENTER_FRAME, enter_frame);
gameBoard[i][j] = 0;
if (gameBoard[i][(j + 1)] == 2){
gameBoard[i][(j + 1)] = 0;
} else {
if (gameBoard[i][(j - 1)] == 2){
gameBoard[i][(j + 1)] = 0;
};
};
};
render();
};
count = 0;
addEventListener(Event.ENTER_FRAME, enter_frame);
}
private function reset(_arg1):void{
var _local3:int;
var _local2:int;
while (_local2 < _arg1.length) {
_local3 = 0;
while (_local3 < _arg1[0].length) {
_arg1[_local2][_local3] = 0;
_local3++;
};
_local2++;
};
}
public function newGame():void{
Hud.reset("level", 1);
Hud.reset("score", 0);
rowAt = 14;
level = 1;
direction = 1;
nbLights = 3;
lastLeft = true;
delayTick = START_DELAY;
Menu.visible = false;
startWithOnes = false;
Parent.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
reset(gameBoard);
addRow();
render();
}
private function gameTick(_arg1:TimerEvent):void{
var _local2:Array = new Array();
if (multiplyer > 0){
multiplyer--;
};
if ((((((gameBoard[rowAt][6] == 1)) && ((direction == 1)))) || ((((gameBoard[rowAt][0] == 1)) && ((direction == -1)))))){
direction = -(direction);
};
var _local3:int;
while (_local3 < 7) {
if (gameBoard[rowAt][_local3] == 1){
_local2.push((_local3 + direction));
gameBoard[rowAt][_local3] = 0;
};
_local3++;
};
_local3 = 0;
while (_local3 < _local2.length) {
gameBoard[rowAt][_local2[_local3]] = 1;
_local3++;
};
render();
}
private function placeArrows():void{
Arrows.y = ((rowAt * 32) + 16);
}
private function render():void{
var _local6:int;
var _local7:tileMC;
var _local8:Object;
var _local1:Array = new Array();
var _local2:MovieClip = new MovieClip();
while (numChildren) {
removeChildAt(0);
};
var _local3:backgroundMC = new backgroundMC();
_local2.addChild(_local3);
var _local4:int;
while (_local4 < 14) {
_local6 = 0;
while (_local6 < 7) {
_local7 = new tileMC();
_local7.x = (2 + (_local6 * 32));
_local7.y = (2 + (_local4 * 32));
_local7.stop();
if (gameBoard[_local4][_local6] != 0){
_local1.push(_local7);
};
_local2.addChild(_local7);
_local6++;
};
_local4++;
};
var _local5:int;
while (_local5 < _local1.length) {
_local8 = _local1[_local5];
_local8.nextFrame();
_local8.parent.setChildIndex(_local8, (_local8.parent.numChildren - 1));
_local5++;
};
addChild(_local2);
}
private function key_up(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == 32){
gameEnabled = true;
};
}
}
}//package classes
Section 3
//hud (classes.hud)
package classes {
import flash.events.*;
import flash.media.*;
public class hud extends hudMC {
const ADDER:Number = 591;
var level:Number;// = 1
var music:Sound;
var sndTransform:SoundTransform;
var highscore:Number;// = 0
var Parent;
var score:Number;// = 0
var channel:SoundChannel;
var musicEnabled:Boolean;// = true
public function hud(_arg1, _arg2):void{
music = new song();
sndTransform = new SoundTransform(0.5);
super();
Parent = _arg1;
highscore = _arg2;
txt_highscore.text = String(highscore);
channel = music.play(0, 99);
channel.soundTransform = sndTransform;
update();
btn_music.addEventListener(MouseEvent.MOUSE_DOWN, music_click);
addEventListener(Event.ENTER_FRAME, enter_frame);
}
private function update():void{
txt_level.text = String(level);
}
public function reset(_arg1, _arg2):void{
switch (_arg1){
case "level":
level = 1;
break;
case "score":
score = 0;
break;
};
update();
}
private function music_click(_arg1:MouseEvent):void{
if (musicEnabled){
SoundMixer.stopAll();
} else {
channel = music.play(0, 99);
channel.soundTransform = sndTransform;
};
musicEnabled = !(musicEnabled);
}
public function edit(_arg1, _arg2, _arg3:Number=0, _arg4:Number=0, _arg5:String=""):void{
if (((!((_arg5 == ""))) && ((_arg2 > 0)))){
addChild(new bonus(_arg3, _arg4, _arg5, _arg2));
};
switch (_arg1){
case "level":
level = (level + _arg2);
break;
case "score":
score = (score + _arg2);
break;
};
save();
update();
}
public function save():void{
Parent.AutoSave(Number(txt_highscore.text));
}
private function enter_frame(_arg1:Event):void{
if (Number(txt_score.text) < (score - ADDER)){
txt_score.text = String((Number(txt_score.text) + ADDER));
} else {
txt_score.text = String(score);
};
if (Number(txt_highscore.text) < (highscore - ADDER)){
txt_highscore.text = String((Number(txt_highscore.text) + ADDER));
} else {
txt_highscore.text = String(highscore);
};
if (score > highscore){
highscore = score;
};
}
}
}//package classes
Section 4
//menu (classes.menu)
package classes {
import flash.events.*;
import flash.net.*;
public class menu extends menuMC {
var Parent;
public function menu(_arg1):void{
Parent = _arg1;
addFrameScript(0, frame1);
addFrameScript(1, frame2);
addFrameScript(2, frame3);
}
private function key_down(_arg1:KeyboardEvent):void{
play_click();
}
private function credits_click(_arg1:MouseEvent):void{
gotoAndStop("credits");
}
private function frame1():void{
stop();
addEvent();
btn_play.addEventListener(MouseEvent.MOUSE_DOWN, play_click);
btn_help.addEventListener(MouseEvent.MOUSE_DOWN, help_click);
btn_moregames.addEventListener(MouseEvent.MOUSE_DOWN, moregames_click);
btn_credits.addEventListener(MouseEvent.MOUSE_DOWN, credits_click);
}
private function frame2():void{
btn_back.addEventListener(MouseEvent.MOUSE_DOWN, back_click);
}
private function frame3():void{
btn_back.addEventListener(MouseEvent.MOUSE_DOWN, back_click);
}
private function help_click(_arg1:MouseEvent):void{
gotoAndStop("help");
}
private function back_click(_arg1:MouseEvent):void{
gotoAndStop("main");
}
private function moregames_click(_arg1:MouseEvent):void{
var _local2:URLRequest = new URLRequest("http://www.minijuegos.com/");
navigateToURL(_local2);
}
public function addEvent():void{
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
}
private function play_click(_arg1:MouseEvent=null):void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, key_down);
Parent.newGame();
}
}
}//package classes
Section 5
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var cpmstarLoader:Loader;
private var contentspotid:String;
public function AdLoader(_arg1:String){
this.contentspotid = _arg1;
addEventListener(Event.ADDED, addedHandler);
}
private function dispatchHandler(_arg1:Event):void{
dispatchEvent(_arg1);
}
private function addedHandler(_arg1:Event):void{
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
var _local2 = "http://server.cpmstar.com/adviewas3.swf";
var _local3:DisplayObjectContainer = parent;
cpmstarLoader = new Loader();
cpmstarLoader.contentLoaderInfo.addEventListener(Event.INIT, dispatchHandler);
cpmstarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
cpmstarLoader.load(new URLRequest(((_local2 + "?contentspotid=") + contentspotid)));
addChild(cpmstarLoader);
}
}
}//package CPMStar
Section 6
//loader_3 (stackem_fla.loader_3)
package stackem_fla {
import flash.display.*;
public dynamic class loader_3 extends MovieClip {
public function loader_3(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package stackem_fla
Section 7
//MainTimeline (stackem_fla.MainTimeline)
package stackem_fla {
import flash.events.*;
import flash.media.*;
import CPMStar.*;
import flash.display.*;
import flash.text.*;
import classes.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public var Game:game;
public var Hud:hud;
public var ad:DisplayObject;
public var CPMStarContentSpotID:String;
public var saved_info:SharedObject;
public var adBox:MovieClip;
public var btn_continue:SimpleButton;
public var minijuegos:MovieClip;
public var Arrows:arrowsMC;
public var txt_percent:TextField;
public var highscore:Number;
public function MainTimeline(){
addFrameScript(0, frame1, 2, frame3, 3, frame4);
}
public function preload(_arg1:Event):void{
var _local2:Number = Math.round(((this.loaderInfo.bytesLoaded / this.loaderInfo.bytesTotal) * 100));
txt_percent.text = (String(_local2) + "%");
if (_local2 == 100){
removeEventListener(Event.ENTER_FRAME, preload);
btn_continue.visible = true;
txt_percent.visible = false;
btn_continue.addEventListener(MouseEvent.MOUSE_DOWN, continue_click);
};
}
public function AutoLoad():void{
highscore = saved_info.data.Highscore;
if (!highscore){
trace("No highscore found. Reset at 7300");
highscore = 7300;
} else {
trace(("Loaded highscore : " + highscore));
};
}
function frame4(){
stop();
Arrows = new arrowsMC();
Hud = new hud(this, highscore);
Game = new game(stage, Hud, Arrows);
Game.x = 30;
Game.y = 30;
addChild(Game);
addChild(Hud);
addChild(Arrows);
}
function frame3(){
stop();
}
public function continue_click(_arg1:MouseEvent):void{
gotoAndStop("intro");
}
public function AutoSave(_arg1):void{
if (saved_info.data.Highscore < _arg1){
saved_info.data.Highscore = new Number(_arg1);
trace(("Saved highscore : " + saved_info.data.Highscore));
};
}
function frame1(){
stop();
highscore = 7300;
saved_info = SharedObject.getLocal("user_data2");
btn_continue.visible = false;
CPMStarContentSpotID = "443QC19CC609";
ad = new AdLoader(CPMStarContentSpotID);
adBox.addChild(ad);
addEventListener(Event.ENTER_FRAME, preload);
AutoLoad();
}
}
}//package stackem_fla
Section 8
//MINIJUEGOS_4 (stackem_fla.MINIJUEGOS_4)
package stackem_fla {
import flash.display.*;
public dynamic class MINIJUEGOS_4 extends MovieClip {
public function MINIJUEGOS_4(){
addFrameScript(99, frame100);
}
function frame100(){
MovieClip(parent).play();
}
}
}//package stackem_fla
Section 9
//arrowsMC (arrowsMC)
package {
import flash.display.*;
public dynamic class arrowsMC extends MovieClip {
}
}//package
Section 10
//backgroundMC (backgroundMC)
package {
import flash.display.*;
public dynamic class backgroundMC extends MovieClip {
}
}//package
Section 11
//bonusMC (bonusMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class bonusMC extends MovieClip {
public var txt:TextField;
public var txt2:TextField;
}
}//package
Section 12
//buzz (buzz)
package {
import flash.media.*;
public dynamic class buzz extends Sound {
}
}//package
Section 13
//hudMC (hudMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class hudMC extends MovieClip {
public var txt_highscore:TextField;
public var txt_score:TextField;
public var txt_level:TextField;
public var btn_music:SimpleButton;
}
}//package
Section 14
//menuMC (menuMC)
package {
import flash.display.*;
public dynamic class menuMC extends MovieClip {
public var btn_play:SimpleButton;
public var btn_credits:SimpleButton;
public var btn_moregames:SimpleButton;
public var btn_back:SimpleButton;
public var btn_help:SimpleButton;
}
}//package
Section 15
//song (song)
package {
import flash.media.*;
public dynamic class song extends Sound {
}
}//package
Section 16
//tileMC (tileMC)
package {
import flash.display.*;
public dynamic class tileMC extends MovieClip {
}
}//package