Couldn't you put the list component in a movieclip and add attach the movieclip to the scrollPane (which is a lot easier).
Also, what is  your 'createUniqueInstanceName()' function ?

Matt Bennett wrote:
Hello Flashcoders,

I'm building a scrollable list, and I keep track of the list items
with a Collection. I'm having trouble adding items to it - I think I'm
overwriting some instance variables somewhere.

In the code below, listContainer is a reference to the contents of a
ScrollPane component:

var listContainer = scrollPane.content;

Here's my function to add a list item:

      function addListItem(symbolName, props)
      {
              // Create the content (instance name: _itemX)
              var instanceName = this.createUniqueInstanceName();
              var item = listContainer.createClassObject(symbolName,
instanceName,
this.getNextHighestDepth(), props);

              //add to list items
              listItems.addItem(item);

              trace("////////////////////////////////////////////");
              trace("debugging addItem");
              var iterator = listItems.getIterator();
              while(iterator.hasNext()) {
                      var thisitem = iterator.next();
                      trace("this item: "+thisitem+"; type:
"+thisitem.className);
              }
              trace("////////////////////////////////////////////");

              return item;
      }


After adding 3 items, the debug trace looks like this:

////////////////////////////////////////////
debugging addItem
this item: ; type: undefined
this item: ; type: undefined
this item: _level0.QUESTION
PAD.contentWidget.questionList.scrollPane.spContentHolder._item2;
type: View
////////////////////////////////////////////

I assumed that I was overwriting an instance name somewhere, but I
also traced the contents of listContainer with a for-in loop. This is
the output after the first item is added:

////////////////////////////////////////////
this item: 2441; type: undefined; text: undefined
...other irrelevant stuff
this item: true; type: undefined; text: undefined
this item: _level0.QUESTION
PAD.contentWidget.questionList.scrollPane.spContentHolder._item0;
type: View; text: question 1
////////////////////////////////////////////

And this the output after the second item is added:

////////////////////////////////////////////
this item: 2441; type: undefined; text: undefined
...other irrelevant stuff
this item: true; type: undefined; text: undefined
this item: _level0.QUESTION
PAD.contentWidget.questionList.scrollPane.spContentHolder._item1;
type: View; text: question 2
////////////////////////////////////////////

So it looks to me like I'm actually overwriting each _itemX instance
on listContainer - and hence the references in the Collection become
null pointers.

Does anyone have any experience with this?

Many thanks,
Matt.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to