Section 1
//Block (Block)
package {
import flash.display.*;
import flash.geom.*;
public class Block extends MovieClip {
private var _shapeType:int;// = 0
public var rotate:int;// = 0
private var _blockSize:int;
private var _blockShape:Array;
public var location:Point;
public function Block(_arg1:int){
var _local2:*;
var _local3:BlockMC;
_shapeType = 0;
location = new Point(0, 0);
rotate = 0;
_blockShape = new Array();
super();
_blockShape.push([0, -1, 0, 1, 0, 2]);
_blockShape.push([-1, 0, 1, 0, 0, 1]);
_blockShape.push([0, -1, 1, 0, 1, 1]);
_blockShape.push([0, -1, -1, 0, -1, 1]);
_blockShape.push([0, -1, -1, -1, 0, 1]);
_blockShape.push([0, -1, 1, -1, 0, 1]);
_blockShape.push([1, 0, 0, 1, 1, 1]);
_blockShape.push([0, -3, 0, -2, 0, -1, 0, 1, 0, 2, 0, 3, 0, 4]);
_blockSize = _arg1;
_local2 = 0;
while (_local2 < 8) {
_local3 = new BlockMC();
_local3.width = _blockSize;
_local3.height = _blockSize;
this.addChild(_local3);
_local2++;
};
}
public function getShapePosArray(_arg1, _arg2, _arg3):Array{
var _local4:Array;
var _local5:Array;
var _local6:*;
var _local7:*;
var _local8:*;
_local4 = new Array();
_local5 = _blockShape[shapeType];
_local4.push({x:_arg1, y:_arg2});
_local6 = 0;
while (_local6 < (_local5.length / 2)) {
_local7 = _local5[(_local6 * 2)];
_local8 = _local5[((_local6 * 2) + 1)];
switch (_arg3){
case 1:
_local7 = -(_local5[((_local6 * 2) + 1)]);
_local8 = _local5[(_local6 * 2)];
break;
case 2:
_local7 = -(_local5[(_local6 * 2)]);
_local8 = -(_local5[((_local6 * 2) + 1)]);
break;
case 3:
_local7 = _local5[((_local6 * 2) + 1)];
_local8 = -(_local5[(_local6 * 2)]);
break;
};
_local7 = (_local7 + _arg1);
_local8 = (_local8 + _arg2);
_local4.push({x:_local7, y:_local8});
_local6++;
};
return (_local4);
}
public function setShapePos():void{
var _local1:Array;
var _local2:*;
_local1 = getShapePosArray(location.x, location.y, rotate);
_local2 = 0;
while (_local2 < _local1.length) {
this.getChildAt(_local2).x = (_local1[_local2].x * _blockSize);
this.getChildAt(_local2).y = (_local1[_local2].y * _blockSize);
_local2++;
};
}
public function get shapeType():int{
return (_shapeType);
}
public function set shapeType(_arg1:int){
var _local2:Array;
var _local3:int;
var _local4:*;
var _local5:ColorTransform;
var _local6:*;
var _local7:*;
var _local8:*;
_shapeType = _arg1;
_local2 = _blockShape[_shapeType];
_local3 = (Math.floor((_local2.length / 2)) + 1);
_local4 = 0;
while (_local4 < this.numChildren) {
this.getChildAt(_local4).visible = (_local4 < _local3);
_local4++;
};
if (_shapeType < 7){
_local6 = ((((_shapeType + 1) & 4))==4) ? 1 : 0.2;
_local7 = ((((_shapeType + 1) & 2))==2) ? 1 : 0.2;
_local8 = ((((_shapeType + 1) & 1))==1) ? 1 : 0.2;
_local5 = new ColorTransform(_local8, _local7, _local6, 1, 0, 0, 0, 0);
} else {
_local5 = new ColorTransform(0.7, 0.7, 0.7, 1, 0, 0, 0, 0);
};
this.transform.colorTransform = _local5;
_local4 = 0;
while (_local4 < _local3) {
this.getChildAt(_local4).transform.colorTransform = _local5;
_local4++;
};
}
}
}//package
Section 2
//BlockMC (BlockMC)
package {
import flash.display.*;
public dynamic class BlockMC extends MovieClip {
}
}//package
Section 3
//BlockSet (BlockSet)
package {
import flash.events.*;
import flash.media.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class BlockSet extends MovieClip {
private const BGCOLOR:uint = 0xFFFFFF;
private const MAINVOL:Number = 0;
private var _soundBtn:SoundMC;
private var _skip:Number;// = 6
private var _keyOld:Boolean;// = true
private var _color:ColorTransform;
private var _eventBlockCount:int;// = 10
private var _pauseTimer:Timer;
private var _keyBtn:KeyMC;
private var _burn:BurnBlock;// = null
private var _blockSize:int;// = 6
private var _rotateSound:Sound;
private var _num:int;// = 0
private var _keyAct:uint;// = 0
private var _keyRep:Boolean;// = false
private var _matrix:Matrix;
private var _pause:PauseBTN;
private var _mute:Boolean;// = false
private var _pauseCounter:PauseMC;// = null
private var _landingSound:Sound;
private var _gameover:GameOverMC;
private var _preblock:Block;
private var _stagewidth:int;// = 1
private var _rotateChannel:SoundChannel;// = null
private var _mainChannel:SoundChannel;
private var _mainSound:Sound;
private var _start:StartBTN;
private var _block:Block;
private var _bmpData:BitmapData;
private var _score:ScoreMC;
private var _preLanding:Boolean;// = false
private var _key:uint;// = 0
private var _startDate:Date;
private var _mainTransform:SoundTransform;
private var _stageheight:int;// = 1
private var _eventBlockCounter:int;// = 0
public function BlockSet(){
var _local1:Bitmap;
_burn = null;
_pauseCounter = null;
_stagewidth = 1;
_stageheight = 1;
_preLanding = false;
_skip = 6;
_eventBlockCount = 10;
_eventBlockCounter = 0;
_num = 0;
_key = 0;
_keyAct = 0;
_keyRep = false;
_keyOld = true;
_blockSize = 6;
_mute = false;
_rotateSound = new RotateSound();
_rotateChannel = null;
_landingSound = new LandingSound();
_mainSound = new MainSound();
super();
_mainTransform = new SoundTransform();
_mainTransform.volume = MAINVOL;
_matrix = new Matrix(1, 0, 0, 1, 0, 0);
_color = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
_stagewidth = Math.floor((1920 / _blockSize));
_stageheight = Math.floor((1080 / _blockSize));
_bmpData = new BitmapData((_stagewidth * _blockSize), (_stageheight * _blockSize), false, BGCOLOR);
_local1 = new Bitmap(_bmpData, PixelSnapping.AUTO, false);
stage.addChild(_local1);
_block = new Block(_blockSize);
_block.visible = false;
stage.addChild(_block);
_block.shapeType = 0;
_preblock = new Block(_blockSize);
_preblock.visible = false;
stage.addChild(_preblock);
_preblock.shapeType = 0;
_score = new ScoreMC();
stage.addChild(_score);
_gameover = new GameOverMC();
_gameover.visible = false;
_gameover.x = (stage.width / 2);
_gameover.y = ((stage.height / 2) - 10);
stage.addChild(_gameover);
_start = new StartBTN();
_start.x = (stage.width / 2);
_start.y = (_gameover.y + _gameover.height);
stage.addChild(_start);
_start.addEventListener(MouseEvent.CLICK, this.onRestartClick);
_pause = new PauseBTN();
_pause.x = (_stagewidth * _blockSize);
_pause.y = 0;
_pause.visible = false;
stage.addChild(_pause);
_pause.addEventListener(MouseEvent.CLICK, this.onPause);
_soundBtn = new SoundMC();
_soundBtn.x = (_stagewidth * _blockSize);
_soundBtn.y = 30;
stage.addChild(_soundBtn);
_soundBtn.addEventListener(MouseEvent.CLICK, onSound);
_keyBtn = new KeyMC();
_keyBtn.x = (_stagewidth * _blockSize);
_keyBtn.y = 60;
_keyOld = true;
_keyBtn.oldBtn();
stage.addChild(_keyBtn);
_keyBtn.addEventListener(MouseEvent.CLICK, onKeymodeChange);
}
private function onPauseEnd(_arg1:Event):void{
pauseRestart();
}
public function restart(){
_gameover.visible = false;
_start.visible = false;
_preblock.visible = false;
_bmpData.fillRect(new Rectangle(0, 0, _bmpData.width, _bmpData.height), BGCOLOR);
_score.Lines = 0;
_score.Score = 0;
_score.Time = 0;
_skip = 20;
_key = 0;
_block.visible = true;
_pause.visible = true;
_eventBlockCount = 0;
_eventBlockCounter = 0;
_startDate = new Date();
resetPre();
resetPos();
_mainChannel = _mainSound.play(1, 999999, _mainTransform);
stage.addEventListener(Event.ENTER_FRAME, this.onEnter, false, 0, true);
stage.addEventListener(KeyboardEvent.KEY_DOWN, this.onKeydown, false, 0, true);
stage.addEventListener(KeyboardEvent.KEY_UP, this.onKeyup, false, 0, true);
}
private function landing(){
var _local1:Array;
var _local2:int;
var _local3:int;
var _local4:*;
var _local5:int;
var _local6:Array;
var _local7:*;
var _local8:Rectangle;
var _local9:Boolean;
var _local10:*;
_local1 = _block.getShapePosArray(_block.location.x, _block.location.y, _block.rotate);
_local2 = _block.location.y;
_local3 = _local2;
if (!_mute){
_landingSound.play(0, 0);
};
_local4 = 0;
while (_local4 < _local1.length) {
_local8 = new Rectangle((_local1[_local4].x * _blockSize), (_local1[_local4].y * _blockSize), _blockSize, _blockSize);
_bmpData.draw(stage, _matrix, _color, BlendMode.NORMAL, _local8, true);
if (_local1[_local4].y < _local2){
_local2 = _local1[_local4].y;
};
if (_local1[_local4].y > _local3){
_local3 = _local1[_local4].y;
};
_local4++;
};
_local5 = 0;
_local6 = new Array();
_local7 = _local2;
while (_local7 <= _local3) {
_local9 = true;
_local10 = 0;
while (_local10 < _stagewidth) {
if (!isBlock(_local10, _local7)){
_local9 = false;
break;
};
_local10++;
};
if (_local9){
_local6.push(_local7);
};
_local7++;
};
if (_local6.length > 0){
_block.visible = false;
_burn = new BurnBlock(_local6, _stagewidth, _blockSize, this, _mute);
stage.addChild(_burn);
return;
};
resetPos();
if (!canMove(_block.location.x, _block.location.y, _block.rotate)){
gameover();
};
}
private function onPauseTimer(_arg1:TimerEvent):void{
if ((_pauseCounter.time - 1) <= 0){
pauseRestart();
} else {
_pauseCounter.time--;
};
}
private function onRestartClick(_arg1:MouseEvent):void{
restart();
}
private function onEnter(_arg1:Event):void{
var _local2:Date;
var _local3:int;
_local2 = new Date();
_score.Time = (_local2.getTime() - _startDate.getTime());
if ((((_burn == null)) && ((_pauseCounter == null)))){
_num++;
if (_keyRep){
keyAction();
};
if ((((_key == 13)) || ((((_key == 38)) && (!(_keyOld)))))){
_num = 0;
_local3 = 0;
while (canMove(_block.location.x, (_block.location.y + 1), _block.rotate)) {
_block.location.y++;
_block.setShapePos();
_local3++;
if (_local3 > 3){
break;
};
};
if (!canMove(_block.location.x, (_block.location.y + 1), _block.rotate)){
landing();
_key = 0;
};
} else {
if ((((((_num > _skip)) || ((((_key == 32)) && (_keyOld))))) || ((((_key == 40)) && (!(_keyOld)))))){
_num = 0;
if (canMove(_block.location.x, (_block.location.y + 1), _block.rotate)){
_block.location.y++;
_preLanding = false;
_block.setShapePos();
} else {
if (_preLanding){
landing();
} else {
_preLanding = true;
};
};
};
};
};
}
public function spin(_arg1:int):void{
var _local2:int;
if (_block.shapeType != 6){
_local2 = (((4 + _block.rotate) + _arg1) % 4);
if (canMove(_block.location.x, _block.location.y, _local2)){
_block.rotate = _local2;
_block.setShapePos();
};
};
if (!_mute){
if (_rotateChannel != null){
_rotateChannel.stop();
};
_rotateChannel = _rotateSound.play(1, 0);
};
}
public function toRight():void{
if (canMove((_block.location.x + 1), _block.location.y, _block.rotate)){
_block.location.x++;
_block.setShapePos();
};
}
private function onSound(_arg1:MouseEvent):void{
_mute = !(_mute);
if (_mute){
_mainTransform.volume = 0;
} else {
_mainTransform.volume = MAINVOL;
};
if (_mainChannel != null){
_mainChannel.soundTransform = _mainTransform;
};
_soundBtn.alpha = (_mute) ? 0.2 : 1;
}
public function resetPos(){
_block.rotate = 0;
_block.location.y = 1;
_block.location.x = _preblock.location.x;
_block.shapeType = _preblock.shapeType;
resetPre();
_block.setShapePos();
}
private function onKeyup(_arg1:KeyboardEvent):void{
_key = 0;
_keyRep = false;
}
private function onKeydown(_arg1:KeyboardEvent):void{
_keyRep = !((_key == 0));
if (_key != _arg1.keyCode){
_key = _arg1.keyCode;
keyAction();
};
}
private function resetPre(){
_preblock.location.x = (Math.floor((Math.random() * (_stagewidth - 12))) + 6);
_eventBlockCounter++;
if (_eventBlockCount == 0){
_eventBlockCount = (Math.floor(((Math.random() * _stagewidth) / 2)) + _stagewidth);
_eventBlockCounter = 0;
};
if (_eventBlockCounter == _eventBlockCount){
_eventBlockCount = 0;
_eventBlockCounter = 0;
_preblock.shapeType = 7;
} else {
_preblock.shapeType = Math.floor((Math.random() * 7));
};
_preblock.visible = true;
_preblock.alpha = 0.2;
_preblock.setShapePos();
}
public function endBreak():void{
var _local1:Array;
var _local2:*;
var _local3:*;
_local1 = _burn.dels;
_skip = (_skip - 0.2);
if (_skip <= 1){
_skip = 10;
};
_score.Score = (_score.Score + (Math.pow(2, _local1.length) * 10));
_score.Lines = (_score.Lines + _local1.length);
stage.removeChild(_burn);
_burn = null;
_local2 = 0;
while (_local2 < _local1.length) {
_local3 = _local1[_local2];
_bmpData.copyPixels(_bmpData, new Rectangle(0, 0, _bmpData.width, (_local3 * _blockSize)), new Point(0, _blockSize));
_bmpData.fillRect(new Rectangle(0, 0, _bmpData.width, _blockSize), BGCOLOR);
_local2++;
};
_pause.visible = true;
resetPos();
_block.visible = true;
if (!canMove(_block.location.x, _block.location.y, _block.rotate)){
gameover();
};
}
public function toLeft():void{
if (canMove((_block.location.x - 1), _block.location.y, _block.rotate)){
_block.location.x--;
_block.setShapePos();
};
}
private function onKeymodeChange(_arg1:MouseEvent):void{
_keyOld = !(_keyOld);
if (_keyOld){
_keyBtn.oldBtn();
} else {
_keyBtn.newBtn();
};
}
private function pauseRestart():void{
_pauseCounter.removeEventListener(MouseEvent.CLICK, onPauseEnd);
_pauseTimer.stop();
_pauseTimer.removeEventListener(TimerEvent.TIMER, onPauseTimer);
_pauseTimer = null;
stage.removeChild(_pauseCounter);
_pauseCounter = null;
_mainChannel = _mainSound.play(1, 999999, _mainTransform);
}
private function onPause(_arg1:MouseEvent):void{
_pause.visible = false;
_pauseCounter = new PauseMC();
_pauseCounter.x = (stage.width / 2);
_pauseCounter.y = (stage.height / 2);
_pauseCounter.time = 300;
stage.addChild(_pauseCounter);
_pauseTimer = new Timer(1000);
_pauseTimer.addEventListener(TimerEvent.TIMER, onPauseTimer, false, 0, true);
_pauseTimer.start();
_pauseCounter.addEventListener(MouseEvent.CLICK, onPauseEnd, false, 0, true);
_mainChannel.stop();
}
private function keyAction(){
if (_key != 0){
if (_pauseCounter != null){
pauseRestart();
_key = 0;
} else {
if (_burn == null){
switch (_key){
case 40:
if (_keyOld){
spin(-1);
};
break;
case 32:
if (!_keyOld){
spin(1);
};
break;
case 88:
spin(1);
break;
case 38:
if (_keyOld){
spin(-1);
};
break;
case 90:
spin(-1);
break;
case 37:
toLeft();
break;
case 39:
toRight();
break;
};
};
};
};
}
private function isBlock(_arg1, _arg2):Boolean{
var _local3:uint;
if ((((((_arg1 < 0)) || ((_arg1 >= _stagewidth)))) || ((_arg2 >= _stageheight)))){
return (true);
};
_local3 = _bmpData.getPixel(((_arg1 * _blockSize) + (_blockSize / 2)), ((_arg2 * _blockSize) + (_blockSize / 2)));
if (_local3 == 0){
return (false);
};
if (_local3 != 0xFFFFFF){
return (true);
};
return (false);
}
private function canMove(_arg1, _arg2, _arg3):Boolean{
var _local4:Array;
var _local5:*;
_local4 = _block.getShapePosArray(_arg1, _arg2, _arg3);
_local5 = 0;
while (_local5 < _local4.length) {
if (isBlock(_local4[_local5].x, _local4[_local5].y)){
return (false);
};
_local5++;
};
return (true);
}
public function gameover(){
_gameover.visible = true;
_start.visible = true;
_mainChannel.stop();
stage.removeEventListener(Event.ENTER_FRAME, this.onEnter);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, this.onKeydown);
stage.removeEventListener(KeyboardEvent.KEY_UP, this.onKeyup);
}
}
}//package
Section 4
//BreakMC (BreakMC)
package {
import flash.display.*;
public dynamic class BreakMC extends MovieClip {
public var _stopping:Boolean;
public function BreakMC(){
addFrameScript(0, frame1, 17, frame18);
}
function frame18(){
stop();
_stopping = true;
}
function frame1(){
_stopping = false;
}
public function get stopping():Boolean{
return (_stopping);
}
}
}//package
Section 5
//BurnBlock (BurnBlock)
package {
import flash.events.*;
import flash.media.*;
import flash.display.*;
public class BurnBlock extends MovieClip {
private var _expSound:Sound;
private var _last:BreakMC;
private var _dels:Array;
private var _expChannel:SoundChannel;// = null
private var _parent:BlockSet;
private var _width:int;
private var _size:int;
private var _mute:Boolean;
public function BurnBlock(_arg1:Array, _arg2:int, _arg3:int, _arg4:BlockSet, _arg5:Boolean){
_expSound = new ExpSound();
_expChannel = null;
super();
_dels = _arg1;
_width = _arg2;
_size = _arg3;
_parent = _arg4;
_mute = _arg5;
this.addEventListener(Event.ENTER_FRAME, onEnter, false, 0, true);
}
private function onEnter(_arg1:Event):void{
var _local2:int;
var _local3:*;
var _local4:*;
var _local5:BreakMC;
_local2 = this.numChildren;
if (_local2 < ((_dels.length * _width) - 1)){
_local3 = Math.floor((_local2 / _width));
_local4 = (((_local3 % 2))==0) ? (_local2 - (_local3 * _width)) : ((_width - (_local2 - (_local3 * _width))) - 1);
_local5 = new BreakMC();
_local5.x = (_local4 * _size);
_local5.y = (_dels[_local3] * _size);
_local5.width = _size;
_local5.height = _size;
if (!_mute){
if (_expChannel != null){
_expChannel.stop();
};
_expChannel = _expSound.play();
};
this.addChild(_local5);
_last = _local5;
} else {
if (_last.stopping){
this.removeEventListener(Event.ENTER_FRAME, onEnter);
_parent.endBreak();
};
};
}
public function get dels():Array{
return (_dels);
}
}
}//package
Section 6
//ExpSound (ExpSound)
package {
import flash.media.*;
public dynamic class ExpSound extends Sound {
}
}//package
Section 7
//GameOverMC (GameOverMC)
package {
import flash.display.*;
public dynamic class GameOverMC extends MovieClip {
}
}//package
Section 8
//KeyMC (KeyMC)
package {
import flash.display.*;
public dynamic class KeyMC extends MovieClip {
public function KeyMC(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
public function oldBtn():void{
gotoAndStop(1);
}
public function newBtn():void{
gotoAndStop(2);
}
}
}//package
Section 9
//LandingSound (LandingSound)
package {
import flash.media.*;
public dynamic class LandingSound extends Sound {
}
}//package
Section 10
//MainSound (MainSound)
package {
import flash.media.*;
public dynamic class MainSound extends Sound {
}
}//package
Section 11
//PauseBTN (PauseBTN)
package {
import flash.display.*;
public dynamic class PauseBTN extends SimpleButton {
}
}//package
Section 12
//PauseMC (PauseMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class PauseMC extends MovieClip {
public var pauseText:TextField;
public var _time:int;
public function PauseMC(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
_time = 300;
}
public function set time(_arg1:int):void{
var _local2:*;
var _local3:*;
_time = _arg1;
_local2 = Math.floor((_time / 60));
_local3 = (_time - (_local2 * 60));
pauseText.text = (((("" + _local2) + "min ") + _local3) + "sec");
}
public function get time():int{
return (_time);
}
}
}//package
Section 13
//RotateSound (RotateSound)
package {
import flash.media.*;
public dynamic class RotateSound extends Sound {
}
}//package
Section 14
//ScoreMC (ScoreMC)
package {
import flash.display.*;
import flash.text.*;
public dynamic class ScoreMC extends MovieClip {
public var _lines:Number;
public var hiscoreText:TextField;
public var timeText:TextField;
public var _time:Number;
public var _score:Number;
public var linesText:TextField;
public var scoreText:TextField;
public var _hiscore:Number;
public function ScoreMC(){
addFrameScript(0, frame1);
}
public function set Score(_arg1:Number):void{
_score = _arg1;
if (HiScore < _score){
HiScore = _score;
};
scoreText.text = ("" + _score);
}
function frame1(){
stop();
_score = 0;
_hiscore = 0;
_lines = 0;
_time = 0;
}
public function get Score():Number{
return (_score);
}
public function set Lines(_arg1:Number):void{
_lines = _arg1;
linesText.text = ("" + _lines);
}
public function set Time(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_time = _arg1;
if (_time == 0){
timeText.text = "";
} else {
_local2 = Math.floor((_time / 1000));
_local3 = Math.floor((_local2 / (60 * 60)));
_local2 = (_local2 - (_local3 * (60 * 60)));
_local4 = Math.floor((_local2 / 60));
_local2 = (_local2 - (_local4 * 60));
timeText.text = ((((_local3 + ":") + ((_local4)<10) ? ("0" + _local4) : ("" + _local4)) + ":") + ((_local2)<10) ? ("0" + _local2) : ("" + _local2));
};
}
public function set HiScore(_arg1:Number):void{
_hiscore = _arg1;
hiscoreText.text = ("" + _hiscore);
}
public function get Time():Number{
return (_time);
}
public function get Lines():Number{
return (_lines);
}
public function get HiScore():Number{
return (_hiscore);
}
}
}//package
Section 15
//SoundMC (SoundMC)
package {
import flash.display.*;
public dynamic class SoundMC extends MovieClip {
}
}//package
Section 16
//StartBTN (StartBTN)
package {
import flash.display.*;
public dynamic class StartBTN extends SimpleButton {
}
}//package