views:

346

answers:

2

Hi,

I am trying to embed swf to html, and I'm using SwfObject 2.0 My swf has a xml file with it, the swf are in the same folder with index.html, and the xml file is in a subfolder called xml. So far everything's fine and working. However, I have another html page that's in a subfoler and wants to load the same swf and xml. This time, the xml didn't load. I've checked the path like a million times, and tried this

<script>
  var flashvars = {};
  flashvars.folderPath = "../";
</script>

nothing works unless I duplicate the xml folder and put it in the subfolder with the html file. Anyone know how to solve this? Thanks in advance.

Cheers

A: 

try using direct path in your flash, not relative

I assume the link to your file is looking like file.xml which is a relative way
accessing directly - the link to the xml is something like: /file.xml or /path_to/file.xml (note the slash at the beginning)
this way, wherever you embed your swf, it'll call the xml properly

Michal M
I'm a bit confused now, since I did not link the path from the index.html, so am I suppose to do that? is this the right way to do so?<param name="flashvars" value="xml_path=/xml/data.xml" />
christinelalala
Yes, this will basically make the flash request for xml work from any location on you website. Whether the swf is at example.com/file.swf or example.com/dir/file.swf the request will always be to example.com/xml/data.xml
Michal M
I see, so I still have to state the path in the html page or else it's not going to find it?
christinelalala
It's up to you whether you specify the path to XML in HTML and pass it as a flash-variable, or you make it fixed (not dynamic) in the flash itself.
Michal M
You can also try with the "base" parameter, see here:http://stackoverflow.com/questions/1575771/relative-urls-in-actionscript-3/1576747#1576747
Cay
A: 

Unlike CSS, the root path of a Flash movie is the location of the hosting webpage, not the location of the SWF file itself. As Michal says, using a full path to the XML file should resolve this issue.

spender