- Problem: a relative path URL defined in a loadMovie() script is relative to the HTML page containing the parent SWF, not the parent SWF of loaded SWF...
- This means that, if you want the SWFs to work in Flash Player as well as the in the HTML page (don't we all?!), the parent SWF must be in the same directory as the HTML page that contains it. The problem with this is that you can't embed that parent SWF from other HTML pages in different directories without breaking the relative links to the child SWFs.
Solutions??
- Just have one HTML page holding the parent SWF that loads all the children, but this is very limiting and in the job I'm on now - not possible
- You could have Absolute links to your child SWFs, but Best Practice of Actionscript advises against it.
- You could have multiple copies of the parent and child SWFs for each HTML page, even if they all look and work the same, with relative links to the child SWFs appropriate for each HTML page. You could re-save the one set of SWFs and make sure that the directory structure is the same for each HTML page so the loadMovie URLs don't have to be changed for each parent SWF - but that's just annoying. There must be a better way...
- One of the many posts I've read from people who've discovered this problem offered a bit of custom actionscript which can fix it by creating a 'relative absolute' path. It uses a function to generate a correct absolute path to each child SWF but it looks a bit complicated and I don't know if this is the way to go... The script is below with full description at
http://www.flashzone.nl/archives/000234.php
public function getAbsoluteUrl(urlInput:String):String {
var strResult:String = "";
if(urlInput.indexOf("http://") > -1) //only convert when online
{
if(urlInput.indexOf(".swf") > -1) // only convert when an actual .swf file is used
{
strResult = urlInput.substring(0, urlInput.lastIndexOf("/")+1); // find absolut path minus filename of .swf
}
}
return strResult;
}
loadMovie(getAbsoluteUrl(_root._url) + "_assets/lib.swf");
FOR THE LOVE OF GOD WOULD SOME GENIUS PLEASE SHOW ME THE WAY!!!
I have a massive Flash site to do that will get bigger and deeper (in terms of loaded child SWFs) and I'm under the gun so I need to figure out what to do. I think I might just have the one HTML page but I'm not sure what the implications of this are yet...