Detailed November 11, 2005, will be on August 8, 2008 8 o'clock in the evening in Beijing at the opening of the 29th Olympic Games in the preparation process ushered in the countdown 1000 days of important historical moment, BOCOG and the community held the Olympic Games mascot release and Countdown 1000 days activities, to meet this special day. This reminds us that the opening of the 2008 Beijing Olympic Games is moving towards us at a brisk pace. In order to remember this moment, deliberately use flash to achieve the countdown to the Beijing Olympics. The specific steps are as follows:
1. Start Flash, create a new component, named "Countdown", select "Movie clips" in the behavior, and then enter the component editing window.
2. Click on the Text tool, select "Static text" in the attribute, underline a text box, set the parameters of the text box, and enter the contents "now away from the 2008 Beijing Olympic Games opening and".
3. Click on the Text tool, select "Dynamic text" in the attribute, underline a text box, set the parameters of the text box, and set the variable to "Daojishitext".
4. The named layer is "Countdown", and the following code is entered on the first frame of the timeline:
Endtime=new Date (2008,7,8,20,0,0); Define countdown end time, here is the 2008 Beijing Olympic opening Day Note that the month parameter is expressed in 0-11 January-December Nowtime=new Date (); Define Current time Zong=math.floor ((Endtime.gettime ()-nowtime.gettime ())/1000); Gets the total number of seconds that the current time differs from the end time if (zong>0) { Tian=math.floor (zong/(60*60*24)); Get the remaining days zong=zong-tian*60*60*24; Shi=math.floor (zong/(60*60)); Get the remaining hours zong=zong-shi*60*60; Fen=math.floor (ZONG/60); Get the number of minutes left zong=zong-fen*60; Miao=zong; Get the number of seconds left Daojishitext=string (Tian) + "Days" +string (shi) + "Time" +string (fen) + "min" +string (Miao) + "seconds"; } |
5. Insert the key frame at the 12th frame of the timeline, enter the statement "gotoAndPlay (1);".
6. Return to the main scene, drag the countdown movie clip to the main scene, test run, the effect as shown in the picture.
|
Figure 1 Playback Effect Chart |
Description: The above code with the opening of the Beijing 2008 Olympic Games Countdown end time, first calculated the current time and end time between the total number of seconds, and then converted to the corresponding number of days, hours, minutes and seconds. Because the flash default frame rate is 12, the code uses the "gotoAndPlay (1)" in the 12th frame. statement, which is used to schedule the countdown code to run every second, so that the countdown information displayed is refreshed every second.