Unexpected “Gotcha” with Relative Paths in ActionScript
Friday, August 25th, 2006About a month ago, I mentioned a quirky fact of life when dealing with relative paths in ActionScript. In a nutshell, a SWF’s point of view changes depending on how it’s embedded. A SWF considers relative paths from its own folder when played in a Projector. That makes perfect sense. On the other hand, a SWF embedded in an HTML document, as played by the Flash Player plug-in, sees things differently. To a SWF in an HTML document, relative paths begin from the folder of the HTML document.
For example, if a root HTML document embeds a SWF in a flashcontent subfolder, and if that SWF loads a JPG from the same folder as itself, the ActionScript must nevertheless include a reference to the flashcontent subfolder — because that’s where that JPG is located from the HTML’s point of view. This can quickly confuse matters when you test the SWF from inside Flash, because the Flash IDE plays SWFs inside a special Projector (see (Perhaps) Unexpected Point of View: SWF Defers to HTML for some workarounds).
That’s a “gotcha” enough already, but I just discovered an exception to the rule. Keep reading »







