views:

19

answers:

1

There are lots of examples of how to create skinnable components in AS3 using the new Spark component architecture, however I've yet to find any such examples using MXML.

What I'm mainly referring to is defining the skin parts and skin states. It seems as though the SkinPart metadata is supposed to be associated with properties and as such can't be used in MXML, is this correct?

+2  A: 

As far as I can tell, this isn't possible, because - as you rightly pointed out, there's no way to assign property-level metadata in MXML.

But declaring skin contracts in MXML seems like it would go against the spirit of the Skinning architecture, which is to separate the view of the component from it's implementation logic.

And, given that in MXML everything declared has a value, it inherently couples the component to a skin.

Ie:

<!-- labelDisplay has a value -->
<s:Label id="labelDisplay" />

vs

[SkinPart]
public var labelDisplay:Label; // labelDisplay == null;

Likewise, most of the component logic itself would end up in a <fx:Script /> block, which would probably be better suited in a seperate class.

Marty Pitt
+1 for rightly pointing out that everything declared in MXML has a value. MXML is quite exemplary at defining structure and many times I find myself writing components that does little more than define skin parts and the boilerplate that follows (partAdded, I'm looking at you). Anyway, thanks for confirming my suspicons!
macke