如何从Action Script 3.0中了解Flash Player版本

时间:2008-09-23 14:41:31

标签: flash actionscript-3

有一种方法可以了解使用Action Script 3.0运行我们的SWF文件的计算机上安装的Flash播放器版本吗?

3 个答案:

答案 0 :(得分:8)

如果您是在IDE中进行编程,则以下内容将为您提供版本

trace(Capabilities.version);

如果您要构建自定义类,则以下内容应该有所帮助。 确保以下代码进入名为VersionCheck.as

的文件中
package
{
    import flash.system.Capabilities;

    public class VersionCheck
    {
        public function VersionCheck():void
        {
            trace(Capabilities.version);
        }
    }
}

希望这会有所帮助,请记住,所有AS3语言都可以在线学习http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/

答案 1 :(得分:4)

答案 2 :(得分:4)

这个例子可能有助于弄清楚你收到的细节,这样你就可以在你得到的有些尴尬的数据中采取行动。

import flash.system.Capabilities;


var versionNumber:String = Capabilities.version;
trace("versionNumber: "+versionNumber);
trace("-----");

// The version number is a list of items divided by ","
var versionArray:Array = versionNumber.split(",");
var length:Number = versionArray.length;
for(var i:Number = 0; i < length; i++) trace("versionArray["+i+"]: "+versionArray[i]);
trace("-----");

// The main version contains the OS type too so we split it in two
// and we'll have the OS type and the major version number separately.
var platformAndVersion:Array = versionArray[0].split(" ");
for(var j:Number = 0; j < 2; j++) trace("platformAndVersion["+j+"]: "+platformAndVersion[j]);
trace("-----");

var majorVersion:Number = parseInt(platformAndVersion[1]);
var minorVersion:Number = parseInt(versionArray[1]);
var buildNumber:Number = parseInt(versionArray[2]);

trace("Platform: "+platformAndVersion[0]);
trace("Major version: "+majorVersion);
trace("Minor version: "+minorVersion);
trace("Build number: "+buildNumber);
trace("-----");

if (majorVersion < 9) trace("Your Flash Player version is older than the current version 9, please update.");
else trace("You are using Flash Player 9 or later.");