Best way to implement custom code in a openfl class?

I added a Eventlistener-Counter code directly in DisplayObject.hx.
All works fine and i can see in the logs when i miss to remove an EventListener.

But modifying DisplayObject.hx directly means i have to add my code for every new openfl release.

What is a better way to do this?

You could put this in a custom class that extends Sprite, if you wanted, or if the code is useful enough, we might consider adding certain functionality behind a define (such as -Dopenfl-debug-listeners with #if openfl_debug_listeners wrapping the code), but this seems like something that might be more of a one-time thing to do?

I thought i would need the additional code in more classes than Sprite, thats why i chose DisplayObject as the common base to implement my code.
But as it turns out, i only do use Spriteā€¦ -> MySprite it is :wink:

Its just some simple testcode, i collect all added Eventlistener with their PosInfos in an Array and remove them on removeEvent.
Still its a nice way to see, which Events(and where) got forgotten to be removed.