--- In [email protected], "spirit_ryder2k"
<[EMAIL PROTECTED]> wrote:
>
> Hi, I'm doing a small app which loads a list of songs from an XML 
> and display it in a list. I'm using a TileList with a custom 
> renderer to render the songs. Because I want to keep track which 
> song has loaded I put a trace comment on the creation event. This 
> all works as intended, the song list has 2 items and 2 item are 
> displayed on screen. But I get 3 traces. It seems that the TileList 
> creates 3 objects but only shows 2.
> 
> Any suggestions on how to make sure it only loads 2 objects? It 
> seems like the first item in the XML list is created twice :(
> 
> Source code below:
> 
> Song1.xml
> -------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <song>
>       <track>
>               <name>We are broken</name>
>               <url>../Paramore - We Are Broken.mp3</url>
>       </track>
>       <track>
>               <name>Pressure</name>
>               <url>../Paramore - Pressure (Acoustic).mp3</url>
>       </track>
> </song>
> -------------------------
> 
> renderer.mxml
> -------------------------
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Label xmlns:mx="http://www.adobe.com/2006/mxml"; 
> creationComplete="trace('new song ' + data.name)" 
> text="{data.name}"/>
> -------------------------
> 
> test.mxml
> -------------------------
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
> layout="absolute" creationComplete="SongServ.send()">
>       <mx:HTTPService id="SongServ" url="../Song1.xml" />
>       <mx:TileList direction="vertical" itemRenderer="renderer" 
> dataProvider="{SongServ.lastResult.song.track}"  left="10" top="10" 
> right="10" height="200"/>
> </mx:Application>
> -------------------------
>

Ok, I've runned into this issue a few weeks ago and Alex Harui,
adviced me to use the rowHeight and set it a value, the flex will now
how to render the lines without creating an extra item. however you'l
still get duplicates first time you trace because of the binding which
will fire twice, and I don't think you can do something about it. You
could unmarshall your XML into objects and reuse those objects if they
already created/ only create them when not already created and then
the binding will fire only when the value of the object is changed.

Hope this helps,
Claudiu.


Reply via email to