0 Replies Latest reply on Nov 9, 2009 4:34 AM by Daniel Freeman

    An itemRenderer destructor event?  (It's not coming back)

    Daniel Freeman Level 1

      I have custom itemRenderers in which I set up event listeners.

       

      Obviously, when I've finished with an itemRenderer - I want to tidy up.  I want to remove any listeners that were created.

       

      But how do I know if I've finished with an itemRenderer?

       

      I attempted to use the Event.REMOVED_FROM_STAGE event.  But sometimes an itemRenderer instance is reinstated after being removed - which messes things up.

       

      If I listen for EVENT.ADDED_TO_STAGE to enable me to reinstate the itemRenderer, then if I really have removed the itemRenderer permanently - I'm left with a dangling listener that's no longer needed.  With no way of knowing if I can safely remove this listener.

       

      Is there an event that tells me that an itemRenderer is removed AND IT WON'T BE COMING BACK! ?

       

      . . . . . . . .

       

      I suppose one solution is to use the MXML form of a custom itemRenderer...

       

      <mx:AdvancedDataGridItemRenderer addedToStage="addListeners()" removedFromStage="removeListeners()">

       

      ... And then assume that the addedToStage and removedFromStage listeners are tidied-up, leaving no loose ends when the intemRenderer instance is finally removed.

       

      Nevertheless, I would still like to know the answer, so I can accomplish this for a pure ActionScript itemRenderer.

       

       

      Also, what are other developers using?  ADDED_TO_STAGE and REMOVED_FROM_STAGE ?  Or another pair of events that signal creation and removal ?