Search tutorials
The Script
Flash 5 allows you to link scripts to Movie Clip events. In this example you will use the event enterFrame to do the trick.
To type in the script for the Movie Clip, right click it on the stage and choose Actions to open the Object Actions dialogue box. Change the clip event to EnterFrame.
Below is the complete script for this clock.
onClipEvent (enterFrame) {
// Gets the time information and stores in MyDate
MyDate = new Date();
// Assigns values individually
hour = MyDate.getHours();
minute = MyDate.getMinutes();
second = MyDate.getSeconds();
// Calculates position for hours hand
if (hour > 11) {
hour = hour-12;
}
hour = hour*5;
movement = minute/12;
hour = int(hour+movement);
// Moves hours hand
with (_root.Clock.Hours) {
gotoAndStop(hour) + 1;
}
// Moves minutes hand
with (_root.Clock.Minutes) {
gotoAndStop(minute) + 1;
}
// Moves seconds hand
with (_root.Clock.Seconds) {
gotoAndStop(second) + 1;
}
}
| » Level Intermediate |
|
Added: 2000-11-22 Rating: 8.02 Votes: 115 |
| » Author |
| Marcos J Pinto is a free lance developer and a computer books author in Brazil. His most recent book is a begginers introduction to using Flash 5 (in Portuguese). |
| » Download |
| Download the files used in this tutorial. |
| Download (27 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!