Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Flash ActionScript Timer Class Clock with Start and Stop Buttons

This Flash ActionScript Timer Class tutorial demonstrate how to use a Play button to start the timer clock and a Stop button to stop the timer clock.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

In this Flash Timer Class tutorial, we provide a Play button to start the timer clock and a Stop button to stop the timer clock.

The complete Flash Movie of this tutorial is shown as above. Click on the Flash movie to activate it and play around to see how it works. The timer clock will start counting when the Play button is clicked and stop when the Stop button is clicked.

Flash ActionScript Codes:

//Create a Timer object and store it in a variable called myClock.
//The timer will trigger every 100 milliseconds (0.1 seconds)
//1000 milliseconds = 1 second
//The repeatCount is zero, i.e. timer will trigger infinitely
//Create a Timer instance that will trigger every 0.1 seconds infinitely
var myClock:Timer = new Timer(100, 0);


//Start the time at zero
var time:Number =0;


function countingClock(evt:TimerEvent):void {

//Increase the time by 0.1
time += .1;
//Only need one decimal place of myClock
time = (Math.round(time*10)) / 10;
//Show the time
clock_txt.text = String(time);



//Add an event listener to the timer object (myClock)
//The event that listen is called TIMER which will be trigger every 0.1 seconds
//Every time the TIMER event is triggered, it will call the countingClock function
myClock.addEventListener(TimerEvent.TIMER, countingClock);


function startClock(evt:MouseEvent):void {

//Timer object created will not start automatically
//Start myClock when startClock function is called



play_btn.addEventListener(MouseEvent.CLICK, startClock);


function stopClock(evt:MouseEvent):void {

//Stop the clock



stop_btn.addEventListener(MouseEvent.CLICK, stopClock);

Download Flash Source File:

Flash Source File timer-3.fla


Up to now, the delay of the Timers are set before we used them. Actually the delay of Timer can be adjusted (faster or slower) during the runtime. In the next Flash Timer Class animation tutorial, we will use two buttons to control the delay of a Timer.