Introspective Event Handling For Flex SkinnableComponents
So the Flex Spark architecture promotes the separation of a component model/controller from its view, or in Flex lingo, its skin. Here is the PITA process that I go throughout when creating a skinnable component manually: I create an ActionScript class (the host component) that subclasses SkinnableComponent. I define and annotate the skin parts. I try to define the skin part types to be as high as possible in the class hierarchy. What I mean by that is instead of defining a part to be of type Button, I make it of type ButtonBase. I override the partAdded function and add all the event listeners for each part, as event handling should be done in the host component not in the skin. I override the partRemoved function and remove all the added event listeners, as I want to be a “good citizen”. I create a subclass of Skin and associate it with the host component. I add the skin parts and any graphic elements to make it “pretty”. I “ClassReference” the skin to its host component as ...