<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
private var alert:Alert;
private function loadGallery(src:String):void {
httpService.url = src;
httpService.send();
}
private function httpService_fault(evt:FaultEvent):void {
var title:String = evt.type + " (" + evt.fault.faultCode + ")";
var text:String = evt.fault.faultString;
alert = Alert.show(text, title);
xmlListColl.removeAll();
}
private function httpService_result(evt:ResultEvent):void {
var xmlList:XMLList = XML(evt.result).images.image;
xmlListColl = new XMLListCollection(xmlList);
}
]]>
</mx:Script>
<mx:XMLListCollection id="xmlListColl" />
<mx:HTTPService id="httpService"
resultFormat="e4x"
fault="httpService_fault(event);"
result="httpService_result(event)" />
<mx:ApplicationControlBar dock="true">
<mx:Button label="gallery 1"
click="loadGallery('gallery1.xml');" />
<mx:Button label="gallery 2"
click="loadGallery('gallery2.xml');" />
<mx:Button label="gallery 404"
click="loadGallery('gallery404.xml');" />
</mx:ApplicationControlBar>
<mx:TileList id="tileList"
dataProvider="{xmlListColl}"
itemRenderer="TileListItemRenderer"
columnCount="3"
columnWidth="150"
rowCount="2"
rowHeight="100" />
</mx:Application>