Using timer and for do loop?

I am using some code for a memory type card game where you must click on two of 16 tiles and try and match the colours. I would like to incorporate some code to create a timer where once the timer has got to 40 seconds all the tiles on the screen will be removed and another swf will be loaded in saying Sorry you did not complete the game.

If you do manage to match all the colours before the 40 second timer is up then I want another swf to be loaded in saying Congratulations you completed the game.

Here is the code for the game which is in a document class. The Flash file has 9 frames 8 of which have coloured tiles in and one which shows the back of the card.

package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
//import flash.display.*;
import flash.display.MovieClip;
import flash.display.Stage;

public class color_match extends Sprite {
private var first_tile:colors;
private var second_tile:colors;
private var pause_timer:Timer;
var colordeck:Array = new Array(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8);

public function color_match() {
for (x=1; x<=4; x++) {
for (y=1; y<=4; y++) {
var random_card = Math.floor(Math.random()*colordeck.length);
var tile:colors = new colors();
tile.col = colordeck[random_card];
colordeck.splice(random_card,1);
tile.gotoAndStop(9);
tile.x = (x-1)*82;
tile.y = (y-1)*70;
tile.addEventListener(MouseEvent.CLICK,tile_clicked);
addChild(tile);
}
}
}
public function tile_clicked(event:MouseEvent) {
var clicked:colors = (event.currentTarget as colors);
if (first_tile == null) {
first_tile = clicked;
first_tile.gotoAndStop(clicked.col);
}
else if (second_tile == null && first_tile != clicked) {
second_tile = clicked;
second_tile.gotoAndStop(clicked.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(event: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(event:TimerEvent) {
removeChild(first_tile);
removeChild(second_tile);
first_tile = null;
second_tile = null;
pause_timer.removeEventListener(TimerEvent.TIMER_COMPLETE,remove_tiles);
}
}
}

Here is the code for the timer I was thinking about using.

var flashTimer:Timer = new Timer(1000, 40);
flashTimer.addEventListener(TimerEvent.TIMER, onTime);
flashTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
flashTimer.start();
function onTime(evt:TimerEvent):void
{
}
function onTimerComplete(event:TimerEvent):void
{
//when 40 secs up load swf
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest(“sorry.swf”));
addChild(myLoader);
}

For the Congratulations screen I was thinking about incorporating a for do loop in the remove_tiles function counting the amoint of times its called and if it equals 8 times then load Congratulations swf.

Has anybody got any idea how I can incorporate all of this code?
Id appreciate the helpon this!
Thanks