Flex 4 Skinning - Nashville Flex Camp

24
SKINNING IN FLEX 4 Mike Orth http:/mikeorth.com

description

Presentation on Skinning in Flex 4 from the Adobe User Group Tour, Nashville Flex / Flash Camp. This covers the basics of what has changed, new css styling support, and creating custom Spark skins.

Transcript of Flex 4 Skinning - Nashville Flex Camp

Page 1: Flex 4 Skinning - Nashville Flex Camp

SKINNING IN FLEX 4

Mike Orthhttp:/mikeorth.com

Page 2: Flex 4 Skinning - Nashville Flex Camp

Disclaimer

This is all based on Flex 4 Beta 1 Some things may change

spark.skins.default.* package changed to spark.skins.spark.* on Monday, June 15.

Page 3: Flex 4 Skinning - Nashville Flex Camp

Concepts

Types of Skins / Spark vs. Halo CSS Creating/Applying Skins Examples QA

Page 4: Flex 4 Skinning - Nashville Flex Camp

What is Skinning?

Skinning is the process of changing the appearance of a component by modifying or replacing its visual elements.

The skin controls all visual elements of a component, including layout.

Page 5: Flex 4 Skinning - Nashville Flex Camp

Importance of Skinning

Branding Sets your application apart from others User Experience Great skinning makes you forget it’s a Flex

app Cool != functional

Page 6: Flex 4 Skinning - Nashville Flex Camp

Halo vs. Spark

The Halo theme has “the Flex look”

Mostly backwards compatible with Flex 3

Spark is the new theme

Page 7: Flex 4 Skinning - Nashville Flex Camp

Types of skins

GraphicalArtwork, PNG, GIF <mx:Button upSkin="@Embed(source=‘up_skin.gif')”/>

ProgrammaticExtend ProgrammaticSkin, UIComponent,

Border, etc..Drawing APIoverride updateDisplayList

Page 8: Flex 4 Skinning - Nashville Flex Camp

Types of skins

StatefulOne file containing all states (up, down,

disabled, etc…), usually a .swc file.Create assets and package them (CS3 or

4)Spark Skins are Stateful skins

Page 9: Flex 4 Skinning - Nashville Flex Camp

CSS – New Additions

Namespaces ID Selectors Descendant Selectors Pseudo Selectors

Page 10: Flex 4 Skinning - Nashville Flex Camp

CSS

Namespaces@namespace mx "library://ns.adobe.com/flex/halo";@namespace s "library://ns.adobe.com/flex/spark";

s|Button { color: #FF0000; }

mx|Panel { styleName: “myStyle”;}

Page 11: Flex 4 Skinning - Nashville Flex Camp

CSS

ID selectors

#submitButton { color: blue;}

Descendant Selector

s|Form s|TextInput{ font-weight: bold;}

Pseudo/State selectors

s|Button:over { alpha: 1; }

Page 12: Flex 4 Skinning - Nashville Flex Camp

Examples

Page 13: Flex 4 Skinning - Nashville Flex Camp

Creating Spark Skins

Page 14: Flex 4 Skinning - Nashville Flex Camp

Spark Skinning

Spark Skins & Containers Skinning Contracts Applying Skins

Page 15: Flex 4 Skinning - Nashville Flex Camp

Spark Skinning

Page 16: Flex 4 Skinning - Nashville Flex Camp

Spark Skinning

In Flex 4, Skins are more powerful (you must decide to use it for good or for evil)

Created in MXML, Skin includes

○ Text○ Images ○ FXG graphics○ Transitions○ Filters○ States

Page 17: Flex 4 Skinning - Nashville Flex Camp

Containers

GroupsLightweight, simply a mechanism to layout

visual childrenNot Skinnable

Spark ContainersUse as base class for skinning containersSkinnableComponent, SkinnableContainerLayout children using contentGroup

Page 18: Flex 4 Skinning - Nashville Flex Camp

Skinning Contracts

A skinning contract between a skin class and component class defines how the component displays its skins.

Valid contract contains:Host ComponentSkin PartsSkin StatesA bowl of only Brown M&M’s

Page 19: Flex 4 Skinning - Nashville Flex Camp

Skinning ContractsSkin Class Host Component

Specify the host component.

Declare the skin states, and define their appearance.

Define the appearance of the skin parts.

Define the skin class Identify the skin

states that it supports with the SkinStates metadata tag.

Identify the skin parts that it uses with the SkinPart metadata tag.

Page 20: Flex 4 Skinning - Nashville Flex Camp

Example Usage<s:Skin>

<Metadata> [HostComponent("spark.components.Button")] </Metadata>…<s:states>

<s:State name=“up”/><s:State name=“down”/>…

</s:states>// Define appearance…

</s:Skin>

Page 21: Flex 4 Skinning - Nashville Flex Camp

FXG

Graphics interchange format Defines shapes using mark-up Rect, Circle, Path

Page 22: Flex 4 Skinning - Nashville Flex Camp

Skin states

alpha=“.8” alpha.over=“1” includeIn / excludeFrom

Page 23: Flex 4 Skinning - Nashville Flex Camp

References

http://mikeorth.com http://livedocs.adobe.com/flex/gumbo/html/ http://danorlando.com/?p=374

Page 24: Flex 4 Skinning - Nashville Flex Camp

Thanks!