Usable methods of DateField Class.

There are predefined methods for the Class DateField and they are very usefull when writing ur ActionScript.

For instance u want to know the day of the date you have mentioned in the date, this can be achevied by using the method getDate().For example the date is 28/12/2007 as below def.

private var date1=new Date();
date1=new Date(2007,11,28);

Now u want to know the day of that date variable date1.use the following line of code.

var d1=date1.getDate();

Now the variable d1 contains the day of the date variable date1.

similarly we can use the methods getMonth(),getYear(),getHours()[if u mention it in the date def],getMinutes() [if u mention it in the date def]….like that there are many methods i will come back with them later for instance have the following code.

private var date1=new Date();
private var date2=new Date();
private function init():void
{
date1=new Date(2007,11,28);
date2=new Date(2007,12,10);
}
private function show():void
{
var d1=date1.getDate();
var d2=date2.getDate();
Alert.show(” “+((30-d1)+(d2)),”SUM”);
}//similar for getmonth ,getyear, gethoures……..

<mx:Button label=”Button” click=”show()”/>

Here on click of button it alerts  the number of days in the given date range.

Similar code can be generated for other methods.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: