Quick Tips:LocationUtil
From CASA Framework
The org.casaframework.util.LocationUtil utility includes helpful static functions to help you know where your Flash movie is internally. Let us cover two of them.
Be sure to import the class to access the static methods:
import org.casaframework.util.LocationUtil;
[edit] The isPlugin Method
To tell if your file is being run locally (IDE/Test Movie/Flash Player) or if your movie is in a browser player (plug-in/ActiveX) you can use the isPlugin function. For example; if you want to change file paths depending on testing locally or on a server:
if (LocationUtil.isPlugin()) {
// The movie is being played in the browser, let's look for FlashVars:
this.myMovie_mc.loadMovie(_root.imagePath);
} else {
// We are testing this movie locally, let's use our local test data:
this.myMovie_mc.loadMovie("test_files/images/test.jpg");
}
Which we could simplify to:
this.myMovie_mc.loadMovie(LocationUtil.isPlugin() ? _root.imagePath : "test_files/images/test.jpg");
[edit] The isDomain Method
If you want to know which domain the Flash file is on you can:
if (LocationUtil.isDomain(_root, "bbc.co.uk") {
trace("My SWF is on bbc.co.uk domain");
} else {
trace("My SWF is NOT on bbc.co.uk");
}
You can also check for subdomains:
LocationUtil.isDomain(_root, "news.bbc.co.uk")
This can be used to change file paths relative to the server delivering the SWF, or to redirect to your site if someone is hosting your file on an unauthorized server/hot linking your content.
Please note: LocationUtil is for internal code to know the location of the SWF, for external statistics check out our friends at MochiBot.

