views:

37

answers:

1

Hello again,

I'm making a LIST container with my own item renderer to display xml file.

Now, I'm overriding the public override function set data(value:Object):void method in my item renderer, the problem is that this function been called many times(!!) (more then the data provider length).

Maybe I'm not setting the data provider right, here is how I do it:

First declare bindable property:

[Bindable]
private var _listDataProvider:XMLListCollection;

Then, creating LIST object:

<mx:List id="list" dataProvider="{_listDataProvider}" itemRenderer="myItemRenderer" />

Then, loading the xml (with urlLoader) and in the result doing:

_listDataProvider = new XMLListCollection(xml..Person);

The XMLListCollection build-up ok (I can see it in debug).

What am I doing wrong?????

Thanks guys...

+1  A: 

It looks right to me, I have a feeling the Flex 3 List and related dataProvider components will set the data a few times for each item renderer the first round (inefficiencies in the framework). The first time, they might set it to null (is that happening?), then the next time they might set it to the value.

To get around this, just do something like:

public function set data(value:Object):void
{
    if (super.data == value) 
        return;
    super.data = value;
}

That should do the trick.

viatropos