Detect Flash Player Version | Actionscript based detection method (as2)

looking for this in as3!? look no more Detect Flash Player Version | Actionscript based detection method (as3)

Overview

Recently I had a requirement that I had to detect which version of the flash player was currently installed. This is a normal thing, we do it all the time when embedding flash into html, we detect which version of the player is installed and if the user has an old version they are invited to upgrade…

But what about finding the flash version from within flash? An actionscript based detection method? I hadn’t ever thought about doing that…

It turns out it is very simple. From adobe I found the flash detection kit. Which had a lot of code I didn’t need. I only want to know what version of the player is running, not forward to upgrade sites and redirect… So I made this little testing file to save and share what I learned:

Steps

Internally flash knows it’s version number as $version. So to read it we must evaluate that variable.

eval(“$version”);

This returns a string, 3 letter operating system, a space, and then the version number as four numbers seperated with commas.
I display the $version and to split it out I split the string on the space, and then split the version number with the comma delimiter and display them all.

Example

Here’s what mine is (gif):

version detection actionscript gif

And here’s what yours is (swf):
[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/03/flashversiondetectionactionscriptmethod.swf” width=”160″ height=”160″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

Actionscript (as2)

[cc lang=”actionscript” tab_size=”2″ lines=”40″]
version = eval(“$version”);

//The operating system: WIN, MAC, LNX
var osType;
//The player version.
//The latest as of December ’07: 9,0,115,0
var majorVersion; //9
var majorRevision; //0
var minorVersion; //115
var minorRevision; //0

vers.text = version;

osArray = version.split(‘ ‘);
osType = osArray[0];

versionArray = osArray[1].split(‘,’);
majorVersion = versionArray[0];
majorRevision = versionArray[1];
minorVersion = versionArray[2];
minorRevision = versionArray[3];
[/cc]

Download

Here’s the source fla file: flash version detection actionscript method

Let me know how and if you find this useful

7 thoughts on “Detect Flash Player Version | Actionscript based detection method (as2)

  1. Beautiful, I was developing a game to be played at fullscreen mode. Since the flash Player 9 doesn´t allowed you to use keyboards, my game simple doesn´t work at all… 🙁 Then I decided to install Player 10 (beta version) to make my game useful, and It worked fine, but since most users haven´t installed this version yet, I decided to write a code which detects the flash player version. If 10 or higher were detected the script will allow the fullscreen mode. If version below 10 was detected, the button disappear and not fullscreen mode were permitted to avoid the game not to be played correctly.
    I thought it was very simple to get this code work correctly, but I found that my code made the flash player to be unstable. I tried to get some help at adobe.com and there was a code similar to mine, which also crashes the flash player… and finally I decided to surf the web to find some code which helps me to finish my project… and I found yours, which works perfectly for my purpose.

    Thank you very much 🙂

  2. ithink better use Capabilities.version to trace the version
    however i wondering did anyone know how to detect the user pc has installed adoble AIR or not by using AS3

    1. There are cases where the OS isn’t 3 characters, such as on devices running Windows Mobile. Luckily your code is written to split on the space, not depend on a number of characters, so it’ll work fine in the case of “WINCE”.

  3. var a:String = “”
    var b:Number = 0

    trace(eval(“$version”));

    a = eval(“$version”);

    a = a.slice(4,6)

    b = Number(a)

    // if main flash version = 9)
    {
    trace(“Yes”)
    }
    else
    {
    trace(“No”)
    }

Comments are closed.