Wednesday, July 2, 2008

flex reading data from XML url



This is how the Config.xml looks like:
<?xml version="1.0" ?>
<config channelName="zee" bgColor="0xcc0066"
gridNumRows="3" gridNumCols="3" />

This example shows how to read the attributes of
an XML node.



<mx:HTTPService id="readConfig"
url="Config.xml" resultFormat="xml"
result="showClips(event)"/>
<mx:script>
<![CDATA[
import mx.rpc.events.ResultEvent;

[Bindable]

[Bindable]
private var configParams:XML;

private function showClips(event:ResultEvent):void {
configParams = (XML)(event.result);
mainGrid.rowCount = (int)((int)(configParams.@gridNumRows)-(int)('0'));
mainGrid.columnCount = (int)((int)(configParams.@gridNumCols)-(int)('0'));
cnLabel.text = configParams.@channelName;
}

No comments:

Blog Archive