UIComponent VS. ProgrammaticSkin

When i saw this post by Keith Peters i had the idea to turn this into a skin for the flex components.
The problem i found was that if you use a programmatic skin the manual tells you to extend the class mx.skins.ProgrammaticSkin.
This class extends from FlexShape which extends Shape. The problem is that in one skin i need to add more than one Shape but because ProgrammaticSkin is a Shape a can not add new shapes.
I ended up extending my skin from UIComponent which definetly is not the right way. If anyone knows a better way how to create a “complex” skin please comment here.

You can see what i came up with here. (Source enabled)

Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

5 thoughts on “UIComponent VS. ProgrammaticSkin

  1. The Flex framework and components don’t have any hard dependencies on ProgrammaticSkin…typically, our components only require that their skins implement the IFlexDisplayObject interface. ProgrammaticSkin is just a convenient base class to use if you want to write a skin.

    That means that you can write your own skin class based on Sprite, if you need to. So the easiest thing for you to do would be:

    1) grab the source for ProgrammaticSkin out of the framework source.
    2) Save it into a new file of your own choosing .
    3) rename the class to match your new filename.
    4) change the ‘extends Shape’ to ‘extends Sprite’ in your new class.

    Done. Now you’ve got a lightweight skin baseclass that extends the core Sprite object, and can support child objects.

    It’s worth remembering that Flex components…anything that extends UIComponent…must be placed inside of other UIComponents. So if you’re looking to embed _UIComponents_ in your skin, then you still have to use UIComponent as your baseclass.

    Ely Greenfield.
    Architect, Flex SDK.
    Adobe Systems.

  2. Pingback: Tink » Blog Archive » Adding Children to Skins (SpriteBorder & SpriteProgrammaticSkin)

Leave a Reply

Your email address will not be published. Required fields are marked *