13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Internationalizing applications<br />

var date:Date = new Date(2009, 2, 27, 13, 1);<br />

var dtf:DateTimeFormatter = new DateTimeFormatter("<strong>en</strong>-US",<br />

DateTimeStyle.LONG, DateTimeStyle.LONG);<br />

var longDate:String = dtf.format(date);<br />

trace(longDate); // March 27, 2009 1:01:00 PM<br />

dtf.setDateTimeStyles(DateTimeStyle.SHORT, DateTimeStyle.SHORT);<br />

var shortDate:String = dtf.format(date);<br />

trace(shortDate); // 3/27/09 1:01 PM<br />

Localizing month names and day names<br />

Many applications use lists of month names and the names of the days of the week in cal<strong>en</strong>dar displays or pull-down<br />

lists.<br />

You can retrieve a localized list of the month names using the method DateTimeFormatter.getMonthNames().<br />

Dep<strong>en</strong>ding on the operating system, full and abbreviated forms might be available. Pass the value<br />

DateTimeNameStyle.FULL to get full l<strong>en</strong>gth month names. Pass the values<br />

DateTimeNameStyle.LONG_ABBREVIATION or DateTimeNameStyle.SHORT_ABBREVIATION to get shorter<br />

versions.<br />

In some languages, a month name changes (into its g<strong>en</strong>itive form) wh<strong>en</strong> it is placed next to the day value in a date<br />

format. If you plan to use the month names alone, pass the value DateTimeNameContext.STANDALONE to the<br />

getMonthNames() method. To use the month names in formatted dates, however, pass the value<br />

DateTimeNameContext.FORMAT.<br />

var dtf:DateTimeFormatter = new DateTimeFormatter("fr-FR");<br />

var months:Vector. = dtf.getMonthNames(DateTimeNameStyle.FULL,<br />

DateTimeNameContext.STANDALONE);<br />

trace(months[0]); // janvier<br />

months = dtf.getMonthNames(DateTimeNameStyle.SHORT_ABBREVIATION,<br />

DateTimeNameContext.STANDALONE);<br />

trace(months[0]); // janv.<br />

The DateTimeFormatter.getWeekdayNames() method provides a localized list of the names of the days of the week.<br />

The getWeekdayNames() method accepts the same nameStyle and context parameters that the getMonthNames()<br />

method does.<br />

var dtf:DateTimeFormatter = new DateTimeFormatter("fr-FR");<br />

var weekdays:Vector. = dtf.getWeekdayNames(DateTimeNameStyle.FULL,<br />

DateTimeNameContext.STANDALONE);<br />

trace(weekdays[0]); // dimanche<br />

weekdays = dtf.getWeekdayNames(DateTimeNameStyle.LONG_ABBREVIATION,<br />

DateTimeNameContext.STANDALONE);<br />

trace(weekdays[0]); // dim.<br />

In addition, the getFirstWeekday() method returns the index value of the day that traditionally marks the beginning<br />

of the week in the selected locale.<br />

Last updated 6/6/2012<br />

948

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!