It can sometimes be useful to now at runtime in which environment is running our flash animation (from the CS3 flash player, from a test server, from the production server…). For example, you may want to display the framerate when testing, but not on the production environment. Or you may need to access another WebORB (or whatever) server in test and prod environment.
As the flash application runs in the client, I found that the easier was to rely on a flashvars set in the index file.
So all you need to do is:
In the html file embedding the swf: (change “production” to “local” or “testing” on the corresponding environment)
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://macromedia.com/cabs/swflash.cab#version=9,0,0,0" id=flaMovie width=800 height=600> <param name=movie value="flaMovie.swf"> <param name=FlashVars value="environment=production"> <param name=quality value=medium> <param name=bgcolor value=#00000> <embed src="flaMovie.swf" FlashVars="environment=production" bgcolor=#000000 width=800 height=600 type="application/x-shockwave-flash"> </embed> </object>
And then in the action script code:
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var environment:String = paramObj["environment"];
And then you can use this environment flag to show / hide debug informations.
