Use the Flash. system. capabilities. Language Method to Determine the language on the computer where the language is used. Method returns the language of a two-letter ISO-639-1.Code(For example, "FR" is French ). In some cases, some country code will be added to some ancillary items (for example, "ZH-CN" stands for simplified Chinese and "ZH-tw" stands for traditional Chinese ).
Because more handheld devices support Flash Player. For example, a mobile phone-sized screen is different from a typical desktop computer display, so you should load different playback content according to different types of devices.
Package
{
Import flash. display. Sprite;
Import flash. system. capabilities;
Public class testsolution extends Sprite
{
PublicFunction Testsolution ()
{
Super ();
VaR Resx: Int = Flash. system. capabilities. screenresolutionx;
VaR Resy: Int = Flash. system. capabilities. screenresolutiony;
// If the resolution is 240x320 or less, then load the pocketpc
// Movie version. Otherwise, assume the device is a desktop computer
// And load the regular content.
If (Resx <= 240 ) && (Resy <= 320 )){
Trace ( " It is a Pocket PC " );
// VaR URL: String = "main_pocketpc.swf ";
}
Else {
Trace ( " It is a PC " );
// VaR URL: String = "main_shorttop.swf ";
}
// Loader. Load (New URLRequest (URL ));
}
}
}
Package
{
Import flash. display. Sprite;
Import flash. system. capabilities;
Public class extends agetest extends Sprite
{
Public Function Languagetest ()
{
Super ();
// Create an associative array with language codes for the keys
// And greetings for the values.
VaR Greetings: Array = New Array ();
Greetings [ " En " ] = " Hello " ;
Greetings [ " Es " ] = " Hola " ;
Greetings [ " FR " ] = " Bonjour " ;
//Extract the first two characters from the language code.
VaRLang: String=Flash. system. capabilities. Language. substr (0,2);
// Use a default language if the language is not in the list
If (Greetings [Lang] = Undefined ){
Lang = " En " ;
}
// Display the greeting in the appropriate language.
Trace (Greetings [Lang]);
}
}
}