Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Flex/Actionscript External XML Scope Issue

Avatar

Avatar
Level 1
loretz
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
loretz
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
loretz
Level 1

03-09-2008

I am processing an external XML file in an event listener
after the URLLoader is complete. The issue I'm having is that I
want getProduct() to return the XML data. How can I get the data
from the event listener getXML(). I tried creating a public
variable outside of the functions but I can't access it from within
the two functions.



package messages

{

import flash.events.Event;

import flash.net.*;



//Returns the current product

public class FetchXMLData

{

public static function getXML(e:Event):void {



var myProduct:XML = new XML(e.target.data);

trace(myProduct.product);

}



public static function getProduct():XML{



var loader:URLLoader = new URLLoader();

loader.addEventListener(Event.COMPLETE,
FetchXMLData.getXML);

loader.load(new URLRequest("
http://www.example.com/api"));



var myProducts:XML = new XML();

//get the value from the listener?!

return myProducts;

}

}

}