Accessibility

TechNote

Detecting Flash Player version information with $version

Introduction

As Adobe Flash Player updates are released, player version information becomes important to ensure proper movie playback. For example, the ability to view a Flash file in Netscape with the wmode parameter set to True was first introduced in Flash Player version 6,0,65,0 (major version: 6, minor version: 0, revision: 65).

Before you attempt to use browser transparency, make sure the player supports that feature. This document explains how to detect major and minor versions of Flash Player using ActionScript.

Determining version information with Flash MX and later

Utilizing the System object, you can simply use the ActionScript System.capabilities.version to return the player version:

 playerVersion = System.capabilities.version; 

The version information is returned as a string in the following format. The string consists of an abbreviation for the platform followed by numbers indicating player version number (major version, minor version, revision, build number).

 WIN 9,0,16,0 MAC 9,0,16,0 UNIX 7,0,25,0 
Detecting the presence of Flash Player

To determine whether or not Flash Player is present on a machine, use either of the following methods. Both of these methods are discussed in more detail in How to detect the presence of the Flash Player (TechNote 14526).

The Flash Player Detection Kit provides a complete framework for script-based detection of Flash Player. You can also detect Flash without JavaScript using a Flash-based detection method.

A basic player version detection script

Use the following script to determine major and minor player version with Flash Player 4,0,11,0 and later.

To use this code, copy and paste the code into the first frame of a new Flash movie. Replace the commented sections (within the If statements) with commands that either redirect to alternate content or alert the user to upgrade the player, for example. In order for $version to work, you must publish for Flash Player 4 or 5. Later players should use the System object.

 playerVersion = eval("$version");
		
myLength = length(playerVersion);
while (i <= myLength) {
i = i + 1;
temp = substring(playerVersion, i, 1);
if (temp eq " ") {
platform = substring(playerVersion, 1, i-1);
majorVersion = substring(playerVersion, i + 1, 1);
secondHalf = substring(playerVersion, i + 1, myLength - i);
revision = substring(secondHalf, 5, 2);
trace("platform " + platform);
trace("majorVersion " + majorVersion);
trace("secondHalf " + secondHalf);
trace("revision " + revision);
}
}

To test these expressions, preview the Flash movie in a browser by choosing File > Preview in Browser. To test the detection script against older versions of the Flash Player, see Archived Flash Players available for testing purposes (TechNote 14266).

Background information: Flash 4 and 5

In Flash Player 4.0r11 and later, version information is contained in a hidden variable called $version. This special variable, when evaluated, returns player version information in string form.

Flash 5 introduced a new function, getVersion(), that evaluates $version automatically and returns the result. With the System object, Flash MX also introduced a new method of determining the specific version of Flash Player. ThegetVersion() method in Flash 5 made this easier, as you didn't have to use eval:

 var playerVersion = getVersion(); 

In Flash 4, the eval function was used to extract the information in $version, as in the following code example:

 Set Variable: "playerVersion" = eval("$version") 

Note: In releases of Flash Player earlier than 4.0r11, no version information is returned by these methods.

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:tn_14294
Browser:Chrome
Internet Explorer
Netscape
Opera
Safari
Firefox
Database:DB2
Informix
MySQL
Oracle
SQL Server
Sybase
MS Access

Products Affected:

flashplayer