开发者

ActionScript 2 load another SWF that loads other files - relative path/url problem

Few facts first:

1. I can only use ActionScript 2.

2. All files are within the same domain (i.e "http://www.example.com").

I have a lo开发者_运维技巧ader SWF which acts as a selection tool ("auto_magic.swf") located at "/" in the website (the root folder).

A User selects the tool he needs (it's a mechanical diagnostic system) and the main movie loads it (currently I use loadMovie() - suggest else if needed).

That tool is located at "/tools/[tools_name]/tool_main.swf".

Now, the "tool_main.swf" is loading just fine.

The problem is that "tool_main.swf" needs to load other files located in its folder, so for example it tries to load "config.xml", BUT Flash isn't looking for "config.xml" in the tool's dedicated folder - instead it's looking for this file at the root folder "/" where "auto_magic.swf" is located, probably because the movie's main swf is coming from there.

To make it even worst I cannot modify the tool's SWF ("tool_main.swf") because it's coming from a third party.

Is there any solution? As far as I see this I need one of these solutions;

1. Be able to set the base url of the loaded swf.

2. *Change* the whole movie's base url at run-time because it needs to load several tools from different folders.

Trying to solve this for several good hours. Help will be highly appriciated!


relative paths are always relative to where the main swf exists. so as your load chain expands, '/' always refers to the location of the Main.swf.

in AS2, you can inspect a swfs _url property to determine its fully qualified url location, and determine its parent folder.

In the AS2 child swf, you can use this:

var myfolder = this._url.slice(0, this._url.lastIndexOf('/') + 1);

and then use that to load in further assets relative to itself.

hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜