Posts Tagged as3
Determining whether a SWF is running in the IDE or a browser
Posted by nerdabilly in ActionScript, ActionScript 3.0, Flash on June 1, 2011
Here’s something that’s been around for a while that I didn’t learn about until just recently.
The flash.system.capabilities.playerType property can be used to tell whether you’re running in the browser, a standalone player, or the Flash IDE. It returns the following values (from Adobe’s documentation):
- “ActiveX” for the Flash Player ActiveX control used by Microsoft Internet Explorer
- “Desktop” for the Adobe AIR runtime (except for SWF content loaded by an HTML page, which has Capabilities.playerType set to “PlugIn”)
- “External” for the external Flash Player or in test mode
- “PlugIn” for the Flash Player browser plug-in (and for SWF content loaded by an HTML page in an AIR application)
- “StandAlone” for the stand-alone Flash Player
Simply check for (flash.system.capabilities.playerType == "ActiveX" || flash.system.capabilities.playerType == "PlugIn") and you’ll know you’re in a browser.