Link to home
Start Free TrialLog in
Avatar of hostopolis
hostopolisFlag for United States of America

asked on

Accessing remote Flex swf & xml data

I have a Flex swf I created on my site that rotates product images. It gets the image locations from an xml file on my site. On my site, it works great. However, I want to place this in an eBay listing. The Flash movie appears in the listings, so the movie is playing, but the photos do not.

The param to the movie file works fine, as the movie does indeed appear on ebay. How can I get it to retrieve the data? I have tried the crossdomain.xml trick, but that has not solved the problem.
<param name="movie" value="http://www.mydomain.com/sl_slideshow/sl_slideshow.swf" />

Open in new window

Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

How are the Photo's location stored in the XML? is it relative or Photo URL's?
Avatar of hostopolis

ASKER

The xml is below.
<?xml version="1.0" standalone="yes"?>
<PhotoGallery>
  <photo>
    <url>assets/photos/photo01.jpg</url>
    <title>Polo</title>
  </photo>
  <photo>
    <url>assets/photos/photo02.jpg</url>
    <title>Fleece</title>
  </photo>
  <photo>
    <url>assets/photos/photo03.jpg</url>
    <title>T-Shirt</title>
  </photo>
</PhotoGallery>

Open in new window

Ok how are you adding your swf to eBay listing in the sense are you just pointing it to show the SWF from your site?
Yes. Since we are not allowed to upload the swf and the related files, I can only point to the swf on my site.

<param name="movie" value="http://www.mydomain.com/sl_slideshow/sl_slideshow.swf" />
I was certain I had tried full URLs last night, but it was late, and I was very tired, so I tried it again. Both in the xml file, and in the Flex code as well.

AS code in Flex:
var myXMLURL:URLRequest = new URLRequest("http://www.nakdtree.com/sl_slideshow/assets/xml/Photos.xml");

XML:
<url>http://www.nakdtree.com/sl_slideshow/assets/photos/photo01.jpg</url>

It still didn't work. Then, I had a rare moment of clarity, and deleted my browser cache. Now it works.

And, I have a new question, for which I will reward these points for, if you have an answer:

How can I make the location of the XML a <param> in the HTML so the same movie can be used with different XML files?
ASKER CERTIFIED SOLUTION
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How do I use the string in my Active Script?
Ok. I found the example code. Amazing what you'll see when you scroll down. I tried the example as shown, but it didn't work for me. I might be doing something wrong, so here's how I used it:


[Bindable] private var xmlfile:String;
 
private function init():void{
xmlfile=Application.application.parameters.xmlfile;
}
 
Security.allowDomain("*");
private var photoCounter:Number = 0;
private var photoXML:XML = new XML();
private var totalPhotos:int;
private function loadPhotosXML():void {
var myLoader:URLLoader = new URLLoader(myXMLURL);
var myXMLURL:URLRequest = new URLRequest("{xmlfile}");
myLoader.addEventListener("complete", xmlLoaded);
myLoader.load(myXMLURL);
}

Open in new window

Did you add the preintialize="init()" to the application tag?
Yes. Still didn't work. Works less now than it did. Now the movie doesn't anything, just gives me a grey box.

Here's the application tag:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="225" height="242" creationComplete="loadPhotosXML()" borderStyle="solid" borderColor="#000000" borderThickness="2" backgroundGradientColors="[#CC99FF, #CC99FF]" preinitialize="init();">

Open in new window

Oh My God this is crazy I tried for 25 mins for this stupid thing :P

Just add "FlashVars", "xmlfile=http://www.nakdtree.com/sl_slideshow/assets/xml/Photos.xml"

to both

AC_FL_RunContent() methodss in the  HTML and the above code will work as is please try :)
Ok. Either I'm an idiot, or I'm stupid. I can't get it to work. How should I be placing the variable in my code?

This is what I have:

var myXMLURL:URLRequest = new URLRequest("http://www.mydomaincom/sl_slideshow/assets/xml/${xmlfile}");
First of all please check if you are getting xmlFile correctly and get the URL request

Alert.show("XML FIle:"+xmlfile);
var myXMLURL:URLRequest = new URLRequest(xmlfile);

It worked before I started trying to make it dynamic.
I didn't get you dynamic in the sense your don;t even want to specify the xmlFile URL in HTML you want to pass it as query String param??

Can you please tell me what is happening currently?? is it able to get the xmlfile param??? is that Alert msg showing something or not?
I apologize. You were right. I should have just done what you asked.

Here's the results:  XML File:null

What do you think is wrong?
can you please check a method starting with AC_FL_RunContent (this is a java script method)  in your html page inside which the Object / embed for the Flex swf.

ans see if you have

"FlashVars", "xmlfile=http://www.nakdtree.com/sl_slideshow/assets/xml/Photos.xml"

that must do it.

please refer this he has clearly shown all the files. both mxml and html for more details if needed.

http://blog.flexexamples.com/2007/08/07/grabbing-flashvars-from-the-embedding-html-template/

I went through everything verifying the URLs were correct. I found a couple spots where there were typos, fixed them, and everything works like a charm. Than you for sticking with me all day. The points are your's -- you've been a tremndous help. Hope you have a great weekend.
Thank you again for all your help.