Return to Snippet

Revision: 27191
at December 16, 2010 21:13 by adrianparr


Updated Code
import flash.system.Capabilities;

var flashPlayerMajorVersion:int;

trace("Getting Flash Player version ...");
var versionString:String = Capabilities.version;
var pattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/;
var result:Object = pattern.exec(versionString);
if (result != null) {
	trace("input: " + result.input);
	trace("platform: " + result[1]);
	flashPlayerMajorVersion = int(result[2]);
	trace("flashPlayerMajorVersion: " + flashPlayerMajorVersion);
	trace("minorVersion: " + result[3]);    
	trace("buildNumber: " + result[4]);
	trace("internalBuildNumber: " + result[5]);
} else {
	trace("Unable to match RegExp.");
}

// Example output ...
//
// Getting Flash Player version ...
// input: WIN 10,1,52,14
// platform: WIN
// flashPlayerMajorVersion: 10
// minorVersion: 1
// buildNumber: 52
// internalBuildNumber: 14

Revision: 27190
at May 27, 2010 07:53 by adrianparr


Initial Code
import flash.system.Capabilities;

var flashPlayerMajorVersion:int;

trace("Getting Flash Player version ...");
var versionString:String = Capabilities.version;
var pattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/;
var result:Object = pattern.exec(versionString);
if (result != null) {
	trace("input: " + result.input);
	trace("platform: " + result[1]);
	flashPlayerMajorVersion = int(result[2]);
	trace("flashPlayerMajorVersion: " + flashPlayerMajorVersion);
	trace("minorVersion: " + result[3]);    
	trace("buildNumber: " + result[4]);
	trace("internalBuildNumber: " + result[5]);
} else {
	trace("Unable to match RegExp.");
}

Initial URL

                                

Initial Description
This code separates out the Flash Player Platform, Major Version number and Minor Version numbers.

Initial Title
AS3 Get Flash Player Version Number (inc. Major and Minor Numbers)

Initial Tags
regex, flash, regexp

Initial Language
ActionScript 3