I've been experimenting with a couple of classes that extend Canvas
and realize I need to get some basic information sorted out. I've done
quite a bit of googling, looking through examples, and checking
Adobe's documentation. Somehow I've lost the plot. Briefly, my
questions are:

* How do people normally track references to dynamically created objects?
* If you add an object to an array, are you copying a reference or
something bigger in RAM?
* How do you well and truly clear an object?

References to a good, basic demo would be most welcome, too.

Those are the questions, below is the background that leads to the
questions....which may be skipped if the questions alone make sense.

What I've got is a class I've called SearchGroup that extends Canvas.
This is just a bounding container that is meant to coordinate a number
of child containers of calls SearchRow, which also extends Canvas. So,
there is one SearchGroup with 1 or more SearchRow instances. I'm going
everything in ActionScript rather than MXML as I'm trying to get
comfortable with AS.

  When a SearchRow is created, it should go at the bottom of the
SearchGroup canvas (visually).
  When a SearchRow is deleted, any rows below it should be moved up.

That's about all I'm trying to do at the moment and there are probably
better built-in widgets to use. My main problem is sorting out how you
properly create, track, and delete objects. My main application has an
initApp() like so:

                        public function initApp() : void {
                                this.addChild(searchArea.addRow());
                                this.addChild(searchArea.addRow());
                                this.addChild(searchArea.addRow());
                                }

Whenever addRow() is called, a row is created, added to the display
list, and some private variables are updated within searchArea (a
SearchGroup):

                public function addRow() : SearchRow {
                        _rowCount ++;
                        var row:SearchRow = new SearchRow(_rowCount);
                        _rowReferences.push(row);
                        return row;
                }

[I figure that SearchRow shold be an inner class of SearchGroup - but
I don't know how to do that in AS. Otherwise, I assume I should put
addRow into SearchRow and then have SearchRow dispatch an
event...which I'm skipping for the moment for simplicity.)

So, when a row is added, the searchArea increments a count and appends
the reference into a private array named _rowReferences. A couple of
questions:

* How do people normally track dynamically created object references?
* When I copy an object into my array, _rowReferences.push(row), am I
copying a _reference_ or something more substantial in RAM?

When I come to delete a row, I'd like four things to happen:
* Decrement the row count - that's easy.
* Remove the reference from the tracking array - that's easy.
* Remove the item from the display list - that's easy, assuming I get
the right parent reference.
* Remove (delete/clear) the row object instance. How do you do that?
I've not found a remove/delete/clear option or operator that appears
to do anything. I'm fuzzy on the AS/Flex garbage collection system, I
expect.

Thanks again for any help! Eventually I'll be able to contribute
answers instead of questions to the list.

Reply via email to