1

I know I could use "BrowserManager.getInstance()" to find out which from URL is my app running, but it doesn't work as I would expect (you can't read url in one line - you have to wait for an event).

Is it possible to do it in some simple way? Like you do in Flash:

if (this.getDepth() == -16384)
Nux
  • 9,276
  • 5
  • 59
  • 72

2 Answers2

1

This is how I do it

var lc:LocalConnection = new LocalConnection();
switch ( lc.domain ){
  case "":
  case "localhost":
    trace('on a dev machine')
    break;
  case 'your.domain.com':
  default:
    trace('not dev so fall through')
}

A one liner could be done like

if(new LocalConnection().domain == "localhost" )
The_asMan
  • 6,364
  • 4
  • 23
  • 34
  • Great! thanks. Just in case anybody wonders you need "import flash.net.LocalConnection;" too (if it's not added automatically). – Nux Sep 22 '11 at 07:38
0
import flash.system.Security;

Security.sandboxType == Security.REMOTE

That tells you when it's running on the web.

jhocking
  • 5,527
  • 1
  • 24
  • 38
  • Doesn't work `(Security.sandboxType == Security.REMOTE)` returns true when I run debug in Flash Builder. – Nux Sep 21 '11 at 15:23
  • darn, well that works in my company's project (we use that to check if we should expect login data from the webpage). We don't use Flash Builder though, so I dunno. – jhocking Sep 21 '11 at 15:29