Unknown Domain

HOW TO: Find the path to the location of Flash projector (Win + Mac)

This snippet of code can be put in the main flash projector so that any loaded swf files can find their way home....

var path = "";
var currentPath = _root._url.split("/");

for (i = 0; i < currentPath.length; i++)
	if (i != (currentPath.length - 1)) path = path + currentPath[i] + "/";

The code simply gets the _root._url and splits it everywhere it finds a forward slash and puts it all back together again skipping the last part of the url (the filename) its a simple bit of code, could be better written by searching for /*.* using a search pattern but it works and it only has to run once if you run it in an if statement....

if (_root.path == "") {

I am using this code for a project where we need to have a USB flash drive with two partitions, one for Mac, and one for PC, the PC one will have all the assets (SWF files) and the Mac one will just have a flash projector which points to "files:///Volumes/Memory stick name". The windows partition will need to have the above code so it knows where to look for its files as Windows assigns a random drive letter where as the Mac uses the "/Volumes/Memory stick name" which unless renamed should remain the same.

The need for two partitions came as for Windows we will have an autorun.cfg file to launch the projector but on Mac this is not possible so the user will open the Finder window and because that partition of the drive is formatted for Mac it will remember the layout allowing us to setup a custom logo, and layout which will be more user friendly than a list of files.