My session notes from Flash Midlands in Birmingham (UK) 16th June 2009.
An introduction to declarative graphics and skinning for Flex applications using Degrafa and the new FXG format.
6. What is Degrafa?
Create graphics via MXML
Easier than using drawing API directly
Reduce / eliminate external assets
Very powerful
Retain control & precision
Bindable properties
“not just lls and strokes! ”
7.
8. How does it work?
You need something to draw onto
Surface - extends UIComponent
or MXML component like:
or advanced CSS using CSSSkin
9. What can it do?
Draw shapes
<degrafa:Circle radius="30" />
Fills - solid, gradient, bitmap, blends
<degrafa:SolidFill color="#FF0000" />
Transformations
<degrafa:RotateTransform registrationPoint="center" angle="45" />
10. Simple example,
Draw a red circle on screen:
<degrafa:Surface>
<degrafa:fills>
<degrafa:SolidFill id="redFill" color="#FF0000"/>
</degrafa:fills>
<degrafa:GeometryGroup>
<degrafa:Circle radius="50" fill="{redFill}"/>
</degrafa:GeometryGroup>
</degrafa:Surface>
11. De ne,
In CSS we set the skin class:
.preItem {
borderSkin: ClassReference("skins.PreItemPanel");
}
18. Spark & Flex 4,
New component architecture
Skin separate to behaviour
Extended States model
Metadata key to new architecture
Use of FXG for visual creation
19. What is FXG?
Declarative graphical tag library
XML based
Primitives, text, transformation
Interchange format - Catalyst & CS
Mirrors FP10 rendering model
20. Simple example,
Draw a red circle on screen:
<s:Graphic>
<s:Group>
<s:Ellipse width="100" height="100">
<s:fill>
<mx:SolidColor color="#FF0000" />
</s:fill>
</s:Ellipse>
</s:Group>
</s:Graphic>
21. What skin?
Associate component with skin (CSS):
Button {
skinClass: ClassReference('spark.skins.default.ButtonSkin")
}
or inline:
<s:Button skinClass="skins.PreButton" label="Button"/>
25. States,
Extended from MXML.
Better for skin development
<s:states>
<s:State name="up"/>
<s:State name="over"/>
<s:State name="down"/>
</s:states>
<s:GradientEntry color="#858585" color.over="#F7F7F7" ratio="0" alpha="0"/>
26. HostComponent,
Metadata link to component
<fx:Metadata>[HostComponent("spark.components.Button")]</fx:Metadata>
To get properties of skin’s host
No code hinting in IDE yet
<SolidColor color="{hostComponent.backgroundColor as uint}" />
30. Halo & Spark,
Can co-exist
Use CSS Namespace
Skin Halo by extending SparkSkin
Halo navigators must have Halo
container as child
31. Round up,
Degrafa
easy to use, renders well,
data visualisation extensions
Not fully integrated, still beta
FXG
Catalyst & CS Suite will aide creation
integrated with FP10
lacking some extra of Degrafa