Flash Script – Dynamic Time in Flash


type = 'application/x-shockwave-flash'
data = 'http://sitepointstatic.com/flash/time.swf'
width = '400'
height = '400'
bgcolor = 'black'
>

Download the sample files here.

1. Create a new movie with width=200 and height=75.

2. Create a text field, and name it "time".

3. Name the current layer "textfield".

4. Create a new layer above the current layer, and name it "actions".

4. Create two key frames in the actions layer.

5. Insert this action into the first key frame:

today = new Date();  

time = today.getHours() add ":" add today.getMinutes()  
add ":" add today.getSeconds();

6. In the second frame, insert this action:

gotoAndPlay (1); 

7. You're finished! Press ctrl+enter to test the movie.

Win an Annual Membership to Learnable,

SitePoint's Learning Platform

No Reader comments

Comments on this post are closed.