Re: [flexcoders] Re: Getting multiple addedToStage events

2008-09-24 Thread Tom Chiverton
On Tuesday 23 Sep 2008, ozziegt wrote: I have been using creationComplete, but there is no way for me to remove the listeners when the object is removed from the stage, which leads to memory leaks. Does 'remove' not do that ? -- Tom Chiverton Helping to biannually compete 24/7 magnetic

Re: [flexcoders] Re: Getting multiple addedToStage events

2008-09-24 Thread Samuel Colak
All objects dispatch FlexEvent.Remove when they are removed from a container - this occurs on the stage and also in Container objects (since Container and Stage both exhibit the same behaviour). The FlexEvent.Remove is a way of trapping the message that an object is being removed by its

Re: [flexcoders] Re: Getting multiple addedToStage events

2008-09-24 Thread Michael Schmalle
Event.REMOVED Containers cannot use this since their child list is not updated. UIComponent listens to the Event.REMOVED and stops propagation of it so there is no way to listen for it. The component will then dispatch FlexEvent.REMOVE at the correct time after child lists are correctly

Re: [flexcoders] Re: Getting multiple addedToStage events

2008-09-23 Thread Tom Chiverton
On Monday 22 Sep 2008, ozziegt wrote: I am using the event so the MXML component knows when it has been added to the stage, and also removed so it can set up and tear down some event listeners appropriately. I normally use creationComplete for setting up the listeners. -- Tom Chiverton

Re: [flexcoders] Re: Getting multiple addedToStage events

2008-09-23 Thread Samuel Colak
Use Event.ADDED_TO_STAGE instead of creation-complete - you can also use init to construct listeners in the MXML although i have seen in the past this occasionally gets messy. The reason behind this is that after the first hit of the event, you dont want it to occur again - in the MXML

[flexcoders] Re: Getting multiple addedToStage events

2008-09-23 Thread ozziegt
--- In flexcoders@yahoogroups.com, Tom Chiverton [EMAIL PROTECTED] wrote: I normally use creationComplete for setting up the listeners. I have been using creationComplete, but there is no way for me to remove the listeners when the object is removed from the stage, which leads to memory

Re: [flexcoders] Re: Getting multiple addedToStage events

2008-09-23 Thread Samuel Colak
Ok - i did a bit of research you can do the following - trap for the notification FlexEvent.Remove which occurs when a child is removed from a container. Other than that im not sure what else to do.. Basically trap this function... my own code already did something similar but this

Re: [flexcoders] Re: Getting multiple addedToStage events

2008-09-23 Thread Samuel Colak
All, Heres a little bit of code i knocked up to demonstrate For MXML - just extend the class and tie into the functions via the override. On another note, you might want to check if the current object contains children - if so remove them before you remove yourself (via the

[flexcoders] Re: Getting multiple addedToStage events

2008-09-22 Thread ozziegt
I am using the event so the MXML component knows when it has been added to the stage, and also removed so it can set up and tear down some event listeners appropriately. Perhaps this isn't the best way to do it. If another way is better, I'm open to hear it. :) Yes the currentTarget is the same