• Save
What’s under your skin
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

What’s under your skin

on

  • 2,050 views

Best practices for Flex components with skins and layouts

Best practices for Flex components with skins and layouts

Statistics

Views

Total Views
2,050
Views on SlideShare
2,050
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

What’s under your skin Presentation Transcript

  • 1. What’s Under Your Skin? Understanding best practices in Flex 4 Skinning Jeff Tapper Digital Primates
  • 2. Agenda
    • Review the Spark Component Model
    • Describe the roles of a component, layout and skin
    • What goes in a skin
    • SkinState and SkinParts
    • Component / Skin communications
    • Explore a few real skinned components
  • 3. Who am I
    • Jeff Tapper (jtapper@digitalprimates.net)
    • Senior Consultant – Digital Primates
    • Building Internet Applications since 1995
    • Authored 11 books on internet technologies
    • Adobe Certified Instructor for all Flex, AIR, Flash, and ColdFusion courses
    • http://blogs.digitalprimates.net/jefftapper
    • Twitter: jefftapper
  • 4. Who are you
    • Developers who:
      • Have some experience with Flex
      • Want to understand more about Flex 4 skinning
      • Have a sense of humor
    • If this isn’t you, you should just leave
  • 5. Understanding the Spark Component Model
    • Component – what does it do
    • Skin – what does it look like
    • Layout – how are children arranged
  • 6. Components
    • Raw Logic
    • No Layout
    • No UI
    • Component delegates layout and look to other classes
    • Ponder the List (mx.controls.List vs spark.components.List)
  • 7. Layouts
    • Component Agnostic
    • Responsible for positioning children
    • Optionally implementing virtualization
      • updateDisplayList checks useVirtualLayout
      • VerticalLayoutSample:
        • if (useVirtualLayout)
        • updateDisplayListVirtual();
        • else
        • updateDisplayListReal();
  • 8. Skins
    • Responsible for entire look and feel of component
    • Component specific
    • Component dictates required elements (skinparts / skinstates)
  • 9. Skins vs Styles
    • In Flex 3, far more control was available from style sheets
    • Flex 4 components expose less control to CSS
      • Assumptions are that more will be done in skins
    • Font related styles still available from CSS
    • Your skins can expose additional styles
    • More info: http://www.jamesward.com/2010/07/30/how-to-define-styles-on-skins-in-flex-4/
  • 10. Adding CSS Support
    • Add metadata to the component
      • [ Style(name="backgroundColor", type="uint", format="Color")]
    • Leverage getStyle() in the skin
      • <s:Rect width=&quot;100%&quot; height=&quot;100%&quot;>
      • <s:fill>
      • <s:SolidColor color=&quot;{getStyle('backgroundColor')}&quot;/>
      • </s:fill>
      • </s:Rect>
  • 11. What goes in a skin
    • Design
      • Borders
      • Backgrounds
      • Dropshadow
      • Etc.
    • Controls (ie. Components)
    • States
  • 12. Understanding skinState
    • Host component has a state, which can (optionally) be passed to skin
      • To notify skin of state change use invalidateSkinState()
      • Be sure to override getCurrentSkinState()
    • UI State changes done in skin, not in component
    • Functional changes done in component, not skin
  • 13. Understanding skinPart
    • Definition of skin properties which can be addressed from component
    • override partAdded/partRemoved method in component
    • Used to allow component to control skin without knowing details of its internals
  • 14. Communicating between component and skin
    • Component passes values to skinparts
      • Best done in partAdded method
    • Skin can address component through “hostCompoment” property, but shouldn’t
      • It just makes you feel icky in the morning
    • Skin parts broadcast events, to which component listens
      • Listeners added in partAdded, removed in partRemoved
  • 15. Architectural Review 1
    • ShoppingList Component
      • Review component code
      • Review skinparts
    • ShoppingList Skin
      • Labels, button and DataGroup
      • DataGroup has itemRenderer
  • 16. Architectural Review 2
    • Skinnable Clock
    • One clock component can have vastly different views
  • 17. Architectural Review #2
    • Clock provides base functionality
      • switch between 12/24 hours
      • Has “clockFace” skinpart (IClockFace)
    • Separate skins for Digital and Analog Clocks
      • Each provides a clockFace
  • 18. DigitalSkin
    • Has background image and DigitalClockFace
    • DigitalClockFace is a SkinnableComponent
      • Requires skinParts for hour, minute and second indicators
      • Uses DigitalClockFaceSkin
    • DigitalClockFaceSkin
      • Renders hour, minute and second indicators
  • 19. AnalogSkin
    • Has background image and AnalogClockFace
    • AnalogClockFace is a SkinnableComponent
      • Requires skinparts for hands
      • Knows how to position hands, for either 12/24 hours
      • Uses AnalogClockFaceSkin
    • AnalogClockFaceSkin
      • Renders analog face
      • Uses a datagroup for numbers
        • Datagroup has custom layout
        • Label Item Renderer
  • 20. Summary
    • Spark component model offers a separation of functionality, layout, and visual appearance
    • Skins contain all visual information
      • May contain other skinnable components which have their own skins
      • Make use of layouts
    • SkinParts are used to facilitate a component populating the elements in a skin