Making a simple digital clock in Flash


In this Macromedia Flash tutorial you will see how to make and program a simple digital clock in actionscript.


1.
Start by creating a text on the stage and type in 00:00:00 just for the visual.

Photoshop Tutorial thumb picture


2.
Now in the properties panel make the text dynamic and name it time1 as shown in the image below.

Photoshop Tutorial thumb picture


3.
Right click and convert it to a movie clip.

click the new movie clip and go to the action script panel.

4.
Now we are ready to make the code for our digital clock.

This is acturlly pretty straight forward, eventhough it seems confusing.

onClipEvent (enterFrame) {
data = new Date();

time1.text = data.getHours() + ":" + data.getMinutes() + ":" + data.getSeconds();
}

I will break the code up into pieces.

onClipEvent (enterFrame) {
code in here.
}

this is the container of the code, this will update the code so we get the current time updated.

data = new Date();

here we declare an object to be of the type date

time1.text = data.getHours() + ":" + data.getMinutes() + ":" + data.getSeconds();

time1 is our text from before, and we set its text to be first hour then a : then minut then : seconds

And we are done.

Now as we converted our timer to a movie clip we can easily apply a small animation to it.

5.
So I went to the filters panel and gave it a blur filter and animated it in the timeline.

0tutor.com rss feed