////// img.xml /////////
<images>
<image>
<id>1</id>
<filename>image1.jpg</filename>
</image>
<image>
<id>2</id>
<filename>image2.jpg</filename>
</image>
<image>
<id>3</id>
<filename>image3.jpg</filename>
</image>
<image>
<id>4</id>
<filename>image4.jpg</filename>
</image>
<image>
<id>5</id>
<filename>image5.jpg</filename>
</image>
</images>
////// main.mxml ////////
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
private var images:ArrayCollection = new ArrayCollection();
private function loadData():void {
var data:HTTPService = new HTTPService();
data.addEventListener(ResultEvent.RESULT,
function(event:ResultEvent):void {
images = event.result.images.image;
var a:Array = new Array();
// here's the important part, using the for each loop to access the loaded data
for each (var item:Object in images) {
item['filename'] = item['filename'];
a.push(item['filename']);
}
trace(a);
}
);
data.url = “img.xml”;
data.send();
}
Output would be:
image1.jpg, image2.jpg, image3.jpg, image4.jpg, image5.jpg
|