Retrieving Flash Player Information Using the Capabilities Class in ActionScript 3
The flash.system.Capabilities class in ActionScript 3 offers static read-only properties to describe the system and runtime environment of an application, such as Flash Player, Adobe AIR, or Flash Lite. By accessing these properties, developers can determine client-side information and customize content accordingly. This article focuses on obtaining common details when Flash Player is embedded in a browser.
Runtime Type
The Capabilities.playerType property indicates the type of runtime currently in use. Possible values include:
"ActiveX"for Flash Player ActiveX controls in Microsoft Internet Explorer."Desktop"for Adobe AIR runtimes, except SWF content loaded via HTML pages, which sets this to"PlugIn"."External"for external Flash Player instances or testing modes."PlugIn"for Flash Player browser plugins, including SWF content in AIR applications loaded via HTML."StandAlone"for standalone Flash Player.
When Flash Player runs as a browser plugin, Capabilities.playerType returns "PlugIn". For example:
var runtimeType:String = Capabilities.playerType;
trace("Runtime type: " + runtimeType); // Output: Runtime type: PlugIn
Debug Version Status
The Capabilities.isDebugger property specifies whether the runtime is a debug version. It returns true for debug versions and false for release versions. Example:
var debugStatus:Boolean = Capabilities.isDebugger;
trace("Debug version: " + debugStatus); // Output: Debug version: true
Adobe runtimes come in two types: release versions for general users and debug versions for developers to facilitate testing. Users typically install release versions from Adobe's support center.
Operating System Type
The Capabilities.os property provides the name of the current operating system. Common values are:
| Operating System | Value |
|---|---|
| Windows 8 | "Windows 8" |
| Windows 7 | "Windows 7" |
| Windows Server 2003 | "Windows Server 2003" |
| Windows XP 64-bit | "Windows Server XP 64" |
| Windows XP | "Windows XP" |
| Windows Mobile | "Windows Mobile" |
| Mac OS | "Mac OS X.Y.Z" where X.Y.Z is the version, e.g., "Mac OS 10.5.2" |
| Linux | "Linux" with version details like "Linux 2.6.15-1.2054_FC5smp" |
| iPhone OS 4.1 | "iPhone3,1" |
Example usage:
var currentOS:String = Capabilities.os;
trace("Current OS: " + currentOS); // Output: Current OS: Mac OS 10.8.5
System Language
The Capabilities.language property returns the language code of the system where the runtime is executing. Lnaguage codes follow ISO 639-1 standards with lowercase two-letter codes, and for languages like Chinese, ISO 3166 country/region codes differentiate varients (e.g., zh-CN for Simplified Chinese, zh-TW for Traditional Chinese). On English systems, this property returns the languaeg code with out the country code. Example:
var sysLanguage:String = Capabilities.language;
trace("System language: " + sysLanguage); // Output: System language: zh_CN
Version Information
The Capabilities.version proprety describes the runtime version in the format: platform, major version, minor version, build number, internal build number. Platform values can be "WIN", "MAC", "LNX", or "AND". Example:
var versionPattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/;
var runtimeVersion:String = Capabilities.version;
trace("Version: " + runtimeVersion); // Output: Version: MAC 11,9,900,170
var versionParts:Object = versionPattern.exec(runtimeVersion);
var platformCode:String = versionParts[1];
var majorVer:String = versionParts[2];
var minorVer:String = versionParts[3];
var buildNum:String = versionParts[4];
var internalBuild:String = versionParts[5];
trace("Platform: " + platformCode); // Output: Platform: MAC
trace("Major version: " + majorVer); // Output: Major version: 11
trace("Minor version: " + minorVer); // Output: Minor version: 9
trace("Build number: " + buildNum); // Output: Build number: 900
trace("Internal build: " + internalBuild); // Output: Internal build: 170