开发者

pass a base path to a swf loaded at runtime

开发者 https://www.devze.com 2023-01-25 02:28 出处:网络
I have a main.swf which 开发者_JAVA技巧loads a module.swf and the module.swf loads some assets.

I have a main.swf which 开发者_JAVA技巧loads a module.swf and the module.swf loads some assets. The module.swf works standalone and also needs to work when loaded by main.swf.

But unfortunately the module.swf can't find the assets when loaded by main.swf because the assets aren't located relative to the main.swf, but are located relative to the module.swf.

As I can't touch the module.swf and I'm also unwilling to change the directory structure, I am looking for a solution close to the a "base" parameter which can be used when a swf is embedded into html.

Is there a way to simulate the base parameter's behaviour when loading a swf file using Loader?

Here is a similar yet unanswered question.


You could use symlinks as a way to redirect your assets url when loaded via the main swf


Something like this

public class URLUtil 
{
    public static function getBaseURL(swfURL:String):String
    {
        return swfURL.substr(0, swfURL.lastIndexOf("/") + 1);
    }
}

example of usage inside module:

var assetURL:String = URLUtils.getBaseURL(root.loaderInfo.url) + "asset.filename";   
loader.load(new URLRequest(assetURL));
0

精彩评论

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