topical media & game development
actionscript-application-photoshow-com-asfusion-controls-XMLPhotoshow.mx
actionscript-application-photoshow-com-asfusion-controls-XMLPhotoshow.mx
[swf]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:controls="*"
horizontalCenter="0" top="30">
<mx:HTTPService id="xmlService" result="xmlReceived(event)" method="post" resultFormat="e4x" />
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
//import com.asfusion.controls.PhotoshowImage;
private var _xmlFile:String;
public function set xmlfile(value:String):void {
//status.text += value;
_xmlFile = value;
//make http request.
getXML();
}
private function getXML():void{
xmlService.url=_xmlFile;
// status.text += " send";
xmlService.send();
}
//function that gets called when the xml file arrives and needs to be parsed.
private function xmlReceived(result:ResultEvent):void{
xmlSource = XML(result.result);
//status.text += " received";
}
//public setter for xmlSource. Typically called by xmlReceived when the xml file
// has been loaded, but it can be used to set the xml directly
public function set xmlSource(xml:XML):void{
var index:int = 0;
var pictures:Array = new Array();
//status.text += " process";
for each( var image:XML in xml..image ) {
pictures[index] = new actionscript_application_photoshow_com_asfusion_controls_PhotoshowImage();
pictures[index].name = image.itemName;
pictures[index].caption = image.itemCaption;
pictures[index].width = image.itemWidth;
pictures[index].height = image.itemHeight;
index++;
}
photoshowContainer.dataProvider = pictures;
}
]]>
</mx:Script>
<controls:actionscript_application_photoshow_com_asfusion_controls_Photoshow id="photoshowContainer" />
</mx:Canvas>
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.