capabilities.version Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
capabilities.version Property Flash 6

the Flash Player version read/write
System.capabilities.version

Description

The string version property contains version and platform information for the Flash Player hosting the current movie. As of Flash 6, it is favored over the getVersion( ) function, though the two return the same value. Because capabilites.version is not available in Flash 5, getVersion( ) must be used for movies that will be played in Flash Player 5. Similarly, $version must be used for movies played in Flash Player 4.

The string stored in version takes the form:

platform majorVersion,minorVersion,buildNumber,patch

where platform is a code indicating the platform ("WIN", "MAC", or "UNIX"), followed by the major version number, the minor version number, and the build (a.k.a. revision) number. The last item, patch, is typically 0. For example:

WIN 5,0,30,0   // Version 5.0, Build 30 (5.0r30) on Windows  MAC 5,0,41,0   // Version 5.0, Build 41 (5.0r41) on Macintosh UNIX 4,0,12,0  // Version 4.0, Build 12 (4.0r12) on Unix

To obtain a more detailed description of the current operating system, use capabilities.os.

In Test Movie mode, version reports the version number of the Player embedded in the authoring tool (which is not the same as the version of the authoring tool itself). For example, the Flash 5 authoring tool embeds the 5.0 r30 version of the Player, so it has a version of:

WIN 5,0,30,0

or:

MAC 5,0,30,0

Any time a major or minor version of the authoring tool is created, the buildNumber restarts at 0. However, in the typical development cycle of the Flash authoring tool, many builds of the Flash Player are produced before the final version of the authoring tool is released. Hence, the build number of the first new major version of a Player is usually greater than 0. For example, Flash Player 5 was first officially released at Build 30. Flash Player 6 was officially released at Build 23. A movie running in the first publicly released Flash Player 6 on Windows has a version of WIN 6,0,23,0.

Typically, we're concerned only with the platform, the major version, and the build number of a Player. To extract the portion of the version string we're after, we can use the string manipulation tools described in Chapter 4, or we can construct a custom object with each component of the version string assigned to a property of that object, as shown in the following Example.

When a movie is embedded in the browser, JavaScript and VBScript provide external tools for version detection, browser sniffing, and automatic page redirection. For details on detecting the Flash Player's presence and version with JavaScript and VBScript, see:

http://www.moock.org/webdesign/flash/detection/moockfpi

The corresponding server string for version is V, with possible values as described earlier in this Description.

Example

The following code extracts the various portions of the version string and stores them as the properties of an object for easy access:

// Split up the version string into usable pieces. var version = System.capabilities.version; var firstSpace = version.indexOf(" "); var tempString = version.substring(firstSpace + 1, version.length); var tempArray = tempString.split(",");     // Assign the various parts of the getVersion( ) string to our object. // Note that we convert the version number portions to integers. var thePlayer = new Object(); thePlayer.platform = version.substring(0,firstSpace); thePlayer.majorVersion = parseInt(tempArray[0]); thePlayer.minorVersion = parseInt(tempArray[1]); thePlayer.build = parseInt(tempArray[2]); thePlayer.patch = parseInt(tempArray[3]);     // Now use our object to perform version-specific code. if ((thePlayer.majorVersion =  = 6) && (thePlayer.build <= 23))  {   this.createTextField("warning_txt", 1, 300, 300, 250, 30);   this.warning_txt.border = true;   this.warning_txt.text = "Please upgrade your Player to avoid streaming bugs."; }

Bugs

Macromedia's documentation for Flash MX incorrectly claims that the server string for version is VER (it actually is V) and that the value of version is an integer (it actually is a string).

See Also

capabilities.os, getVersion( ), $version



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net