Mike 1.5.2011

Looked in to incorporating KapLab’s Kap Inspect.  It’s a runtime debug tool which lets you look at all existing UIComponents, their current properties, styles, and other items.  Unfortunately it’s written with heavy dependence on Flex 3 and you can’t use it in Flex 4 without making some changes to Flex builder and your sdk directories.  The source is available but very large and I don’t want to spend a week trying to get some cool debug tool to work.

So it turns out Kap Inspect is based on another open source project with a much looser license: FlexSpy.  It has a few less features than Kap Inspect, but works in Flex 4 without any changes and still allows access to styles and properties so I added it to our framework as another debug window.  We may need to hide it when moving to production.

Enter Monkey Patching.  It is apparently possible to inject code in to any existing class by recreating the file in your project, placing it at the same package location, and changing anything inside the file you want.  Your class will the override the Flex library class and any class that extends will inherit your class, not the original one.  Doug Mccune came up with a way to override mx.core.FlexSprite (the base class of all flex components) and add a dictionary which keeps references whenever addEventListener is called.  This allows a debug window to view all event listeners on any component.  So I put together FlexSpy and the monkey patched Flex Sprite to get a very useful new debug window.