Starting with an empty dataProvider for a <List>

Posted by tictac on Stack Overflow See other posts from Stack Overflow or by tictac
Published on 2010-05-25T06:53:40Z Indexed on 2010/05/25 7:01 UTC
Read the original article Hit count: 214

I'm using a List which I need to be empty at the start. I'm adding items to it as needed by clicking a button. Since it's empty, I haven't added a dataProvider property

<s:List id="thelist" itemRenderer="listIR" />

To add an item, I'm adding it to the dataProvider directly

thelist.dataProvider.addItem()

but when I do that, it gives me this error

 #1009: Cannot access a property or method of a null object reference.

Also I have a debugging Alert in the listIR itemRenderer itself and I see that when the list is created, I get that alert twice as if 2 itemRenderers were created, even though the list is supposed to be empty at the start.

Any ideas what's wrong with this itemRenderer? How do I start with an empty dataProvider and add items smoothly to it?

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3