I know a bit of converting my XML data into array collection which I can use as DP for my data-based controls.
I want to get some good examples on what Alex posted to convert the xmllistcollection to class instances. I was just thinking cause, xmllistcollection can be definitely bound as a dataprovider to a flex control but if I am going to convert the xmllistcollection to a class instance and use that class as dataprovider for the control, then the overhead may be too much to actually ponder on? ________________________________ From: jamesfin <[email protected]> To: [email protected] Sent: Fri, 30 April, 2010 7:46:57 Subject: [flexcoders] Re: XMLListCollection DataGrid Performance vs Any Other DataProvider Type This code will convert for you... You need to replace the xmllist.myxmldata with your own xml structure names. private function convertXmlToArrayCo llection( myxml:String ):ArrayCollection { var xml:XMLDocument = new XMLDocument( myxml ); var decoder:SimpleXMLDe coder = new SimpleXMLDecoder( ); var data:Object = decoder.decodeXML( xml ); var array:Array = ArrayUtil.toArray( data.xmllist. myxmldata) ; return new ArrayCollection( array ); } A quick follow-up after I made this tweak to use objects vs xml. In my case, performance increased by about 20% when scrolling on a 24" monitor browser full-size by reducing the number of renderers from 10 to 3. I then pre-translated the original xml data in the conversion so that I didn't need to do it with a label function. Performance is now acceptable in full-screen (24") mode. Bottom-line, avoid renderers. Label functions are better but are still taxing on the performance if there is a bunch of computing going on in those functions. Pre-render data when converting from xml to objects. --- In flexcod...@yahoogro ups.com, Alex Harui <aha...@...> wrote: > > I don't know of any links off-hand. I would simply create a class with the > set of properties you are interested in, then take the XML and parse it into > instances of that class. > > You can try to get XMLDecoder to do it, but sometimes it is more efficient > just to write your own converter. > > > On 4/29/10 7:50 PM, "Angelo Anolin" <angelo_anolin@ ...> wrote: > > > > > > > Any link to show us some samples? > > My data is coming from a .NET backend and most of it are in XML format and > parsed into XMLListCollection. > > Would appreciate some more info on this. > > THanks. > > ____________ _________ _________ __ > From: Alex Harui <aha...@...> > To: "flexcod...@yahoogro ups.com" <flexcod...@yahoogro ups.com> > Sent: Wed, 28 April, 2010 21:49:52 > Subject: Re: [flexcoders] XMLListCollection DataGrid Performance vs Any Other > DataProvider Type > > > > > Convert the XML to Class instances. > > > On 4/28/10 10:06 AM, "jamesfin" <james.alan. finnigan @gmail.com> wrote: > > > > > > > Here's the scenario... > > Simple datagrid with XMLListCollection data provider. > > Average collection size is 200 rows of XML (shown below) > > 10 columns in the datagrid with a unique item renderer for each. 1 Column > can display 1 of 10 embedded images depending on an xml attribute. > > AS3-only Renderers are highly optimized. > > Average visible rows = 30 (simultaneously visible rows / meaning at least 300 > renderers being recycled when scrolling? > > Typical XML row data > > <foodata fooid="4997" fooid2="0" fooid3="2909" foot="9" startdate="2010- > 04-09 13:45:00" enddate="2010- 04-09 14:45:00" foost="1" fooname="New Foobar" > foosub="More Foobardata" fooloc="false" fooonly="false" > > </foodata> > > When all said and done being loaded, vertical scrolling is noticeably slow on > a new iMac (Safari or Firefox with latest FlashPlayer) compared to a stripped > down non-XML data provider version which scrolls quickly. > > Googling consensus shows that XMLListCollection is not the optimal > dataprovider in this scenario and that XML in general is not the best choice > if it can be avoided. > > Can anybody shed any light on a better way to improve scrolling performance > based upon this scenario? > > Thanks in advance. > > > > > > > -- > Alex Harui > Flex SDK Team > Adobe System, Inc. > http://blogs. adobe.com/ aharui >

