Flash Player 10 is out and although it’s around 75% penetration wise, which is amazing considering the amount of time it’s out, there are many cases where we would like to check the version of the FP and deploy different applications based on the results. For instance, you may create an application using FP 10 using Catalyst but you still support FP 9 users. Or you can create the main application as FP 9 and create two modules based on the FP player or sub version.
The idea is loading an application with lower FP, for instance FP 9 and than detect the FP version and load the correct application based on the version. Here are a simple utility class and VO to detect the FP version and sub version.
package utils
{
import vo.FlashPlayerVersionVO;
import flash.system.Capabilities;
public class DetectHelper
{
public static function detectFlashPlayerVersion():FlashPlayerVersionVO
{
var flashPlayerVersion:FlashPlayerVersionVO;
var playerVersion:String = Capabilities.version;
var pattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/;
var result:Object = pattern.exec(playerVersion);
var input:String = "";
var platform:String = "";
var majorVersion:Number = 0;
var minorVersion:Number = 0;
var buildNumber:Number = 0;
var internalBuildNumber:Number = 0;
if (result != null)
{
input = String(result.input);
platform = String(result[1]);
majorVersion = Number(result[2]);
minorVersion = Number(result[3]);
buildNumber = Number(result[4]);
internalBuildNumber = Number(result[5]);
}
else
{
trace("could'nt match RegExp, detect flash version didn't work, using default values");
}
flashPlayerVersion = new FlashPlayerVersionVO(input, platform, majorVersion, buildNumber, internalBuildNumber);
return flashPlayerVersion;
}
}
}
package vo
{
public class FlashPlayerVersionVO
{
public function FlashPlayerVersionVO(input:String = "", platform:String = "", majorVersion:Number = 0, buildNumber:Number = 0, internalBuildNumber:Number = 0)
{
this.input = input;
this.platform = platform;
this.majorVersion = majorVersion;
this.buildNumber = buildNumber;
this.internalBuildNumber = internalBuildNumber;
}
public var input:String;
public var platform:String;
public var majorVersion:Number;
public var buildNumber:Number;
public var internalBuildNumber:Number;
}
}






















So do you know how to detect a client side pc whether installed the AIR or Not by using actionscript3?
Check the Browser API which does the heavy lifting of checking if Adobe AIR runtime is installed or not. The way it works is that after http://airdownload.adobe.com/air/browserapi/air.swf gets loaded, you can check whether the Adobe AIR runtime got installed or not.
Thanks so much for posting the class. I was familiar with the Capabilities class, but hadn’t built the regex needed to compare major and minor versions. Great stuff.
David