Original tutorial, reproduced please indicate the source: Web Teaching Network The effect is as follows: Production steps: 1. First create a new MC component, and then edit the component by setting up two dynamic text boxes and setting the instance name: Time and date respectively for two text boxes. The variables used in two text boxes are: Time and datefinal. 2. Insert a frame at frame 2nd. (Press F5) 3. Select the first keyframe, and then open the Action panel. We first set up several code to get the system clock and save them with variables. The code is as follows: MyDate = new Date (); seconds = Mydate.getseconds (); minutes = Mydate.getminutes (); Hours = Mydate.gethours (); Day = Mydate.getday (); Date = Mydate.getdate (); month = Mydate.getmonth (); Year = Mydate.getfullyear (); 4. If today is Sunday, then the value of the "Day" variable is "0" and if it is Monday the return value is 1, .... If it is January, then month is 0, February is 1, .... There's still time, when the moment is 7:03:05 it will be shown as 9:3:5 so we are here to limit the value of the above variable. First change the way day is displayed: if (day==0) { Day = "Sunday" else if (day==1) { Day = "Monday" else if (day==2) { Day = "Tuesday" else if (day==3) { Day = "Wednesday" else if (day==4) { Day = "Thursday" else if (day==5) { Day = "Friday" else if (day==6) { Day = "Saturday" } Then change how the month is displayed: if (month==0) { month = "January" else if (month==1) { month = "February" else if (month==2) { month = "March" else if (month==3) { month = "April" else if (month==4) { month = "May" else if (month==5) { month = "June" else if (month==6) { month = "July" else if (month==7) { month = "August" else if (month==8) { month = "September" else if (month==9) { month = "October" else if (month==10) { month = "November" else if (month==11) { month = "December" } Here if we just want to display the month in digital form we do not need to use the above code, then directly to the month variable plus 1 on it! Month = month + 1; In order for the minute and second to display correctly we use the following code to give the variants: if (minutes<10) { minutes = "0" +minutes; } if (seconds<10) { seconds = "0" +seconds; } Here we are using 0 characters and a number added to the value, such as "5" + "3" =53 instead of 8. This is the place to pay attention to. 5. Notes on the 12-hour and 24-hour display time: If we want to display the time in 12 hours, we use the following code: if (hours>12) { Hours = hours-12; AMPM = "PM"; } else { AMPM = "AM"; } if (hours = = 0) { Hours = 12; } Then add the 12-hour display code: Time = ((Hours) + ":" + (minutes) + ":" + (seconds) + "" + (AMPM)); If you want to display the time in 24 hours, use the following code directly: Time = ((Hours) + ":" + (minutes) + ":" + (seconds)); 6. The date of the display, which provides two ways: Datefinal = (Day) + "" + (date) + "" + (Month) + "" + (year)); Or in the form of "/" Datefinal = ((date) + "/" + (Month) + "/" + (year)); Finally, drag the movie to the scene to press Ctrl+enter to see the effect, through this example, we hope that the action has a basis for understanding. I hope you get the benefit from it. source file download (. fla) |