开发者

When is the right point (from the life cycle view) to set data provier for LIST container on Flex 3

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 s开发者_开发百科ee it in debug).

What am I doing wrong?????

Thanks guys...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜