Flash Tutorials, Samples, Resources, Greetings, Games
Home | About Us | Resources | Tutorials | Links | Games | Movies | Projects | Feedback | Contact Us
Tutorials
Here you'll get tutorials for all skill levels wheather you are a new user or an expert flash developer.

» Enter
Resources
In this section you'll get some small movie clips which can be used in your flash projects with flash components, flash action scripts .as files and some other stuff that will help you in your flash projects. You can also submit your work here. For submit details please checkout our Submit Page.

» Enter
Games
Play and download great flash games. If you have any flash game, please send us, we will put it with your name.

» Enter
Movies
Flash FLA movies to download.

» Enter
Home » Tutorials



   Basic Level - Displaying Day and Date
Open a new file and give it a name date.fla.
Here we will display day and date in the format [Day, date], for ex:- Sunday, 1 Jan. 2004.
So first of all select first frame, open script window (F9), and write following code.

mydate = new Date();
day = mydate.getDay();
dt = myDate.getDate();
month = mydate.getMonth();
yr = mydate.getFullYear();
trace(day + " , " + dt + " " + month + " " + yr);

When you test this movie, you will get some unexpected result. This is because Flash action script returns day of the week (0 for Sunday, 1 for Monday, and so on) and Month (0 for January, 1 for February, and so on) in Numeric format. To display date in Understandable format we have to write some more code for validation. This can be done by a simple if condition. So once again open script window and add following code:-

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" ;
                        }

Now you will see that the Day of the week is being displayed in text format and not in numeric format. Same validation need to be applied for month.
And now to show the date on stage, add a dynamic text box with variable name "dtformat" and set the formatted date in this variable, and you have done it.


Download Final Fla file