So, I thought I’d bring attention to a strange inconsistency I run into on a very regular basis while developing applications in Adobe Flash.
Much of the work that I do in flash has to do with displaying and managing video. To date, I have probably created at least 50 different playlist enabled video players, by which I mean video players with a list of either links, thumbnails, or both that allow you to play other videos in the same container without leaving the page. For example, something like this…

A Generic Video Player
…with a playlist that allows you to select other videos, like this…

Video Player with Playlist
This is all well and good. Because I try to build in a way that’s generalized for client accessibility and ease-of-use (and because I don’t want to be solely responsible for updating these things myself), the standard way to go about creating something like this would be to have an external XML document that contains all of the information required to build the playlist. The application is responsible for loading that document and extracting that information from it, which it uses to build a clickable, interactive playlist. This is all quite simple. The XML could look something like this:
<playlist>
<item>
<uid>1</uid>
<title>Video 1</title>
<video>PATH TO VIDEO</video>
<thumbnail>Image for video</thumbnail>
</item>
<item>
<uid>2</uid>
<title>Video 2</title>
<video>PATH TO VIDEO</video>
<thumbnail>Image for video</thumbnail>
</item>
<!-- and on, and on, and on -->
</playlist>
The folder structure for such an application could (and would) conceivably look like this:

FLA Folder
Within our document root, we have an FLA folder to hold our source files.

FLV Folder
We have an FLV folder for holding video assets.

SWF Folder
We have a SWF folder for holding all of our compiled application SWFs.

XML Folder
And finally we have an XML folder for holding any XML documents we’ll be loading in the application. The index file resides in the document root.
Here’s where things get screwy.
In my application, when I’m ready to load my external XML in order to build a playlist, my code will look like this:
var req:URLRequest = new URLRequest("xml/playlist.xml");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, _playlistHandle, false, 0, true);
loader.load(req);
After I’ve loaded my playlist, suppose I want to play the first video. For the sake of brevity, we will suppose that I have an instance of a video player class that will allow me to simply pass the path to the FLV in to begin playing it, and that it’s already been instantiated and configured under the name “_player.”
function _playlistHandle(e:Event):void {
var loader:URLLoader = e.target as URLLoader;
var xml:XML = XML(loader.data);
_player.play(xml.item.video[0].toString());
}
What do you suppose the path to my video is going to be, within my xml doc? If you look above, you’ll see I loaded the xml from the document root, and it would be natural for you to assume that the path to the first video is “flv/video.flv.” In this instance, you would be incorrect.
The correct path to the video file would be “../flv/video.flv.” Why is this? The relative path to an asset, in flash, varies according to what type of asset it is you’re accessing. In the case of XML you load your file from the location in which the SWF file is running, which in our example is the document root. When you’re loading video, however, you have to load your file from the physical location of the swf, not from where it’s running. In our example, that means our video file must be loaded as if the application is running from within our “swf” subfolder.
Why is this the case? I honestly have no idea. I can only imagine that in some obtuse way it’s meant to protect video content from being exploited by external domains or malicious third parties, though I can’t see exactly how.
Hopefully if you find yourself developing such an application, and you can’t figure out why the paths to your videos won’t resolve correctly, you’ll remember reading about the issue here. If anyone has a good explanation for why this is the case, I’d also be very curious to be informed.