My WTF of the day: URLs and nested swfs

So, I have this bunch of classes to handle similar games, and all this classes are imported (and thus included) in a file called Library.swf. Each game loads this library and then use the classes that are inside, instead of importing itself. It’s great for updating, because there are a ton of games and I have to recompile only the library.

It’s working wonderfully, thank you, but I’m stuck at a somewhat simple task: retrieving the game url, for a simple domain name checking.

No matter what I do from a class inside the library, it will trace “Library.swf”, never “Game.swf”.

Look at the following pieces of code:

In the timeline:

new GameManager(this, option1, option2, option3)

In the GameManager class:

public function GameManager(topLevel, option1, option2, option3, option4=null) {

And I have tried all the possibilities: root, root.stage, topLevel.stage, topLevel.root.stage… None worked.

The first traces “Game.swf”, the second “Library.swf”. The same object, tracing different values depending on who is asking for them.

It already gave me a few wtfs, now I’m bringing it here so you can *wtf *too. And maybe find a solution, who knows.

I’m currently using the following:

var'eval', 'window.location.href') || stage.loaderInfo.url

But it requires javascript if the file is opened in the browser, or returns the library path when opened in the stand alone player.
At least it works for javascript enabled webpages, but other options would be good.