Sunday, September 25, 2011

Understanding Spark Skinning - PART 1

Introduction to Skinning
In my previous post we saw the basic difference between skinning between Flex 3 (Halo) and Flex 4(Spark). Let us further delve into the world of Spark Skinning. I'll go through this in a 3 part series where we'll discuss the basics of skinning and put together an example.


An important thing to note before proceeding is that, while skinning spark components is that though it may look a bit difficult and time consuming, it is actually quite simple.

Skinning Contract
Skinning spark components starts with a Skinning Contract. The Skinning Contract between the skin class and the component class defines the set of rules that each class must follow in order to ensure communication between them.
The skinning class part of the contract tells that the Skin Class must do the following
  • Specify the host component
  • Declare the skin states
  • Define appearance of skin parts
  • Optionally bind data defined on the host component
The host component must
  • Identify skin states with metadata
  • Identify skin parts with metadata
  • Define data that is bound to the skin class
The compiler validates the HostComponent , SkinPart and SkinStates in the skin class. So, all the states and the skin parts that are there on the host component must be declared in the skin class.
A skin can be applied to a component only after a valid contract is established between the two.

No comments :