I have a MovieClip that is composed in a parent (non-display object) class. We register an event listener against that movieclip – a CLICK handler for example.
With event.target I can get a reference to the MovieClip from within the event handler. But how can I pull a reference to its composing class?
I could simply add a “parentClass” property on the dynamic MovieClip class, but I’m wondering if there’s a more elegant/idiomatic way of doing it that I should consider?
If the class that creates your MovieClip is not a display object then it cannot really be considered its parent. The parent element will be that which your MovieClip is attached to. All that the creating class contains is a reference to an object, just the same as if you then refer to the MovieClip elsewhere.
My preferred way would be to create a descendant class of MovieClip that can contain a reference to the creating class, which you would then use instead of
MovieClip.