In this Adobe Flash tutorial we will be making a timer alarm counter.
This will be the final result, a function that counts in seconds and mili seconds, when we hit a specific number, we will start an alarm function.
First we need a bit of preparation on the stage before we get to the coding part.
Find a image of a digital clock, go to file -> import -> import to stage and select the image.
Now Right click and convert it to a movie clip. (this is all just to make it look interesting).
Now make a text field on the stage, place it within the display of our clock, then in the properties panel make it a dynamic text field and give it an instance name, I named mine tStatus.

Next we need to make another text field and place it below.
In the properties panel also make it dynamic and give it an instance name, I named mine message_txt, give it a bigger font and make it red.

Now we are ready to go to the actionscript panel and type in some code.
So open up the actionscript panel and type in the following code, I made some code description between the code lines to make it more understandable (I hope).
// First we make an instance of the timer class and name it timerClock
var timeClock:Timer = new Timer(100);
// then we start it when the flash movie starts
timeClock.start();
// Here we make couple of variables, the first one handles the timer count
var time:Number = 0
// this one we can change to whatever timer we want the alarm to start
// now its set to 5 seconds
var alarmTime:Number = 5;
// Now we add an eventlistener to the timer instance
// so we can tricker a function to add a number to our time variable.
timeClock.addEventListener(TimerEvent.TIMER, updateClock);
// this is the function trickered by the timer
function updateClock(event:TimerEvent):void
{
// Here we have two conditions first one is if the time is more or
// equal to the alarm time, this will make the alarm start
// and the timer stop counting.
if(time >= alarmTime)
{
trace("ALARM!!!");
message_txt.text = "Wake up!!";
timeClock.removeEventListener(TimerEvent.TIMER, updateClock);
}
// the else statement tells flash to add .1 to the counter every time
// this function is trickered.
else
{
time += .1
// this might seem a bit confusing but Math.round rounds down so we dont
// get any .2332 numbers then we * by 10 to make it in seconds
// and divide it all by 10 to get seconds and milliseconds.
time = (Math.round(time*10))/10;
// here we set the timer text field tStatus equal to the time, remember
// to use the String() to convert it to string, or else you will get error
tStatus.text = String(time);
}
}