PDA

View Full Version : help creating a game timer


bhupi_99000
06-20-2008, 10:43 AM
Hi,

I want to create a timer for my game.

I want to create levels in my game for 1 minute time for each level.

but i'm not able to create the same, in the code below, I want the time should return after "onEnterFrame" finish.. but it returns value before deletion of "onEnterFrame" and executes "onEnterFrame" till deletion.

I'm using this code: -

function curTime()
{
var myTime:Number;

myTime = getTimer();
return myTime;
}

function createTimer ()
{

time = curTime();
oldTime = time;

MovieClip.prototype.onEnterFrame = function ()
{
time = curTime();
trace("current time = "+time);
if ((time-oldTime)>600)
{
trace("working in if = "+time);
time = time-oldTime;
delete MovieClip.prototype.onEnterFrame;
}
};
return time;
}