views:

830

answers:

4

There is a way to know the flash player version installed on the computer that runs our SWF file with Action Script 3.0?

+4  A: 

It's in flash.system.Capabilities.version

davr
A: 

http://www.playerversion.com/

Luke
I believe the question was looking for how to determine the flash version from within the program itself...
vanhornRF
+8  A: 

If you are programming from within the IDE the following will get you the version

trace(Capabilities.version);

If you are building a custom class the following should help. Make sure that this following code goes into a file named VersionCheck.as

package
{
    import flash.system.Capabilities;
    public class VersionCheck
    {
     public function VersionCheck():void
     {
      trace(Capabilities.version);
     }
    }

}

Hope this helps, always remember that all of the AS3 language can be studied online here http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/ and for the best tutorials out there check out Lee Brimelow at http://www.gotoandlearn.com and http://theflashblog.com

<3AS3

Brian Hodge
Graat ansewr Brian, thanks very much, this helps me a lot!
unkiwii
+3  A: 

This example might help figuring out the details you receive so that you can act on specifics within the somewhat awkward data you get.

import flash.system.Capabilities;


var versionNumber:String = Capabilities.version;
trace("versionNumber: "+versionNumber);
trace("-----");

// The version number is a list of items divided by ","
var versionArray:Array = versionNumber.split(",");
var length:Number = versionArray.length;
for(var i:Number = 0; i < length; i++) trace("versionArray["+i+"]: "+versionArray[i]);
trace("-----");

// The main version contains the OS type too so we split it in two
// and we'll have the OS type and the major version number separately.
var platformAndVersion:Array = versionArray[0].split(" ");
for(var j:Number = 0; j < 2; j++) trace("platformAndVersion["+j+"]: "+platformAndVersion[j]);
trace("-----");

var majorVersion:Number = parseInt(platformAndVersion[1]);
var minorVersion:Number = parseInt(versionArray[1]);
var buildNumber:Number = parseInt(versionArray[2]);

trace("Platform: "+platformAndVersion[0]);
trace("Major version: "+majorVersion);
trace("Minor version: "+minorVersion);
trace("Build number: "+buildNumber);
trace("-----");

if (majorVersion < 9) trace("Your Flash Player version is older than the current version 9, please update.");
else trace("You are using Flash Player 9 or later.");
Martin
Thanks for the explanation. Not necessary but helpfull
unkiwii