1
votes

I could barely find a reasonable title that would explain my issue, let alone try and search for how to fix this.

My issue:

  1. User uploads a .zip with say:

    • flash.swf
    • images.xml
    • image.jpgs
  2. It gets extracted into a unique folder ID ex. /swfs/123456/

  3. Server tries to load the .swf in "index.php" and the .swf tries to call the .xml file, which should be in the same directory as the .swf, thinking xml src="images.xml"

The .swf thinks the xml file is in the same folder, but I guess when HTML calls a .swf is confused of it's directory. It's looking for an xml file that doesnt exist because its looking in the same folder as index.php instead of the .swfs original folder ex. /swfs/123456/images.xml

How would I possibly tell the .swf to load an xml without knowing what the directory is, or stop html from confusing my .swf of it's original location?

*Or is it that the xml file is confused of it's location and linking to the wrong images?

2
Could you post some relevant code to help clarify your question? - Colin Brock
Simple breakdown : <code> // Get the .swf from unique folder <object width="100" height="100"> <param name="movie" value="file.swf"> <embed src="swfs/< ?php echo $key ? >/flash.swf" width="100" height="100"> </embed> </object> //actionscript calls XML var xmlPath:String = "images.xml"; // Xml calls images via <images> <imgurl>images/image01.jpg</imgurl> </images> </code> I dont know whether its the .swf looking for the XML in the wrong folder, or the xml looking for the images in the wrong folder... - askon
Can you please edit your original question to include the code snippet using the correct formatting? Also, it might help to include any relevant PHP since that's included here as a tag. - Colin Brock

2 Answers

2
votes

When embedding your swf, you could set the base attribute.

base - . or [base directory] or [URL]. Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files.

From: http://kb2.adobe.com/cps/127/tn_12701.html

Also see: http://kb2.adobe.com/cps/041/tn_04157.html

Example:

<embed base="http://www.example.com/pages/" href="myMovie.swf" quality="high" 
pluginspage="http://www.macromedia.com/go/getflashplayer" 
type="application/x-shockwave-flash" ></embed>
2
votes

It's looking for an xml file that doesnt exist because its looking in the same folder as index.php instead of the .swfs original folder ex. /swfs/123456/images.xml

Yes, that's exactly what is happening. You won't be able to load the XML file with the relative path (images.xml) you are using. You will need to include the full path to the XML file (/swfs/123456/images.xml)

One possible way to do this is pass your $key variable to the .swf file so you can include it in the path to the XML file. You could do something like:

www.yoursite.com/index.php?key=123456

Then grab the variable using Actionscript, and insert it into the path name for the XML file:

xml src="swfs/"+key+"/images.xml"

Does that make sense? Of course, there are other ways to pass data from PHP to Flash and plenty of resources online that discuss them. A quick Google search should find you what you need.