Assuming that your event handler is a method of some component, you can
use 'this' inside the handler to get a reference to that component. (You
can also directly access any of the component's instance variables from
inside your event handler.) Since you've probably declared the
ArrayCollection and the collectionChange handler in the same component,
the owner is simply 'this'.
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of williamkusumo
Sent: Monday, August 27, 2007 5:32 PM
To: [email protected]
Subject: [flexcoders] Problem with ArrayCollection inside an Object



I think this might be a classic programming questions rather than
Flex's.

I have a custom Object with an ArrayCollection as one of its property.
I added a COLLECTION_CHANGE listener on that ArrayCollection. In its
handler function, I need a reference to the object that contains the
ArrayCollection.

Yes, I could've had the object as a global instance so I can access it
directly in the function, but another caveat to this is there could be
several of these objects, and looping through them one by one to find
if they own a particular ArrayCollection might not be a choice.

Is there another way to somehow obtain a reference to the
ArrayCollection owner's object?

Thanks!



 

Reply via email to