zoukankan      html  css  js  c++  java
  • 如何使用ActionScript来检测用户的语言及屏幕分辨率

    使用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));
            }
            
        }
    }

    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]);
            }
            
        }
    }
  • 相关阅读:
    iOS 面试题搜集
    iOS 常用第三方类库、完整APP示例
    iOS 键盘遮挡输入 解决办法
    iOS UIColor RGB HEX
    iOS APP性能优化
    iOS Swift 数组 交换元素的两种方法
    iOS CoreData primitive accessor
    iOS Start developing ios apps (OC) pdf
    iOS 传值方式
    iOS IB_DESIGNABLE IBInspectable @IBDesignable @IBInspectable 加速UI开发
  • 原文地址:https://www.cnblogs.com/sunbingzibo/p/1459860.html
Copyright © 2011-2022 走看看