Referencing External Files From a SWF
I have seen several examples of a SWF movie being unable to find an external file when it loads (an mp3 file, for example) even though it worked during testing.
I don't pretend to be an expert in Flash, but I have seen this problem enough to recognize it.
In testing, the SWF and the external file are both in same folder as the HTML file that calls the SWF. On the live site, the SWF and the external file that calls it are in the same folder. The calling HTML page may be in the same folder or a different one (because the SWF file can be called from any of several pages on the site).
When the SWF is called from a page in a different folder, the external file fails to load (again, even though it did in testing).
The problem is that the path that the SWF uses to load the external file is relative to the page being loaded in the browser and not the location of the SWF file itself.
For example, if you have movie.swf in the images folder that needs to use a sound.mp3 file that is in the same folder. It seems like you should be able to reference the sound.mp3 file as "sound.mp3". This will only work, however, if the file being called from the browser is in the images folder as well.
If the browser is requesting the index.html in the root of the site then the SWF will look for sound.mp3 in the root of the site. You could place your sound.mp3 in the root of the site, but that will only work if all of your HTML files are in the root of the site (not a safe assumption).
If you changed the reference to "images/sound.mp3", then it would work when calling index.html in the root of the site. This approach, however will fail when calling a file from another folder. For example, if you are calling about/index.html, then that reference will cause the SWF to attempt to import "about/images/sound.mp3".
The real solution is to use references that are relative to the site root instead of the current file. So, in our example it would be best to reference the sound file as "/images/sound.mp3" (the / at the beginning is the key). This reference will find the sound.mp3 file in the images folder no matter where the SWF is and no matter where the HTML file calling it is.
Thanks for the clarity, I have had this problem many times on other projects and I just ended up using the entire root link (eg. http://www.domain.com/site/flash/sound.mp3) Does this also work?
Thanks.
I'm sure that would work, but I wouldn't recommend it. You could get the same mileage with "/site/flash/sound.mp3" with the added benefit that this would work on a development site as well (assuming a true development site and not development in a subdirectory of a site).