Flash Cookbook - Tricks - version detection with Flash AS2
There is a practical way to detect the version of flash running on the client's computer. We will use System.capabilities class to reach our goal.
Description:
First of all flash gets a parameter called "url". This will be the url of a php file to call after version is detected. Keep in mind that if the php is not called then there is no flash player at all.
Flash code:
//GET -> url
var version:String = System.capabilities.version;
var load1:LoadVars = new LoadVars();
load1.load(url + "?version=" + version);
The LoadVars above calls our php and passes the version:
Php code:
$version = $_GET['version'];
... your actions here ...
Html code to embed the swf:
... src="version.swf"
width="0"
height="0"
flashvars="url=version.php"
/>
Conclusion:
From the code above you can see that we set the size to zero. We don't need anything else than it's detection job.
After compiling it the swf became 175 bytes.
Homework: think about solutions using flash without displaying a single frame. What functions and classes can you use in this case?