2010-04-06 61 views
0
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播放器版本自動更新3

您的Flash播放器版本比當前版本舊的9,請更新。

如何使用Actionscript自動更新Flash Player?

回答

1

你不能那樣做。這也會非常令人討厭。多個網站會開始更新我的Flash播放器,但我只是想堅持使用我所擁有的播放器(無論出於何種原因)。

另外,請注意,代碼是AS3,而AS3不能編譯爲在版本9以下的Flash播放器上運行。因此,您的腳本要麼運行,要麼檢測播放器版本是否足夠,要麼根本不會運行。

adobe和其他人提供帶有集成的javascript版本檢查的Flash嵌入的HTML模板,如果您的版本不夠新,它將爲您提供手動升級Flash播放器的按鈕。

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