Proper cleanup of custom cell renderer

By rocker | Jul 5, 2009

actionscript3

So I have a tilelist with a custom cell renderer, which is a movie clip with ICellRenderer implemented. I have all sorts of buttons, loaders, event listeners and timers in this custom cell renderer movie clip - in all it is a complicated cellrenderer.

When the tilelist is destroyed, I want to clean up all the cells, remove event listeners, stop timers etc so that these cells are properly garbage collected. The problem is, there is no way to call any method of these individual cells.

- Ideally, a solution would be to write a destructor function which does the job, but no- AS3 won’t make your life that easy.
- I could have cleaned up when REMOVED_FROM_STAGE event fires in the cells, but strangely, this is fired so many times (with a button press etc) that I can not use it reliably.
- Calling tilelist.dataProvider.removeAll() merely sets the dataProvider to an empty array; doesn’t help in cleaning up the items.

I have ran out of ideas. I have been struggling with this for several days without anything working. Can anyone please help me understand how can I cleanup the cells of a tilelist properly?

actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0