Recently I’ve posted on jumpeyecomponents’ Knowledge base an item, for the TxEff component, that shows you how to detect the version of the current Flash player, using ActionScript 3 code.
The only difference between AS2 and AS3 in this case is the method to get the Flash player’s version. AS2 has the getVersion() method. In AS3, there is the flash.system.Capabilities class which has a property called version. In both cases you’ll get a String representing the platform on which Flash player runs and the version. The result looks like this: “WIN 9,0,115,0″ (for the 9.0.115 Flash player on Windows).
What does this String mean ? Well, the first letters are the platform on which Flash player runs. This could be “WIN”, for Windows, “MAC” for Mac OS and “UNIX” for Unix based operating systems. Then comes the actual version number of the player. The first number represents the major version number. Next comes the minor version number. Third is the build number and the last one is the internal build number.
The next code snippet, separates the version String into the corresponding parts and displays them:
import flash.system.Capabilities;
// Get the player’s version by using the flash.system.Capabilities class.
var versionNumber:String = Capabilities.version;
trace(“versionNumber: “+versionNumber);// The version number is a list of items divided by “,”
var versionArray:Array = versionNumber.split(“,”);
var length:Number = versionArray.length;// 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(” “);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);
It’s great.Thank you.
I’m glad it helped you.
Thanks a lot
good example thanks..
Thanks this is helpful. Do you know if there’s a global variable implementation in AS3?
Like say if you have 2 SWFs (parent and child) then you set a variable on the parent SWF and call it from the child SWF?
Thanks in advance :)
Hi Jonathan.
Usually child SWFs can access parameters of the parent SWFs without problems. Just make sure that the child SWF is loaded and initialized and also, when you want to access the parameters of the parent SWF, you need to keep in mind that the direct parent of the child SWF is actually the Loader object that loaded it. So to get ahold of the parent you would use
this.parent.parent["variableName"]. Where this is the instance of the child SWF, the first parent is a reference to the Loader object from the parent SWF and the second parent is actually the reference to the parent SWF.I hope this helps.