使用flash.system.Capabilities.language方法来确定所使用的语言的计算机上的语言情况。方法返回两个字母的ISO-639-1的语言代码(例如,“fr”是法语)。在有些情况下一些国家代码会加入一些了附属,(例如,“zh-cn”的代表简体中文和“zh-tw”的代表繁体中文)。
因为更多的手持设备支持的Flash Player 。例如,手机尺寸的屏幕和一个典型的台式电脑显示器是不同的,所以你应该根据设备的种类不同加载不同的播放内容。
package
{
import flash.display.Sprite;
import flash.system.Capabilities;
public class TestSolution extends Sprite
{
public function TestSolution()
{
super();
var resX:int = flash.system.Capabilities.screenResolutionX;
var resY:int = flash.system.Capabilities.screenResolutionY;
// If the resolution is 240 x 320 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_desktop.swf";
}
//loader.load(new URLRequest(url));
}
}
}
{
import flash.display.Sprite;
import flash.system.Capabilities;
public class TestSolution extends Sprite
{
public function TestSolution()
{
super();
var resX:int = flash.system.Capabilities.screenResolutionX;
var resY:int = flash.system.Capabilities.screenResolutionY;
// If the resolution is 240 x 320 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_desktop.swf";
}
//loader.load(new URLRequest(url));
}
}
}
package
{
import flash.display.Sprite;
import flash.system.Capabilities;
public class LanguageTest 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.
var lang: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]);
}
}
}
{
import flash.display.Sprite;
import flash.system.Capabilities;
public class LanguageTest 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.
var lang: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]);
}
}
}