David Millington

Handy Flash Domain Reading

"How can a Flash file see the address of the page its on?"

Get asked that one quite alot. I've put some thought into it and have begun toying with a few ideas.

The other day I was browsing the Class libraries (like you do) and I stumbled across two methods of getting domain information inside Flash, both examples will use the following url as their content path:


In the HTML the top page swf header has its full address that looks like this:



<object type="application/x-shockwave-flash" data="/shared/swf/navi.swf?sec=news" width="770px" height="76px">
<param name="movie" value="/shared/swf/navi.swf?sec=news" />

Inside Flash we can use the LocalConnection class to get the domain name:

var domain_lc:LocalConnection = new LocalConnection();
/* traces www.davidmillington.net */

The second method is simply:

/* traces http://www.davidmillington.net/shared/swf/navi.swf?sec=news */

Each time you load a Flash movie its _url property gets set to the address it was loaded from.

Im not sure what would happen if you used server side path rewriting to do something like


as the path used in the Flash objects data attribute. If that was seen inside Flash instead of its real location then it means you could easily parse that string to get the page name "/news" and then the real path "/shared/navi.swf". Then its just a case of using "?sec=" + pagename in the rewrite system. Like I said though, without testing it I'm not sure which address it will see.

I'm going to do a test with a few http headers and see what I get. The most promising idea so far is to capture all requests for .swf files and then append the url of the page that requested it via the HTTP_REFERER header. I'm not sure if that will include the actual page name so thats why this is a test.

Leave a comment

thought point page code people class install work player adapter system list panel directory via network problem adobe bit mode setup new time music update address site device version flash settings project xml box screen button control house file show simple option windows menu phone read think game pretty rocky