Creating Custom Spark Components in Flex 4

30
Creating Scalable Custom Components in Flex 4 using Spark Dan Orlando

description

Presentation from Dan Orlando on building scalable custom components using Spark architecture in Flex 4 at Flash Camp Phoenix on 1/29/10.

Transcript of Creating Custom Spark Components in Flex 4

Page 1: Creating Custom Spark Components in Flex 4

Creating Scalable Custom Components in Flex 4 using Spark

Dan Orlando

Page 2: Creating Custom Spark Components in Flex 4

Who is Dan Orlando?• Universal Mind Consultant• Adobe Community Professional• Preacher of best practices with Flex• Author (latest: Flex 4 in Action)• Blog-banger (danorlando.com)• Master DJ• Entrepreneur• Flex Jedi

Page 3: Creating Custom Spark Components in Flex 4

Flex 4 is coming!

Page 4: Creating Custom Spark Components in Flex 4

Welcome to Spark!

• Not a death sentence for Flex 3 apps• Builds on Flex 3 component architecture

(UIComponent)• More Stable & Scalable• Structurally and organizationally superior• Design patterns• Separation of concerns• Code reusability (for real this time!)

Page 5: Creating Custom Spark Components in Flex 4

Will the real MVC please stand up?

Tight Coupling + dependecies

= “domino effect”

Page 6: Creating Custom Spark Components in Flex 4

Controversy in the Community

micro-architectures

design patterns

best practices

Page 7: Creating Custom Spark Components in Flex 4

Anatomy of a Flex 4 Application

Page 8: Creating Custom Spark Components in Flex 4

Spark Component Anatomy

"The general rule is any code that is used by multiple skins belongs in the component class, and any code that is specific to a particular skin implementation lives in the skin."

Page 9: Creating Custom Spark Components in Flex 4

Spark Architecture

Page 10: Creating Custom Spark Components in Flex 4

Ely’s Reveal (MAX ’09)

Dan’s Reveal (Ely’s Reveal, simplified for Flex 4 in Action, ‘10)

Page 11: Creating Custom Spark Components in Flex 4

“Drop down and reveal”

Page 12: Creating Custom Spark Components in Flex 4

“Slide out and reveal”

Page 13: Creating Custom Spark Components in Flex 4

“Pop a wheelie and reveal”

Page 14: Creating Custom Spark Components in Flex 4

Reveal Structure

Page 15: Creating Custom Spark Components in Flex 4

Skin States and Skin PartsCOMPONENT

Page 16: Creating Custom Spark Components in Flex 4

States and Parts

States: defined in the component, controlled by the skin

Parts: defined in the skin, controlled by the component

Page 17: Creating Custom Spark Components in Flex 4

Skin States

SKIN

Page 18: Creating Custom Spark Components in Flex 4

Skin PartsSKIN

Page 19: Creating Custom Spark Components in Flex 4

Declaring the [HostComponent]

This tells the skin what component to apply itself to.

Page 20: Creating Custom Spark Components in Flex 4

This is a composite component!

STOP STOP

Hammer Time

Page 21: Creating Custom Spark Components in Flex 4

Simple vs. Composite

Composite: derived from composition; composed of more than one simple component

Simple: Basic control or container; example: Canvas, Label, Button, ComboBox

Page 22: Creating Custom Spark Components in Flex 4

Simple Component SkinningSKIN

Page 23: Creating Custom Spark Components in Flex 4

Declaring the [HostComponent]

Example: the “openButton” skin:

Page 24: Creating Custom Spark Components in Flex 4

Binding skins with CSSAPPLICATION

Page 25: Creating Custom Spark Components in Flex 4

Properties COMPONENT

Page 26: Creating Custom Spark Components in Flex 4

Method OverridesCOMPONENT

Page 27: Creating Custom Spark Components in Flex 4

Animation & EffectsSKIN

Page 28: Creating Custom Spark Components in Flex 4

Summing it up…

The component class must: 1. Define the skin(s) that correspond to it2. Identify skin parts with the [SkinPart] metadata tag3. Identify view states that are supported by the component

using the [SkinState] tag

The skin class must:4. Use the [HostComponent] metadata tag to specify the

corresponding component5. Declare view states and define their appearance 6. Define display information of skin parts

Page 29: Creating Custom Spark Components in Flex 4

Custom Flex 4 Component Resources

• Ryan Stewart:http://blog.digitalbackcountry.com/2009/07/building-custom-components-in-flex-4-skinparts/

• Dan Orlando:http://danorlando.com/?p=379

• Pete DeHaan:http://blog.flexexamples.com/

• Chet Haase:http://graphics-geek.blogspot.com/

• Flex 4 in Action (ch. 17)Orlando, Ahmed, Bland, Hooks (coming soon)

Page 30: Creating Custom Spark Components in Flex 4

Flex 4 is not as scary as Ozzy trying to be scary after all, so have fun Flexing!!!