13 December 2008

Create date on flash stage very quickly using a little AS

This lesson will show you how to display date on flash stage very quickly. To make this lesson, you have to use a little action script code. You can use this lesson for any web site, when you need to show the date.

Step 1

Start flash.

Step 2

Take now the Text Tool (T) and go to the Properties Panel (Ctrl+F3). On the left, you will see Text Type drop down menu. Select Dynamic Text on it. See the picture below!



Then, draw rectangle shape on the stage like it is shown on the picture below!



Step 3

Go again to the Properties Panel (Ctrl+F3) below the stage. Then, for Var type: date



Step 4

While the dynamic text box (rectangle shape) is still selected, press F8 key (Convert to Symbol) to convert this dynamic text box into a Movie Clip Symbol.

Step 5

Take now the Selection Tool (V) and click once on the new made Movie Clip Symbol. Then, go to the Action Script Panel (F9) and enter this code inside the actions panel:

onClipEvent (load){

weekdays = ["Sunday","Monday","Tuesday",

"Wednesday","Thursday","Friday","Saturday"];

months = ["January","February","March","April","May","June"," July",

"August", "September", "October"," November","December"];

}

onClipEvent (enterFrame){

myDate = new Date();
tDay = weekdays[myDate.getDay()];
tMonth = months[myDate.getMonth()];
tDate = myDate.getDate();
tYear = myDate.getFullYear();
date = tDay+", "+ tMonth+" "+tDate+", "+tYear;

}

Now, we're done!

Test your Movie and enjoy!

Download source file (.fla)

No comments:

Post a Comment

Apply to be a Chitika Publisher!
Follow on Buzz