matteok
matteok

Reputation: 2199

AS3 Event Listener for MovieClip alteration

I wonder if it's possible to add an Event Listener to a MovieClip that fires everytime a child is added to it or removed from it.

Is this possible?

Thank you in advance,

Matteo

Upvotes: 0

Views: 81

Answers (1)

turbosqel
turbosqel

Reputation: 1542

You can override addChild / addChildAt and removeChild / removeChildAt functions and dispatch any event You want :

public override function addChild(child:DisplayObject):DisplayObject {
    dispatchEvent(new Event("newChild"));
    return super.addChild(child);
}

Upvotes: 1

Related Questions