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));
精彩评论