2

I want to know, if my Flashapplication is running in a browser or it is tested from within Flash authoring tool (local Flashplayer).

I came up with this one.

var isLocal:Boolean = !ExternalInterface.available || ExternalInterface.call("window.location.toString") == null;

Other than stated in the AS3 documentation ExternalInterface.available returns always true when running in a browser or testing locally.

line-o
  • 1,885
  • 3
  • 16
  • 33

1 Answers1

3

Try using Capabilities.playerType, it will return the type of runtime environment.

Link to the documentation here:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html#playerType

Bakapii
  • 1,014
  • 1
  • 7
  • 12
  • It returns __"External"__ for the external Flash Player __or__ in test mode. But I have to know which one of these I am running on. – line-o Jul 26 '11 at 12:12
  • @line-o But you asked to find out whether it's running in the autoring tool or in the browser. If you run it in the browser it returns "PlugIn" and from the autoring tool it returns "External". Edit: Saw the update to your question, that's kinda weird. – Bakapii Jul 26 '11 at 12:28
  • 1
    @line-o For me it does exactly that. If i build and run a SWF file from the authoring tool with only a TextField that prints the returned string from Capabilities.playerType, it prints "External". If I then open that exact same SWF in my browser it prints "PlugIn", which is what I'd expect. Is that not the case for you? Edit: Also if I run that exact same SWF by double-clicking it in the OS it prints "StandAlone". – Bakapii Jul 26 '11 at 13:00