View Full Version : Detect browser or IDE?
movax
April 21st, 2008, 03:53 PM
Hello -
I'd like to know how to get AS3 to detect if it is running in the IDE or in a browser. That way I can disable certain functionality and trace it out instead while testing.
Thanks!
Anogar
April 21st, 2008, 03:55 PM
You could pass a Flashvar in the HTML file, and make a conditional statement off of that.
movax
April 21st, 2008, 04:05 PM
Hmm true, I could do that however I'd really rather use detection, so it isn't dependant on something external and easy to forget. I seem to remember coming across this info before - but I can't seem to find it.
You could pass a Flashvar in the HTML file, and make a conditional statement off of that.
dail
April 21st, 2008, 04:10 PM
You can use the URL property of the swfs loader.
var path:String = this.loaderInfo.url
if(path.search("http") == -1){
//not in a browser...
}
I use that approach when using PHP to provide data to Flash, to check that I'm running on a web server.
movax
April 21st, 2008, 05:23 PM
Capabilities.playerType
playerType:String (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html) [read-only] Language Version : ActionScript 3.0 Player Version : Flash Player 9 Specifies the type of runtime environment. This property can have one of the following values:
"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 PlayerThe server string is PT.
Implementation
public static function get playerType():String (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html)
neverrain
March 4th, 2009, 05:06 PM
Capabilities.playerType
playerType:String (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html) [read-only] Language Version : ActionScript 3.0 Player Version : Flash Player 9 Specifies the type of runtime environment. This property can have one of the following values:
"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
The server string is PT.
Implementation
public static function get playerType():String (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html)
This method doesn't work for detecting IDE vs AIR by the way. If you set the player type to AIR inside Flash and run in Debug mode for testing the playerType will always evaluate to Desktop even if you are viewing the app inside the Debugger.
I'm not sure how to determine the difference between AIR in the IDE and AIR running on the desktop yet.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.