Login / Sign Up

Path issues with SWF files configured via XML

 

 

Generally, you must know that the path of the assets the SWF uses (the path of the images specified in the XML file and the path of the XML files themselves) must be relative to the path of the HTML file which embeds the SWF file (and not relative to the SWF file - a common confusion).

More conclusively:

If the folder path of the HTML differs from the assets’ folder path (the folder in which the XML files and images folder are located) then you must specify that path through a variable called folderPath.
For example, in the swfobject embedding code, under this line:

var flashvars = {};

add this line:

flashvars.folderPath = "my_path";

and replace my_path with the path you need to follow to go from the location of the HTML file to the folder in which the assets are located. Alternatively you can specify an absolute path. Note that when you specify the folderPath, it must be terminated with a “/”.

If it is still unclear, please read this arbitrary example:

- the index.html file is located at this address on my domain:
http://www.mydomain.com/mycomponent/index.html

- the swfobject.js file is located at this address:
http://www.mydomain.com/js/swfobject.js

- the asset files (XMLs and images folder) are located in this foloder:
http://www.mydomain.com/mycomponent/assets/

- the SWF file is located on the root folder on my domain:
http://www.mydomain.com/component-name.swf

In this case, the right embedding code in the index.html file using relative paths is:

<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
flashvars.folderPath = "assets/";
var params = {};
params.scale = "noscale";
params.salign = "tl";
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("../component-name.swf", "component-name-div", "600", "300", "9.0.0", false, flashvars, params, attributes);
</script>

 

So again, all the paths are relative to the path of the HTML file and note that the folderPath (if specified) should end with a slash (/). You can of course use any path you like for any type of file, but the references must be modified accordingly.

You can also use absolute paths, for example:

flashvars.folderPath = "http://www.mydomain.com/mycomponent/assets/";

 


    
  • COMMENTS
Loading comments... If comments don't show up in 5 seconds, click to load

Leave a Reply

Only alphanumeric characters allowed
Please type a message!
Format your comments using Textile: *bold*, _italic_, "link text":address,
@code@