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

Basic Timer Class Clock Animation with ActionScript

This Flash ActionScript animation tutorial series show how to do animation with Timer Class. Animation with Timer Class is very easy and simple without much coding. The first tutorial use Timer Class to animate a clock. This is a very basic counting digital clock but it shows how Timer Class works.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Animation with Timer Class with ActionScript 3 is simple and easy without writting much coding. The Timer Class is simply to control when and how often a specify function will be called .

The complete Flash Movie of this tutorial is shown as above. The timer clock will be start counting when the Flash movie is opened.

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
//Summary:
//Create a Timer instance that will trigger every 0.1 seconds infinitely
var myClock:Timer = new Timer(100, 0);

 

//Timer object created will not start automatically
//You have to start it
myClock.start();

 

//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);

Download Flash Source File:

Flash Source File timer-1.fla

Remarks:

In this Flash ActionScript tutorial, the clock started counting at once when the Flash movie was opened. In some situation, you may want the animation to start a bit later (for example, 2 seconds, 5 seconds or longer) when the Flash movie is opened. The next Flash Timer Class animation tutorial will show you how to do that.