topical media & game development
professional-flex-code-17-CreatingDates1.mx
professional-flex-code-17-CreatingDates1.mx
(swf
)
[ flash
]
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="getDates();">
<mx:Script>
<![CDATA[
private function getDates():void
{
var dates:Array = new Array();
dates.push( new Date() );
var millSecs:Number = 12 * 365 * 24 * 60 * 60 * 1002;
dates.push( new Date( millSecs ) );
dates.push( new Date( 1982, 0, 6, 10, 14, 24 ) );
dates.push( new Date( "Wed Jan 6 10:14:24 GMT-0800 1982" ) );
dates.push( new Date( "Jan 6 1982 10:14:24" ) );
dates.push( new Date( "1982/01/06 10:14:24" ) );
txtDates.text += " # ToString() #";
for( var a:String in dates )
txtDates.text += "\n" + dates[ a ].toString();
txtDates.text += "\n\n # ToDateString() #";
for( var b:String in dates )
txtDates.text += "\n" + dates[ b ].toDateString();
txtDates.text += "\n\n # ToLocaleString()";
for( var c:String in dates )
txtDates.text += "\n" + dates[ c ].toLocaleString();
txtDates.text += "\n\n # ToUTCString() #";
for( var d:String in dates )
txtDates.text += "\n" + dates[ d ].toUTCString();
var df:DateFormatter = new DateFormatter();
df.formatString = "year: YYYY / month: MM / day: DD";
txtDates.text += "\n\n # Custom Output #";
for( var e:String in dates )
txtDates.text += "\n" + df.format( dates[ e ] );
}
]]>
</mx:Script>
<mx:TextArea
width="80%" height="80%"
id="txtDates">
</mx:TextArea>
</mx:Application>
(C) A. Eliëns
2/9/2007
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.