Section 1
//color_match (color_match)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class color_match extends Sprite {
private var first_tile:colors;
private var second_tile:colors;
private var pause_timer:Timer;
var colordeck:Array;
public function color_match(){
var _local1:*;
var _local2:colors;
colordeck = new Array(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8);
super();
x = 1;
while (x <= 4) {
y = 1;
while (y <= 4) {
_local1 = Math.floor((Math.random() * colordeck.length));
_local2 = new colors();
_local2.col = colordeck[_local1];
colordeck.splice(_local1, 1);
_local2.gotoAndStop(9);
_local2.x = ((x - 1) * 82);
_local2.y = ((y - 1) * 82);
_local2.addEventListener(MouseEvent.CLICK, tile_clicked);
addChild(_local2);
y++;
};
x++;
};
}
public function tile_clicked(_arg1:MouseEvent){
var _local2:colors = (_arg1.currentTarget as colors);
if (first_tile == null){
first_tile = _local2;
first_tile.gotoAndStop(_local2.col);
} else {
if ((((second_tile == null)) && (!((first_tile == _local2))))){
second_tile = _local2;
second_tile.gotoAndStop(_local2.col);
if (first_tile.col == second_tile.col){
pause_timer = new Timer(1000, 1);
pause_timer.addEventListener(TimerEvent.TIMER_COMPLETE, remove_tiles);
pause_timer.start();
} else {
pause_timer = new Timer(1000, 1);
pause_timer.addEventListener(TimerEvent.TIMER_COMPLETE, reset_tiles);
pause_timer.start();
};
};
};
}
public function reset_tiles(_arg1:TimerEvent){
first_tile.gotoAndStop(9);
second_tile.gotoAndStop(9);
first_tile = null;
second_tile = null;
pause_timer.removeEventListener(TimerEvent.TIMER_COMPLETE, reset_tiles);
}
public function remove_tiles(_arg1:TimerEvent){
removeChild(first_tile);
removeChild(second_tile);
first_tile = null;
second_tile = null;
pause_timer.removeEventListener(TimerEvent.TIMER_COMPLETE, remove_tiles);
}
}
}//package
Section 2
//colors (colors)
package {
import flash.display.*;
public dynamic class colors extends MovieClip {
}
}//package