Section 1
//Game (com.novelgames.flashgames.common.Game)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
public class Game extends MovieClip {
public static var gameStage:Stage;
private function getMouseTarget():DisplayObject{
var _local3:int;
var _local1:Point = this.localToGlobal(new Point(mouseX, mouseY));
var _local2:Array = this.getObjectsUnderPoint(_local1);
_local3 = (_local2.length - 1);
while (_local3 >= 0) {
if (!_local2[_local3].parent.mouseEnabled){
} else {
if (((_local2[_local3].parent.parent) && (!(_local2[_local3].parent.parent.mouseChildren)))){
} else {
return (_local2[_local3]);
};
};
_local3--;
};
return (null);
}
public function onRightMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseRightUp"));
}
public function onMiddleMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseMiddleDown"));
}
public function pause():void{
NewTimer.pause();
}
public function onRightMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseRightDown"));
}
public function onMiddleMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseMiddleUp"));
}
public function unpause():void{
NewTimer.unpause();
}
}
}//package com.novelgames.flashgames.common
Section 2
//Instructions (com.novelgames.flashgames.common.Instructions)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.display.*;
public class Instructions extends MovieClip {
public var startButton:SimpleButton;
private var shownFromGame:Boolean;
public function Instructions(_arg1:Boolean=false){
this.shownFromGame = _arg1;
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
}
private function startButtonClicked(_arg1:MouseEvent):void{
if (!shownFromGame){
Object(parent).gotoGamePage();
} else {
Object(parent).hideInstructionsFromGame();
};
}
}
}//package com.novelgames.flashgames.common
Section 3
//InstructionsButton (com.novelgames.flashgames.common.InstructionsButton)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.display.*;
public class InstructionsButton extends MovieClip {
public function InstructionsButton(){
super();
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, function ():void{
Object(parent.parent).showInstructionsFromGame();
});
}
}
}//package com.novelgames.flashgames.common
Section 4
//MainDevelopment (com.novelgames.flashgames.common.MainDevelopment)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.display.*;
import flash.media.*;
import flash.external.*;
import flash.net.*;
public class MainDevelopment extends MovieClip {
private var titleY:Number;
private var titleX:Number;
private var musicGameSoundChannel:SoundChannel;
private var title:Title;
private var titleIndex:int;
private var instructions:Instructions;
private var game:Game;
private var musicGame:Sound;
public function MainDevelopment(){
super();
try {
ExternalInterface.addCallback("onRightMouseDown", onRightMouseDown);
ExternalInterface.addCallback("onRightMouseUp", onRightMouseUp);
ExternalInterface.addCallback("onMiddleMouseDown", onMiddleMouseDown);
ExternalInterface.addCallback("onMiddleMouseUp", onMiddleMouseUp);
} catch(e) {
};
this.addEventListener(Event.ENTER_FRAME, checkTitle);
}
protected function getMusicGame():Sound{
return (null);
}
public function showHighScores():void{
trace("showHighScores()");
}
public function onMiddleMouseDown():void{
if (game){
game.onMiddleMouseDown();
};
}
public function gotoInstructionsPage():void{
removePage();
instructions = new Instructions();
instructions.x = titleX;
instructions.y = titleY;
this.addChildAt(instructions, titleIndex);
}
public function showInstructionsFromGame():void{
game.pause();
game.visible = false;
instructions = new Instructions(true);
instructions.x = titleX;
instructions.y = titleY;
this.addChildAt(instructions, (titleIndex + 1));
}
private function removePage():void{
if (title){
removeChild(title);
title = null;
};
if (instructions){
removeChild(instructions);
instructions = null;
};
if (game){
removeChild(game);
game = null;
};
if (musicGame){
musicGameSoundChannel.stop();
musicGame = null;
musicGameSoundChannel = null;
};
}
protected function getTitle():Title{
return (null);
}
public function hideInstructionsFromGame():void{
this.removeChild(instructions);
instructions = null;
game.visible = true;
game.unpause();
}
public function gotoMoreGamesURL():void{
navigateToURL(new URLRequest("http://www.novelgames.com"), "_blank");
}
protected function getGame():Game{
return (null);
}
public function onRightMouseDown():void{
if (game){
game.onRightMouseDown();
};
}
public function gotoGamePage():void{
Game.gameStage = stage;
removePage();
game = getGame();
game.x = titleX;
game.y = titleY;
this.addChildAt(game, titleIndex);
musicGame = getMusicGame();
musicGameSoundChannel = musicGame.play(0, int.MAX_VALUE);
}
public function onMiddleMouseUp():void{
if (game){
game.onMiddleMouseUp();
};
}
public function showEnterHighScore(_arg1:int):void{
trace((("showEnterHighScore(" + _arg1) + ")"));
}
public function onRightMouseUp():void{
if (game){
game.onRightMouseUp();
};
}
public function gotoTitlePage():void{
removePage();
title = new Title();
title.x = titleX;
title.y = titleY;
this.addChildAt(title, titleIndex);
}
private function checkTitle(_arg1:Event):void{
if (!(title = getTitle())){
return;
};
titleX = title.x;
titleY = title.y;
this.removeEventListener(Event.ENTER_FRAME, checkTitle);
stop();
titleIndex = this.getChildIndex(title);
}
}
}//package com.novelgames.flashgames.common
Section 5
//MuteButton (com.novelgames.flashgames.common.MuteButton)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.display.*;
import flash.media.*;
public class MuteButton extends MovieClip {
private var gameSoundTransform:SoundTransform;
public function MuteButton(){
if (SoundMixer.soundTransform.volume == 0){
showOff();
} else {
showOn();
};
this.addEventListener(MouseEvent.CLICK, buttonClicked);
this.buttonMode = true;
}
private function showOff():void{
gotoAndStop("off");
}
private function buttonClicked(_arg1:MouseEvent):void{
var _local2:SoundTransform = new SoundTransform();
if (SoundMixer.soundTransform.volume == 0){
_local2.volume = 1;
SoundMixer.soundTransform = _local2;
showOn();
} else {
_local2.volume = 0;
SoundMixer.soundTransform = _local2;
showOff();
};
}
private function showOn():void{
gotoAndStop("on");
}
}
}//package com.novelgames.flashgames.common
Section 6
//NewTimer (com.novelgames.flashgames.common.NewTimer)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.utils.*;
public class NewTimer extends Timer {
private var adjustedStartTime:int;
private var originalRepeatCount:int;
private var originalDelay:int;
private var listener:Function;
private static var pauseTime:int;
private static var paused:Boolean = false;
private static var totalPausedTime:int = 0;
public function NewTimer(_arg1:Number, _arg2:int=0):void{
super(_arg1, _arg2);
originalDelay = _arg1;
originalRepeatCount = _arg2;
}
override public function start():void{
adjustedStartTime = NewTimer.getTimer();
super.start();
}
private function timerEventListener(_arg1:TimerEvent):void{
if (paused){
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
return;
};
if ((NewTimer.getTimer() - adjustedStartTime) >= originalDelay){
adjustedStartTime = NewTimer.getTimer();
if (delay != originalDelay){
stop();
delay = originalDelay;
super.start();
};
listener(_arg1);
} else {
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
};
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
if (_arg1 != TimerEvent.TIMER){
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
return;
};
this.listener = _arg2;
super.addEventListener(_arg1, timerEventListener);
}
public static function unpause():void{
if (!paused){
return;
};
paused = false;
totalPausedTime = (totalPausedTime + (getTimer() - pauseTime));
}
public static function getTimer():int{
if (paused){
return ((pauseTime - totalPausedTime));
};
return ((getTimer() - totalPausedTime));
}
public static function pause():void{
if (paused){
return;
};
paused = true;
pauseTime = getTimer();
}
}
}//package com.novelgames.flashgames.common
Section 7
//Title (com.novelgames.flashgames.common.Title)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.display.*;
public class Title extends MovieClip {
public var startButton:SimpleButton;
public function Title(){
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
}
private function startButtonClicked(_arg1:MouseEvent):void{
Object(parent).gotoInstructionsPage();
}
}
}//package com.novelgames.flashgames.common
Section 8
//Block (com.novelgames.flashgames.towerblocks.Block)
package com.novelgames.flashgames.towerblocks {
import flash.display.*;
public class Block extends MovieClip {
public var centreX:Number;
public function Block(){
stop();
this["cacheAsBitmap"] = true;
}
public function showHighlight():void{
gotoAndStop("highlighted");
}
}
}//package com.novelgames.flashgames.towerblocks
Section 9
//BlockSpark (com.novelgames.flashgames.towerblocks.BlockSpark)
package com.novelgames.flashgames.towerblocks {
import flash.events.*;
import flash.display.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
public class BlockSpark extends MovieClip {
private var timer:Timer;
private var block:Block;
private var startTime:int;
public function initialize(_arg1:Block):void{
this.block = _arg1;
this.x = _arg1.x;
this.y = _arg1.y;
stop();
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onTime);
timer.start();
}
private function onTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((_local2 - startTime) / Config.SPARK_SHOWTIME);
var _local4:int = (Math.floor((totalFrames * _local3)) + 1);
_arg1.updateAfterEvent();
this.x = block.x;
this.y = block.y;
if (_local4 > totalFrames){
_local4 = totalFrames;
};
gotoAndStop(_local4);
if (_local3 >= 1){
timer.stop();
parent.removeChild(this);
};
}
}
}//package com.novelgames.flashgames.towerblocks
Section 10
//Cloud (com.novelgames.flashgames.towerblocks.Cloud)
package com.novelgames.flashgames.towerblocks {
import flash.display.*;
public dynamic class Cloud extends MovieClip {
}
}//package com.novelgames.flashgames.towerblocks
Section 11
//Clouds (com.novelgames.flashgames.towerblocks.Clouds)
package com.novelgames.flashgames.towerblocks {
import flash.events.*;
import flash.display.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
public class Clouds extends MovieClip {
private var cloudSpeeds:Array;
private var lastTime:int;
private var timer:Timer;
private var nextCloudY:Number;
private var clouds:Array;
public function Clouds(){
var _local1:Cloud;
super();
clouds = new Array();
cloudSpeeds = new Array();
nextCloudY = Config.CLOUDS_STARTY;
generateNextCloud();
lastTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onTime);
timer.start();
}
private function generateNextCloudY():void{
var _local1:Cloud = clouds[(clouds.length - 1)];
var _local2:Number = (Config.CLOUDS_MINSPACING + (Math.random() * (Config.CLOUDS_MAXSPACING - Config.CLOUDS_MINSPACING)));
nextCloudY = ((_local1.y - (_local1.height / 2)) - _local2);
}
public function scroll(_arg1:Number):void{
var _local2:int;
_local2 = 0;
while (_local2 < clouds.length) {
clouds[_local2].y = (clouds[_local2].y + _arg1);
if ((clouds[_local2].y - (clouds[_local2].height / 2)) > Config.CLOUDS_MAXY){
this.removeChild(clouds[_local2]);
clouds.splice(_local2, 1);
cloudSpeeds.splice(_local2, 1);
_local2--;
};
_local2++;
};
nextCloudY = (nextCloudY + _arg1);
while (nextCloudY > Config.CLOUDS_MINY) {
generateNextCloud();
};
}
private function generateNextCloud():void{
var _local2:Number;
var _local1:Cloud = new Cloud();
_local1.gotoAndStop((Math.floor((Math.random() * _local1.totalFrames)) + 1));
_local1.x = (Config.CLOUDS_MINX + (Math.random() * (Config.CLOUDS_MAXX - Config.CLOUDS_MINX)));
_local1.y = (nextCloudY - (_local1.height / 2));
clouds.push(_local1);
this.addChild(_local1);
_local2 = (Config.CLOUDS_MINSPEED + (Math.random() * (Config.CLOUDS_MAXSPEED - Config.CLOUDS_MINSPEED)));
cloudSpeeds.push(_local2);
generateNextCloudY();
}
private function onTime(_arg1:TimerEvent):void{
var _local4:int;
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - lastTime);
_local4 = 0;
while (_local4 < clouds.length) {
if ((clouds[_local4].y + (clouds[_local4].height / 2)) < Config.CLOUDS_MINY){
} else {
if ((clouds[_local4].y - (clouds[_local4].height / 2)) > Config.CLOUDS_MAXY){
} else {
clouds[_local4].x = (clouds[_local4].x + ((_local3 * cloudSpeeds[_local4]) / 1000));
};
};
_local4++;
};
lastTime = _local2;
}
}
}//package com.novelgames.flashgames.towerblocks
Section 12
//Config (com.novelgames.flashgames.towerblocks.Config)
package com.novelgames.flashgames.towerblocks {
public class Config {
public static var LINE_BLOCKSPACING:Number = 50;
public static var CLOUDS_MAXY:Number = 400;
public static var CLOUDS_MINSPACING:Number = 50;
public static var LINE_MOVEDOWNSPEED:Number = 200;
public static var BLOCK_MISSY:Number = 580;
public static var SPARK_SHOWTIME:int = 1300;
public static var MESSAGE_GAMEOVERTIME:int = 1000;
public static var BLOCK_SWINGPERIODINCREASE:int = 100;
public static var SCOREPOPUP_PREFIX:String = "+";
public static var BLOCK_SWINGAMPLITUDEINCREASE:Number = 1;
public static var CLOUDS_MINY:Number = 0;
public static var BLOCK_MISSTOLERANCE:Number = 20;
public static var SCORE_PERFECT:int = 200;
public static var BLOCK_ACCELERATION:Number = 1000;
public static var CLOUDS_MINX:Number = 0;
public static var BLOCK_SCROLLSPEED:Number = 50;
public static var BLOCK_SWINGMAXAMPLITUDE:Number = 200;
public static var LINE_TOPX:Number = 300;
public static var LINE_TOPY:Number = -300;
public static var BLOCK_SWINGHEIGHT:int = 10;
public static var LINE_MOVEUPSPEED:Number = 500;
public static var LINE_BLOCKSTARTX:Number = 300;
public static var LINE_BLOCKSTARTY:Number = -50;
public static var SCOREPOPUP_MOVEHEIGHT:Number = 50;
public static var MESSAGE_MISSTIME:int = 2000;
public static var LINE_THICKNESS:Number = 20;
public static var BLOCK_PERFECTTOLERANCE:Number = 10;
public static var BLOCK_SWINGINITIALAMPLITUDE:int = 1;
public static var CLOUDS_MAXSPEED:Number = 20;
public static var SCORE_NORMAL:int = 100;
public static var CLOUDS_MAXX:Number = 600;
public static var BLOCK_SWINGINITIALPERIOD:int = 2000;
public static var BLOCK_SCROLLY:Number = 250;
public static var BLOCK_MISSROTATESPEED:Number = 180;
public static var LINE_AMPLITUDE:Number = 150;
public static var SCORE_COMBO:int = 50;
public static var SCOREPOPUP_MOVETIME:int = 300;
public static var CLOUDS_STARTY:Number = -100;
public static var SCOREPOPUP_STAYTIME:int = 500;
public static var LINE_PERIOD:int = 4000;
public static var CLOUDS_MAXSPACING:Number = 200;
public static var CLOUDS_MINSPEED:Number = 5;
public static var LINE_COLOUR:uint = 4594182;
public static var BLOCK_SWINGMAXPERIOD:int = 10000;
public static var LIFE:int = 3;
}
}//package com.novelgames.flashgames.towerblocks
Section 13
//Game (com.novelgames.flashgames.towerblocks.Game)
package com.novelgames.flashgames.towerblocks {
import flash.events.*;
import flash.display.*;
import com.novelgames.flashgames.common.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
public class Game extends Game {
private var soundPut:Sound;
public var sparksHolder:MovieClip;
private var soundPerfect:Sound;
private var blocks:Array;
public var message:Message;
private var combo:int;
private var dropTimer:Timer;
private var swingDistanceFromCentre:Number;
public var desk:MovieClip;
private var swingPhase:Number;
private var soundDrop:Sound;
private var swingAmplitude:Number;
private var soundMiss:Sound;
public var scoresHolder:MovieClip;
public var background:MovieClip;
private var soundGameOver:Sound;
private var __score:int;
private var startDropBlockY:Number;
public var lifeText:TextField;
private var timer:Timer;
public var blocksHolder:MovieClip;
public var stand:MovieClip;
private var __life:int;
private var startDropTime:int;
public var scoreText:TextField;
public var clouds:Clouds;
private var swingPeriod:int;
private var swingTimer:Timer;
public var clickDetector:MovieClip;
private var lastScrollTime:int;
public var line:Line;
private var lastSwingTime:int;
private var scrollTimer:Timer;
private var lineBlock:Block;
public var noOfBlocksText:TextField;
private var missBlockRotateSpeed:Number;
private var __noOfBlocks:int;
public function Game(){
score = 0;
life = Config.LIFE;
noOfBlocks = 0;
soundDrop = new SoundDrop();
soundPut = new SoundPut();
soundPerfect = new SoundPerfect();
soundMiss = new SoundMiss();
soundGameOver = new SoundGameOver();
startGame();
}
private function onScrollTime(_arg1:TimerEvent):void{
var _local4:Block;
var _local5:int;
var _local2:int = NewTimer.getTimer();
var _local3:Number = (((_local2 - lastScrollTime) * Config.BLOCK_SCROLLSPEED) / 1000);
_arg1.updateAfterEvent();
_local4 = blocks[(blocks.length - 1)];
if (((_local4.y - (_local4.height / 2)) + _local3) > Config.BLOCK_SCROLLY){
_local3 = ((Config.BLOCK_SCROLLY - _local4.y) + (_local4.height / 2));
scrollTimer.stop();
};
stand.y = (stand.y + _local3);
_local5 = 0;
while (_local5 < blocks.length) {
blocks[_local5].y = (blocks[_local5].y + _local3);
_local5++;
};
background.y = (background.y + (_local3 / 2));
desk.y = (desk.y + _local3);
clouds.scroll(_local3);
lastScrollTime = _local2;
}
public function get life():int{
return (__life);
}
private function checkScroll():void{
var _local1:Block;
if (blocks.length == 0){
return;
};
_local1 = blocks[(blocks.length - 1)];
if ((_local1.y - (_local1.height / 2)) > Config.BLOCK_SCROLLY){
return;
};
lastScrollTime = NewTimer.getTimer();
if (scrollTimer){
scrollTimer.stop();
};
scrollTimer = new NewTimer(1, 0);
scrollTimer.addEventListener(TimerEvent.TIMER, onScrollTime);
scrollTimer.start();
}
private function showSparks(_arg1:Block):void{
var _local2:BlockSpark = new BlockSpark();
_local2.initialize(_arg1);
sparksHolder.addChild(_local2);
}
private function showGameOver(_arg1:TimerEvent):void{
message.showGameOver();
timer = new NewTimer(Config.MESSAGE_GAMEOVERTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showPlayAgain);
timer.start();
}
private function onDropMouseDown(_arg1:MouseEvent):void{
line.endBlock();
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onDropMouseDown);
clickDetector.buttonMode = false;
startDropBlockY = lineBlock.y;
soundDrop.play();
startDropTime = NewTimer.getTimer();
dropTimer = new NewTimer(1, 0);
dropTimer.addEventListener(TimerEvent.TIMER, onDropBlockTime);
dropTimer.start();
}
public function get score():int{
return (__score);
}
private function checkGameOver():Boolean{
if (life > 0){
return (false);
};
message.showMiss();
soundGameOver.play();
timer = new NewTimer(Config.MESSAGE_MISSTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showGameOver);
timer.start();
return (true);
}
private function showPlayAgain(_arg1:TimerEvent):void{
Object(parent).showEnterHighScore(score);
message.showPlayAgain();
}
private function adjustSwing():void{
var _local1:Number;
if (blocks.length < Config.BLOCK_SWINGHEIGHT){
return;
};
swingPeriod = (Config.BLOCK_SWINGINITIALPERIOD + ((blocks.length - Config.BLOCK_SWINGHEIGHT) * Config.BLOCK_SWINGPERIODINCREASE));
if (swingPeriod > Config.BLOCK_SWINGMAXPERIOD){
swingPeriod = Config.BLOCK_SWINGMAXPERIOD;
};
swingAmplitude = (Config.BLOCK_SWINGINITIALAMPLITUDE + ((blocks.length - Config.BLOCK_SWINGHEIGHT) * Config.BLOCK_SWINGAMPLITUDEINCREASE));
if (swingAmplitude > Config.BLOCK_SWINGMAXAMPLITUDE){
swingAmplitude = Config.BLOCK_SWINGMAXAMPLITUDE;
};
}
public function get noOfBlocks():int{
return (__noOfBlocks);
}
private function onDropBlockTime(_arg1:TimerEvent):void{
var _local5:MovieClip;
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - startDropTime);
var _local4:Number = (((Config.BLOCK_ACCELERATION * _local3) * _local3) / 2000000);
_arg1.updateAfterEvent();
lineBlock.y = (startDropBlockY + _local4);
if (blocks.length == 0){
_local5 = stand;
} else {
_local5 = blocks[(blocks.length - 1)];
};
if (((startDropBlockY + _local4) + (lineBlock.height / 2)) >= (_local5.y - (_local5.height / 2))){
if (Math.abs((lineBlock.x - _local5.x)) >= (((_local5.width + lineBlock.width) / 2) - Config.BLOCK_MISSTOLERANCE)){
startDropBlockY = lineBlock.y;
startDropTime = _local2;
missBlockRotateSpeed = ((lineBlock.x > _local5.x)) ? Config.BLOCK_MISSROTATESPEED : -(Config.BLOCK_MISSROTATESPEED);
combo = 0;
soundMiss.play();
dropTimer.stop();
dropTimer = new NewTimer(1, 0);
dropTimer.addEventListener(TimerEvent.TIMER, onMissBlockTime);
dropTimer.start();
} else {
lineBlock.y = ((_local5.y - (_local5.height / 2)) - (lineBlock.height / 2));
if ((((blocks.length > 0)) && ((Math.abs((lineBlock.x - _local5.x)) <= Config.BLOCK_PERFECTTOLERANCE)))){
lineBlock.x = _local5.x;
lineBlock.showHighlight();
showSparks(lineBlock);
addScore(lineBlock.x, lineBlock.y, (Config.SCORE_PERFECT + (Config.SCORE_COMBO * combo)));
combo++;
soundPerfect.play();
} else {
addScore(lineBlock.x, lineBlock.y, Config.SCORE_NORMAL);
combo = 0;
soundPut.play();
};
blocks.push(lineBlock);
lineBlock.centreX = (lineBlock.x - swingDistanceFromCentre);
adjustSwing();
noOfBlocks++;
checkScroll();
dropTimer.stop();
startLine();
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onDropMouseDown);
clickDetector.buttonMode = true;
};
};
}
private function onMissBlockTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - startDropTime);
var _local4:Number = (((Config.BLOCK_ACCELERATION * _local3) * _local3) / 2000000);
_arg1.updateAfterEvent();
lineBlock.y = (startDropBlockY + _local4);
lineBlock.rotation = ((missBlockRotateSpeed * _local3) / 1000);
if (lineBlock.y > Config.BLOCK_MISSY){
dropTimer.stop();
blocksHolder.removeChild(lineBlock);
life--;
if (!checkGameOver()){
startLine();
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onDropMouseDown);
clickDetector.buttonMode = true;
};
};
}
public function set score(_arg1:int):void{
__score = _arg1;
scoreText.text = _arg1.toString();
}
private function startGame():void{
combo = 0;
blocks = new Array();
startLine();
swingPeriod = 0;
swingAmplitude = 0;
swingPhase = 0;
swingDistanceFromCentre = 0;
lastSwingTime = NewTimer.getTimer();
swingTimer = new NewTimer(1, 0);
swingTimer.addEventListener(TimerEvent.TIMER, onSwingTime);
swingTimer.start();
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onDropMouseDown);
clickDetector.buttonMode = true;
}
private function onSwingTime(_arg1:TimerEvent):void{
var _local3:int;
var _local2:int = NewTimer.getTimer();
_arg1.updateAfterEvent();
if (blocks.length >= Config.BLOCK_SWINGHEIGHT){
swingPhase = (swingPhase + (((_local2 - lastSwingTime) % swingPeriod) / swingPeriod));
swingDistanceFromCentre = (swingAmplitude * Math.sin(((swingPhase * Math.PI) * 2)));
_local3 = (blocks.length - 1);
while (_local3 >= 0) {
if ((blocks[_local3].y - (blocks[_local3].height / 2)) > Config.BLOCK_MISSY){
break;
};
blocks[_local3].x = (blocks[_local3].centreX + swingDistanceFromCentre);
_local3--;
};
};
lastSwingTime = _local2;
}
public function set noOfBlocks(_arg1:int):void{
__noOfBlocks = _arg1;
noOfBlocksText.text = _arg1.toString();
}
private function addScore(_arg1:Number, _arg2:Number, _arg3:int):void{
var _local4:ScorePopup = new ScorePopup();
this.score = (this.score + _arg3);
_local4.initialize(_arg1, _arg2, _arg3);
scoresHolder.addChild(_local4);
}
private function startLine():void{
lineBlock = new Block();
blocksHolder.addChild(lineBlock);
line.startBlock(lineBlock, ((stand.y - (stand.height / 2)) - (blocks.length * ((blocks.length == 0)) ? 0 : blocks[0].height)));
}
public function set life(_arg1:int):void{
__life = _arg1;
lifeText.text = _arg1.toString();
}
}
}//package com.novelgames.flashgames.towerblocks
Section 14
//Line (com.novelgames.flashgames.towerblocks.Line)
package com.novelgames.flashgames.towerblocks {
import flash.events.*;
import flash.display.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
public class Line extends MovieClip {
private var lastTime:int;
private var timer:Timer;
private var targetLineLength:Number;
private var block:Block;
private var startTime:int;
public var attacher:MovieClip;
private var lineLength:Number;
public function Line(){
x = 0;
y = 20;
}
private function onMoveUpTime(_arg1:TimerEvent):void{
var _local5:Number;
var _local6:Number;
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - lastTime);
var _local4:Number = ((((_local2 - startTime) % Config.LINE_PERIOD) / Config.LINE_PERIOD) - 0.25);
if (_arg1){
_arg1.updateAfterEvent();
};
if (lineLength > targetLineLength){
lineLength = (lineLength - ((Config.LINE_MOVEUPSPEED * _local3) / 1000));
if (lineLength < targetLineLength){
lineLength = targetLineLength;
};
};
_local5 = (Config.LINE_AMPLITUDE * Math.sin(((_local4 * Math.PI) * 2)));
_local6 = Math.sqrt(((lineLength * lineLength) - (_local5 * _local5)));
attacher.x = (Config.LINE_TOPX + _local5);
attacher.y = (Config.LINE_TOPY + _local6);
updateLine();
lastTime = _local2;
}
public function startBlock(_arg1:Block, _arg2:Number):void{
this.block = _arg1;
_arg1.x = Config.LINE_BLOCKSTARTX;
_arg1.y = Config.LINE_BLOCKSTARTY;
attacher.x = _arg1.x;
attacher.y = ((_arg1.y - (_arg1.height / 2)) - (attacher.height / 2));
lineLength = ((attacher.y - (attacher.height / 2)) - Config.LINE_TOPY);
targetLineLength = ((((_arg2 - Config.LINE_BLOCKSPACING) - _arg1.height) - attacher.height) - Config.LINE_TOPY);
startTime = NewTimer.getTimer();
lastTime = startTime;
onMoveDownTime();
if (timer){
timer.stop();
};
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onMoveDownTime);
timer.start();
}
public function endBlock():void{
if (timer){
timer.stop();
};
targetLineLength = (((Config.LINE_BLOCKSTARTY - (block.height / 2)) - attacher.height) - Config.LINE_TOPY);
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onMoveUpTime);
timer.start();
}
private function updateLine():void{
this.graphics.clear();
this.graphics.lineStyle(Config.LINE_THICKNESS, Config.LINE_COLOUR);
this.graphics.moveTo(Config.LINE_TOPX, Config.LINE_TOPY);
this.graphics.lineTo(attacher.x, (attacher.y - (attacher.height / 2)));
}
private function onMoveDownTime(_arg1:TimerEvent=null):void{
var _local5:Number;
var _local6:Number;
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - lastTime);
var _local4:Number = ((((_local2 - startTime) % Config.LINE_PERIOD) / Config.LINE_PERIOD) - 0.25);
if (_arg1){
_arg1.updateAfterEvent();
};
if (lineLength < targetLineLength){
lineLength = (lineLength + ((Config.LINE_MOVEDOWNSPEED * _local3) / 1000));
if (lineLength > targetLineLength){
lineLength = targetLineLength;
};
};
_local5 = (Config.LINE_AMPLITUDE * Math.sin(((_local4 * Math.PI) * 2)));
_local6 = Math.sqrt(((lineLength * lineLength) - (_local5 * _local5)));
attacher.x = (Config.LINE_TOPX + _local5);
attacher.y = (Config.LINE_TOPY + _local6);
block.x = attacher.x;
block.y = ((attacher.y + (attacher.height / 2)) + (block.height / 2));
updateLine();
lastTime = _local2;
}
}
}//package com.novelgames.flashgames.towerblocks
Section 15
//Main (com.novelgames.flashgames.towerblocks.Main)
package com.novelgames.flashgames.towerblocks {
import com.novelgames.flashgames.common.*;
import flash.media.*;
public class Main extends MainDevelopment {
public var title:Title;
override protected function getMusicGame():Sound{
return (new MusicGame());
}
override protected function getTitle():Title{
return (title);
}
override protected function getGame():Game{
return (new Game());
}
}
}//package com.novelgames.flashgames.towerblocks
Section 16
//Message (com.novelgames.flashgames.towerblocks.Message)
package com.novelgames.flashgames.towerblocks {
import flash.events.*;
import flash.display.*;
public class Message extends MovieClip {
public function Message(){
stop();
visible = false;
}
public function showMiss():void{
gotoAndStop("miss");
visible = true;
}
public function showGameOver():void{
gotoAndStop("gameOver");
visible = true;
}
private function homeButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoTitlePage();
}
private function playAgainButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoGamePage();
}
public function showPlayAgain():void{
var _local1:MessagePlayAgain;
_local1 = new MessagePlayAgain();
_local1.playAgainButton.addEventListener(MouseEvent.CLICK, playAgainButtonClicked);
_local1.homeButton.addEventListener(MouseEvent.CLICK, homeButtonClicked);
this.addChild(_local1);
}
}
}//package com.novelgames.flashgames.towerblocks
Section 17
//MessagePlayAgain (com.novelgames.flashgames.towerblocks.MessagePlayAgain)
package com.novelgames.flashgames.towerblocks {
import flash.display.*;
public dynamic class MessagePlayAgain extends MovieClip {
public var homeButton:SimpleButton;
public var playAgainButton:SimpleButton;
}
}//package com.novelgames.flashgames.towerblocks
Section 18
//MusicGame (com.novelgames.flashgames.towerblocks.MusicGame)
package com.novelgames.flashgames.towerblocks {
import flash.media.*;
public dynamic class MusicGame extends Sound {
}
}//package com.novelgames.flashgames.towerblocks
Section 19
//ScorePopup (com.novelgames.flashgames.towerblocks.ScorePopup)
package com.novelgames.flashgames.towerblocks {
import flash.events.*;
import flash.display.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
import flash.text.*;
public class ScorePopup extends MovieClip {
private var timer:Timer;
private var startTime:int;
private var startY:Number;
public var scoreText:TextField;
private function stayFinished(_arg1:TimerEvent):void{
parent.removeChild(this);
}
public function initialize(_arg1:Number, _arg2:Number, _arg3:int):void{
scoreText.text = (Config.SCOREPOPUP_PREFIX + _arg3);
this.x = _arg1;
this.y = _arg2;
startY = _arg2;
this.mouseEnabled = false;
this.mouseChildren = false;
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onMoveTime);
timer.start();
}
private function onMoveTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((_local2 - startTime) / Config.SCOREPOPUP_MOVETIME);
if (_local3 > 1){
_local3 = 1;
};
_arg1.updateAfterEvent();
this.y = (startY - (Math.sin((_local3 * Math.PI)) * Config.SCOREPOPUP_MOVEHEIGHT));
if (_local3 >= 1){
timer.stop();
timer = new NewTimer(Config.SCOREPOPUP_STAYTIME, 1);
timer.addEventListener(TimerEvent.TIMER, stayFinished);
timer.start();
};
}
}
}//package com.novelgames.flashgames.towerblocks
Section 20
//SoundDrop (com.novelgames.flashgames.towerblocks.SoundDrop)
package com.novelgames.flashgames.towerblocks {
import flash.media.*;
public dynamic class SoundDrop extends Sound {
}
}//package com.novelgames.flashgames.towerblocks
Section 21
//SoundGameOver (com.novelgames.flashgames.towerblocks.SoundGameOver)
package com.novelgames.flashgames.towerblocks {
import flash.media.*;
public dynamic class SoundGameOver extends Sound {
}
}//package com.novelgames.flashgames.towerblocks
Section 22
//SoundMiss (com.novelgames.flashgames.towerblocks.SoundMiss)
package com.novelgames.flashgames.towerblocks {
import flash.media.*;
public dynamic class SoundMiss extends Sound {
}
}//package com.novelgames.flashgames.towerblocks
Section 23
//SoundPerfect (com.novelgames.flashgames.towerblocks.SoundPerfect)
package com.novelgames.flashgames.towerblocks {
import flash.media.*;
public dynamic class SoundPerfect extends Sound {
}
}//package com.novelgames.flashgames.towerblocks
Section 24
//SoundPut (com.novelgames.flashgames.towerblocks.SoundPut)
package com.novelgames.flashgames.towerblocks {
import flash.media.*;
public dynamic class SoundPut extends Sound {
}
}//package com.novelgames.flashgames.towerblocks