ActionScript.org Flash, Flex and ActionScript Resources - http://www.actionscript.org/resources
Creating the Time with Flash 5
http://www.actionscript.org/resources/articles/84/1/Creating-the-Time-with-Flash-5/Page1.html
Johan Jansen
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org. 
By Johan Jansen
Published on September 9, 2005
 
Tutorial details:
Written by: Johan Jansen
Difficulty Level: intermediate
Requirements: Flash 5 or higher

Page 1 of 3
Tutorial details:
Written by: Johan Jansen
Difficulty Level: intermediate
Requirements: Flash 5 or higher
download fla Create Object

Well, at first we have to create an object which contains the time and date etc.

It goes like this :
  • Start flash 5.
  • Insert a Keyframe in the first and second frame.
  • Go to the First Keyframe
  • Frame Actions (double click on the keyframe)



    Create Object ... cont.

    At the 'plus' sign:

    Actions Set Variable :

Page 2 of 3
[as]variable = mydate = new Date ();[/as]
value must be expression



Create Counter

  • Insert a new layer with a variable textfield ( dynamic text ) and name it time
  • Goto the first layer
  • Goto frame properties and set a new variable and name it time



  • And as value the code :
    (mydate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds())
    and it must be an expression like this :



    Now I shall explain it :
    mydate.getHours ()
       getHours stands for getting the Hours and
       mydate stands for : from which variable to take the Hours
       (In this case the variable mydate )

    The Minutes and Seconds work the same way.


Page 3 of 3
Updating
Now goto the firstlayer in the second keyframe.
Insert a new action goto and play 1.

This is needed to update the time every second, else the time stops.



Final File