简体   繁体   中英

How to do the auto update of Flash player version through actionscript 3

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.");
            }
        }
    }
}

If trace statement says:

Your Flash Player version is older than the current version 9, please update.

How to start auto update of Flash Player using Actionscript?

you can't do that. It'd be really annoyoing as well. Tons of sites would start updating my flash player, although I just want to stick with the one I have (for whatever reason).

also, please note that the code is AS3, and AS3 cannot be compiled to run on flash player below version 9. thus your script is either run detecting the player version is sufficient, or won't run at all.

adobe and others provide HTML templates for flash embeds with integrated javascript version check, that will present you with a button to manually upgrade flash player, if your version is not new enough.

    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.";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM