Is my flash game local or on the internet?
I'm currently developing a flash game and I need to be able to test it on my local machine and also on the web.
When running locally I use some dummy test data and when online it is joined to an API.
While in development I would like to be able to detect where I'm running so I can switch between these automatically. Is there a way to detect this in Flas开发者_StackOverflow中文版h?
Check on your base movie clip (the root movie) the loaderInfo.url property,
when you're running locally loaderInfo.url will start with file://
Use substr() to extract the beginning and check against that value.
That's how I do it for my flash apps.
精彩评论