Ok so I have played with event handling in action script couple of times but I have come across this situation where I need to check whether the event in the actionscript is already called or not . the code snippet looks like below:
currentTrajectory = new ArrayCollection(event.result as Array);
if ( _multiTrajectoryEvent is intialized) // this is where I need to check
_multiTrajectoryEvent=new MultiTrajectoriesEvent(MultiTrajectoriesEvent.DRAW_AUTO_TRAJ );
//raise an event to
Every time I get the event result from database and I am adding result to arraycollection of event. However, I want to make sure that event object is created only if it hasn't been initialised before in order to have previous value of array collection isnide the event.
Checking if the event object is null doesn't work and if the event is not initialized I can't check it's bubble property as well...
I would appreciate quick thoughts for the same
Generally, people don't re-use events. I have never seen an event object re-used, potentially it might lead to side-effects if any code handling the event keeps a reference to the event.
My advice is not to recycle event objects. They should be garbage collected when they are no longer used. Create a new one every time. Your custom event has no payload, so I really don't follow the point about needing to re-use them. No use is made of currentTrajectory.
It helped a lot and made my solution much simpler!