First up, Flex is doing more work for you than you realize - the lastResult attribute has been marked with [Bindable] metadata which asks the mxmlc compiler to generate some code to ensure that change events are propagated to interested listeners. For a simplified explanation of what happens in your particular case - when the asynchronous result event comes back from the HTTPService it updates its lastResult property which in turn dispatches a change event which, thanks to some code generated by the mxmlc compiler, propagates this update to the dataProvider property of the AreaChart.
 
Note the clues from the previous paragraph - results from things like HTTPService or URLLoader are asynchronous so they too rely on you dealing with events (specifically RPC result or fault events). You must understand events and listeners if you want to achieve the same effect manually.
 
You can use the ActionScript API for HTTPService yourself - just import mx.rpc.http.HTTPService and instantiate an instance of the class yourself and call send() just as you did on the equivalent MXML component.
 
Alternatively, if you really do want to use URLLoader directly then you'll have to add your own event listeners (see flash.net.URLLoader.addEventListener) to listen for the "complete" event and then set the AreaChart's data provider with the value of the URLLoader.data property manually.
 
Finally, if you find something that could be improved in the documentation the best way to help is to leave constructive criticism on the live docs for the online version of Flex 2 manual.
 
Pete
 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sam
Sent: Sunday, October 08, 2006 12:26 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] XML as a dataprovider

Hi,
I'm trying to use XML as a dataprovider to charts and the short
useless blurb in the flex 2 manual isn't helping. If I use
<mx:HTTPService to get my xml then bind that to the dataprovider to a
<mx:AreaChart it works fine:

<mx:HTTPService id="getXML"/>
...
<mx:AreaChart width="100%"
dataProvider="{getXML.lastResult.xport.data.row}">
...

Where the xml is in the form of:

<xport>
<data>
<row/>
...
</data>
</xport>

But if I try to assign the dataprovider dynamicly in actionscript
using a urlloader/urlrequest then doing a :

myXML = XML(myLoader.data);

as the docs suggest I can't just go:

myChart.dataProvider = myXML

Or any part of myXML like myXML.xport.data.row

Is there a way to stick myXML into the dataprovider or is the correct
way to go through all this MXML (I'd rather use AS)?

Thanks

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to