PDA

View Full Version : URL problem..


peptobismol
08-11-2007, 10:03 PM
When an swf & html is placed on the web, they have to be in the same folder to work properly especially when the swf is doing a loadMovie or any .load.

If the html is in another directory and calls the swf... loadMovie will not work as it will try to load from the directory of the html and not the swf.. weird huh?

for example.
the html page is in one directory.
/loadSwf.html <--- calls /myFolder/firstOne/mySWF.swf

the swf is in another directory.
/myFolder/firstOne/mySWF.swf
/myFolder/firstOne/movie1.swf
/myFolder/firstOne/movie2.swf

if mySWF.swf do a loadMovie ( loadMovie("movie1.swf", 1) ), it'll get an error because it will try to load at the directory of the html, like /movie1.swf

I've thought up of 3 solutions so far.. Any more solutions would be much appreciated!

answer 1:
loadMovie("/myFolder/firstOne/movie1.swf") instead of
loadMovie("movie1.swf")

answer 2:
put the html & swf in the same directory
and use an <iframe> in whatever directory and load the html in the iframe.

answer 3:
do a complicated string parsing on _url on the swf to get the path of the movie and do like answer 1. (in cases when the swfs get moved to another directory)
something like :
myURL = _url;
myArray = myURL.split("/");
path = "";
for(var i=0; i < myArray.length-1; i++) {
path += (myArray[i] +"/");
}

loadMovie("/"+path + "movie1.swf");