如何通过actionscript 3自动更新Flash播放器版本

时间:2010-04-06 07:22:15

标签: actionscript flash

package {
    import flash.system.Capabilities;
    import flash.display.MovieClip;

    public class VersionCheck extends MovieClip{
        public function VersionCheck():void {
            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.");
            }
        }
    }
}

如果跟踪声明说:

  

您的Flash Player版本早于当前版本9,请更新。

如何使用Actionscript开始自动更新Flash Player?

2 个答案:

答案 0 :(得分:1)

你不能那样做。这也是非常烦人的。大量的网站会开始更新我的Flash播放器,虽然我只想坚持我拥有的(无论出于何种原因)。

另外,请注意代码是AS3,并且AS3无法编译为在版本9以下的Flash播放器上运行。因此您的脚本要么运行,要么检测到播放器版本已足够,或者根本不运行。

adobe和其他人提供了带有集成javascript版本检查的flash嵌入式HTML模板,如果您的版本不够新,它将为您提供手动升级Flash播放器的按钮。

答案 1 :(得分:0)

    import flash.system.Capabilities;

// Get the player’s version by using the flash.system.Capabilities class.
var versionNumber:String = Capabilities.version;
trace("versionNumber: "+versionNumber);

// The version number is a list of items divided by ",”
var versionArray:Array = versionNumber.split(",");
var length:Number = versionArray.length;

// 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(" ");

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);

if (majorVersion<12) {
    trace("Your Flash Player version is older than the current version 9, please update.");
    //statusText is a label positioning at the left bottom corner of Stage
    statusText.htmlText = "<b>Your Flash Player version is older than the current version 12</b><a href='get.adobe.com/flashplayer/'>please update";
} else {
    statusText.text = "You are using Flash Player 12 or later.";
}