Date.getTime( ) Method | Flash 5 |
retrieve the number of milliseconds between January 1, 1970 and the time of a Date object |
An integer expressing the number of milliseconds between the time of date and midnight, January 1, 1970 � positive if after January 1, 1970; negative if before.
Internally, all dates are represented as a single number�the number of milliseconds between the time of the date and midnight, January 1, 1970. The getTime( ) method gives us access to that number of milliseconds so that we can use it to construct other dates or calculate the elapsed time between two dates.
Suppose we place the following code on frame 10 of a movie:
time1 = new Date();
Then we place the following code on frame 20 of a movie:
time2 = new Date();
With the following code, we can determine the amount of time that elapsed, in milliseconds, between frames 10 and 20 of our movie:
elapsedTime = time2.getTime() - time1.getTime();
Note that Flash's global getTimer( ) function also gives us access to elapsed time in a movie.
Date.setTime( ), getTimer( ), setInterval( )