SlideShare a Scribd company logo
1 of 36
Don’t Just Skin It. Style It! James Polancowww.developmentarc.comFlash Camp Brasil2011
Who am I? James Polanco Web Application ArchitectFlex, Flash, AIR, Ajax... Getting into Scala and Lift Co-founder of DevelopmentArcconsulting and development firm focusing on web applications Author for Adobe Press“Adobe Flash Platform Start to Finish: Working Collaboratively using Adobe Creative Suite 5” Twitter & Website@jamespolancowww.developmentarc.com
What is this session about? Styling a Flex application has many different approachesCSS, MXML properties, Programmatic Skins, 3rd Party libraries (ex: Degrafa) Flex 3 (Halo) vs. Flex 4 (Spark) 	Each Component set (Halo & Spark) has similar and different features to support styling of your Flex components.  Flex 4 (Spark) is changing how we work Changes in the Flex 4 (Spark) component architecture is changing how applications are styled.
Style Support in Flex : Flex 3 (Halo) CSS in Flex 3 Benefits Setting look and feel based on style declarations An extensive set of styles are built into Flex 3 components ex: Button has color, borderColor, backgroundColor, etc... Limitations Only able to change settings that are exposed to the CSS Style system
Style Support in Flex : Flex 3 (Halo) Programmatic Skins in Flex 3 Benefits 	Full Control over all aspects of the design 	Creating backgrounds that can show different component layouts, and add animations… Limitations Requires extensive ActionScript and understanding of the component architecture to implement 	Any design changes must be implemented via code (unless the code implements Flex’s style system) 	Programmatic skins are only defining the background of the component, you can not draw on top of content nor modify children without creating risky direct parent reference
Style Support in Flex : Flex 4 (Spark) CSS in Flex 4 Benefits 	Setting look and feel based on style declarations 	Improved CSS declaration support and advanced language features 	Style names are propagated from the component to the skin  Limitations 	Styles have less support in Flex 4 components 		ex: Button has color but does not support borderColor, backgroundColor, etc…
Style Support in Flex : Flex 4 (Spark) New Skin Architecture in Flex 4 Benefits Replaces Programmatic skin with MXML based skinning system 	Rapidly create and change skins as need 	Separates logic from layout 	You can easily manipulate the components children parts and styles, unlike programmatic skins in Flex 3 Limitations 	Can require development for each layout / design 	CSS support within a skin requires extra development
Understanding Spark (Flex 4) Brief look at the new Flex 4 (Spark) Architecture Creates a separation of layout from logic A Spark component is made up of two parts: the Skin (look & feel) and the backing Component (logic) Allows the look and feel of a component to be changed at runtime Skins are assigned via CSS (skinClass) and can be changed at any time.
Understanding Spark (Flex 4) Brief look at the new Flex 4 (Spark) Architecture
CSS in Flex 4 CSS support still exists in Flex 4 (Spark) components New properties have been created for general themes, such as contentBackgroundColor It’s not as supported as Flex 3 but... Many of the previous Flex 3 CSS properties on the new Flex 4 versions of the components do not exist (yet...) Flex 4 has more CSS features! Many new advanced CSS features, such as ID and pseudo selectors (we will examine this in depth later)
CSS in Flex: What are styles? What are styles? 	Settings of a component that enable the ability to change the look and feel of a component dynamically For example, setting the font color on a button <s:Button color="#FF0000" />
CSS in Flex: Setting Styles Four ways we can set styles in Flex ActionScript setting styles directly in our code MXML setting properties on our MXML components <Style> Blocks defining a style block in our MXML file External Style Sheets linking to external CSS files to define our styles
CSS in Flex: Setting Styles, ActionScript myButton.setStyle("color", 0xFF0000); Styles are not properties of components This means we can’t do things like:  myButton.color = 0xFFFF00 Flex provides a Style Manager The Style Manager handles complex style inheritance and other properties of CSS for us To set a style we use the setStyle() method Because styles aren’t properties and are handled by the Style Manager we use the setStyle() method, whose job is to work with the Style Manager to handle all the complex reltionships
CSS in Flex: Setting Styles, MXML <s:Button id="myButton" color="#FF0000" /> Styles are exposed as properties in MXML 	MXML treats styles as properties of our components MXML hides the fact that styles are not properties on a component MXML and the compiler handle converting our style “properties” into setStyle() commands at compile time
CSS in Flex: Setting Styles, <Style> Block <fx:Style>.myStyle {		color: #FF0000; 	} </fx:Style> <s:Button id=“myButton” styleName=“myStyle”/> A local style definition is created in the MXML and linked through CSS binding techniques 	We can create local style definitions and then apply them to our components (more to come...)
CSS in Flex: External Stylesheets <fx:Stylesrc=“/assets/css/myStylesheet.css” /> <s:Button id=“myButton” styleName=“myStyle”/> Externally referenced style definitions are linked into our MXML and are applied Similar to our local style definition, we can link to external CSS files which are applied
CSS in Flex: Selectors What is a Selector? Defines how a style is applied and in what context There are four selector types in Flex Type Selector Class Selector ID Selector Pseudo Selector
CSS in Flex: Type Selectors What is a Type Selector? Defines global styles for any “type” of component that is created, such as a Button, ComboBox, List, etc... /* All Buttons in our application have their font color set to red: */ 	Button {	color: #FF0000;}
CSS in Flex: Class Selectors What is a Class Selector? Defines styles that must be explicitly referenced by the component using the “styleName” property: ex: <s:ButtonstyleName="myStyle" /> 	/* Only components that reference this style has their font color set to red: */ 	.myStyle {	color: #FF0000;}
CSS in Flex: ID Selectors What is an ID Selector? Components with the explicit ID apply these styles (new in Flex 4) 			ex: <s:Button id=“myButton” /> /* Only components that have id=“myButton” has their font color set to red: */ 	#myButton {	color: #FF0000;}
CSS in Flex: Pseudo Selectors What is a Pseudo Selector? 	Pseudo selectors work in conjunction with other selectors (Type, ID, Class) 	Allows us to changes style based on the current state the component is in (such as a button’s up, over, down & disabled states) 	The component must support the state to apply the style, stateGroups are not supported 	/* Change the color based on state: */ Button:up {	color: #FF0000;} Button:down {	color: #00FF00;}
CSS in Flex: Namespaces What is a Namespace? 	Namespaces are new in Flex 4 and now required for any CSS declarations 	Allow us to support type selectors 	When we say “Button” do we mean Halo or Spark buttons? @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; s|Button {  color: #FF0000; }
CSS in Flex: Chaining Selectors We can now chain selectors Chaining allows us to share properties across different style types s|Button, .blueText, #myLabel { 	color: #0000FF; }
CSS in Flex: Dependent Selectors We can define dependent selectors With a dependent selectors we can apply styles to elements based on their parents, the space between the selectors informs the CSS engine that the style should be applied based on the parent/child relationship s|HGroups|Button { 	color: #0000FF; } <s:HGroup> 	<s:Button id=“myButton” /> </s:HGroup>
CSS in Flex: Linking Selectors We can link type, class and id selectors to identify elements By linking type, class and id selectors together we can explicitly define what and when an element should have a style applied. The style is linked when there is NO space between the selectors S|Button#myButton.labelText { 	color: #0000FF; } <s:Button id=“myButton” styleName=“labelText” />
CSS in Flex: Cascading Cascading is the C in CSS CSS’ (Cascading Style Sheets) power is the ability to define styles and have them apply down the parent/child hierarchy automatically How does it work? Inheritable Styles: If the parent has a style set (such as color) and the child supports the style, then the child’s style is set to the parents value. Inheritance is defined via the [Style] metadata Non-Inheriting Styles: If the parent has the style set and the child supports the style, the value is NOT passed on Global Styles: Flex supports the global tag, which applies this style to EVERYTHING in the application
CSS in Flex: Cascading Chain of Command Understanding the priority order of what style overrides the cascading parents value OR the style definition location is very important Global > Type > Class > ID > local > setStyle() setStyle() overrides a local definition, a local definition overrides an ID definition, an ID definition overrides a Class definition, a Class definition overrides a Type definition and a Type definition overrides a global definition.
Supporting CSS in Flex How do we leverage it in our own components? 	We can support CSS in our custom components by using a combination of Metadata, ActionScript and the new Flex 4 Skin architecture ActionScript Methods Flex provides multiple methods for creating, managing and accessing styles Metadata Metadata allows us to define what styles our components support, how they cascade, their type and their default values  Flex 4 Skins & FXG Flex 4 changes where we manage our styles and also supports a new way to apply and visualize our UI with these style settings
Supporting CSS in Flex: Methods setStyle() The setStyle() method allows us to define a style directly to our component. We pass in a style name and the style value: setStyle("color", 0xFF0000); getStyle() The getStyle method allows us to determine what the current value for the style is: varourColor:Number = getStyle("color"); styleChanged() 	The styleChanged() method is called on our component whenever a defined style is updated. updateDisplayList() The updateDisplayList() method is where we should do all our style calculations and application to our content.
Supporting CSS in Flex: Metadata Metadata informs the compiler and tools (like Flash Builder) what styles are supported Metadata is how MXML can show a style as a property. Without metadata the compiler would not recognize the style property and throw an error at compile time. Styles can still be used without metadata We can still use the ActionScript methods, such as set and get style, even if the metadata isn’t defined. Metadata is defined on the component (ActionScript) class and not a Skin (Flex 4+) The metadata is assigned to the base component and not to a skin, for a component to fully support in MXML it has to be defined on the class: [Style(name="errorColor", type="uint", format="Color", inherit="yes")]
Flex 4: Styling With Skins Creating MXML Skins 	Flex 4 supports creating new looks for components using the skinning architecture. Similar to Programmatic skins, but easier to create and you can use MXML to define them. Setting Skins 	Skins are attached to a component using the skinClass style property, they can be defined in CSS using the ClassReference wrapper. skinClass: ClassReference(”com.example.package.skin.SkinFile"); Swapping Skins 	Because skins are defined via styles we can change them at any time by either referencing a new style declaration or by using setStyle().
Flex 4: CSS in Skins Override updateDisplayList() In the Skin class we can override the updateDisplayList() method and then use getStyle() to retrieve the property values defined for the style. Update the skin with the style values 	Once the values have been pulled from getStyle() we can then apply the values to the parts of the skin that the styles correspond to. Expose style via Metadata on the base component To support style properties in MXML for our skins, the host component the skin is attached to should declare the styles using metadata.
Flex 4: Skin States & CSS States allow the skin to update the look of the UI 	Skin States defined in the host component allow our skins to change the look and feel based on user interaction. Think Button and the up, over, down, and disabled state. Using CSS pseudo selectors enables us to change the style on state changes When we define pseudo selectors ( .myStyle:up{} ) the getStyle() method will return the updated value in the updateDisplayList() method when our states change. This allows us to easily define and support CSS state changes in our skins.
CSS in Skins: Using FXG FXG is Adobe’s new declarative graphics language FXG allows us to create vector based assets in MXML <s:Rect top="0" left="0" right="0" bottom="0">			<s:fill><s:SolidColor id="bgColor" color="#CDCDCD"/></s:fill>		</s:Rect> Modify FXG properties to enable CSS customizable skins When the state changes we can reference and then update the FXG bgColor.color = getStyle("backgroundColor");
Wrapping it up... Flex 4 is adding a lot of styling opportunity Advanced CSS functionality and the new skinning architecture is allowing for easier customization of your application. CSS is currently less prevalent in the current component set 	The current Spark components are at 100% parity yet, but more default CSS support is being added in Flex 4.5. Create styles for your own application 	Using customer CSS in both your components and skins allows for rapid changes and flexibility to your applications look and feel.
Thank you... Any Questions? Any questions? 	Ask them if you got them... James Polanco 	Twitter: @jamespolanco 	Email: info@developmentarc.com 	Website:  http://www.developmentarc.com

More Related Content

What's hot

Managing documents using ms word
Managing documents using ms wordManaging documents using ms word
Managing documents using ms wordJaiveer Singh
 
Save time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft WordSave time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft WordRhonda Bracey
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style SheetsPaul Dionysius
 
Save time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft Word Save time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft Word Rhonda Bracey
 
Presentation of ms word
Presentation of ms wordPresentation of ms word
Presentation of ms wordVaishnavi8950
 
Microsoft PowerPoint 2010
Microsoft PowerPoint 2010Microsoft PowerPoint 2010
Microsoft PowerPoint 2010nhumar
 
OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...Michael Posso
 
Training on webwroks1
Training on webwroks1Training on webwroks1
Training on webwroks1sumeettechno
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?Michael Posso
 
(Ms word2003)
(Ms word2003)(Ms word2003)
(Ms word2003)u083486
 

What's hot (15)

Dreamweaver Ch03
Dreamweaver Ch03Dreamweaver Ch03
Dreamweaver Ch03
 
Managing documents using ms word
Managing documents using ms wordManaging documents using ms word
Managing documents using ms word
 
Html css
Html cssHtml css
Html css
 
Save time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft WordSave time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft Word
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Save time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft Word Save time and your sanity: Increase your efficiency with Microsoft Word
Save time and your sanity: Increase your efficiency with Microsoft Word
 
Presentation of ms word
Presentation of ms wordPresentation of ms word
Presentation of ms word
 
Css
CssCss
Css
 
CSS
CSSCSS
CSS
 
Microsoft PowerPoint 2010
Microsoft PowerPoint 2010Microsoft PowerPoint 2010
Microsoft PowerPoint 2010
 
OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...
 
Training on webwroks1
Training on webwroks1Training on webwroks1
Training on webwroks1
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?
 
(Ms word2003)
(Ms word2003)(Ms word2003)
(Ms word2003)
 
BEM methodology overview
BEM methodology overviewBEM methodology overview
BEM methodology overview
 

Viewers also liked

Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009Ivan Ilijasic
 
Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4Dan Orlando
 
David Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop FinalDavid Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop Finaldcoletta
 
P2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash PlatformP2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash Platformboushley
 
Adobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & TricksAdobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & TricksMihai Corlan
 
360|Flex Greenthreading In Flex
360|Flex Greenthreading In Flex360|Flex Greenthreading In Flex
360|Flex Greenthreading In FlexHuyen Tue Dao
 

Viewers also liked (7)

Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009Osvrt Na Adobe Max 2009
Osvrt Na Adobe Max 2009
 
Migrating fx3tofx4
Migrating fx3tofx4Migrating fx3tofx4
Migrating fx3tofx4
 
Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4Creating Custom Spark Components in Flex 4
Creating Custom Spark Components in Flex 4
 
David Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop FinalDavid Coletta Architecting A Shared Codebase For Browser And Desktop Final
David Coletta Architecting A Shared Codebase For Browser And Desktop Final
 
P2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash PlatformP2P vs Sockets: Communication on the Flash Platform
P2P vs Sockets: Communication on the Flash Platform
 
Adobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & TricksAdobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & Tricks
 
360|Flex Greenthreading In Flex
360|Flex Greenthreading In Flex360|Flex Greenthreading In Flex
360|Flex Greenthreading In Flex
 

Similar to Adobe Flex Don't Style It, Skin it!

Similar to Adobe Flex Don't Style It, Skin it! (20)

Flex 4 Deep Dive
Flex 4 Deep DiveFlex 4 Deep Dive
Flex 4 Deep Dive
 
Flex 4 Deep Dive
Flex 4 Deep DiveFlex 4 Deep Dive
Flex 4 Deep Dive
 
Css - Tutorial
Css - TutorialCss - Tutorial
Css - Tutorial
 
Csstutorial
CsstutorialCsstutorial
Csstutorial
 
Exploring Adobe Flex
Exploring Adobe Flex Exploring Adobe Flex
Exploring Adobe Flex
 
Css tutorial by viveksingh698@gmail.com
Css tutorial by viveksingh698@gmail.comCss tutorial by viveksingh698@gmail.com
Css tutorial by viveksingh698@gmail.com
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Css tutorial
Css tutorial Css tutorial
Css tutorial
 
Flex 4 Overview
Flex 4 OverviewFlex 4 Overview
Flex 4 Overview
 
Visual Experience 360 Flex
Visual Experience 360 FlexVisual Experience 360 Flex
Visual Experience 360 Flex
 
Introduction to whats new in css3
Introduction to whats new in css3Introduction to whats new in css3
Introduction to whats new in css3
 
Formatting text with CSS
Formatting text with CSSFormatting text with CSS
Formatting text with CSS
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
Skinning in Flex 4
Skinning in Flex 4Skinning in Flex 4
Skinning in Flex 4
 
Css
CssCss
Css
 
Cascading Style Sheet | CSS
Cascading Style Sheet | CSSCascading Style Sheet | CSS
Cascading Style Sheet | CSS
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
Css
CssCss
Css
 
Flex 3 - Introduction
Flex 3 - IntroductionFlex 3 - Introduction
Flex 3 - Introduction
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Adobe Flex Don't Style It, Skin it!

  • 1. Don’t Just Skin It. Style It! James Polancowww.developmentarc.comFlash Camp Brasil2011
  • 2. Who am I? James Polanco Web Application ArchitectFlex, Flash, AIR, Ajax... Getting into Scala and Lift Co-founder of DevelopmentArcconsulting and development firm focusing on web applications Author for Adobe Press“Adobe Flash Platform Start to Finish: Working Collaboratively using Adobe Creative Suite 5” Twitter & Website@jamespolancowww.developmentarc.com
  • 3. What is this session about? Styling a Flex application has many different approachesCSS, MXML properties, Programmatic Skins, 3rd Party libraries (ex: Degrafa) Flex 3 (Halo) vs. Flex 4 (Spark) Each Component set (Halo & Spark) has similar and different features to support styling of your Flex components. Flex 4 (Spark) is changing how we work Changes in the Flex 4 (Spark) component architecture is changing how applications are styled.
  • 4. Style Support in Flex : Flex 3 (Halo) CSS in Flex 3 Benefits Setting look and feel based on style declarations An extensive set of styles are built into Flex 3 components ex: Button has color, borderColor, backgroundColor, etc... Limitations Only able to change settings that are exposed to the CSS Style system
  • 5. Style Support in Flex : Flex 3 (Halo) Programmatic Skins in Flex 3 Benefits Full Control over all aspects of the design Creating backgrounds that can show different component layouts, and add animations… Limitations Requires extensive ActionScript and understanding of the component architecture to implement Any design changes must be implemented via code (unless the code implements Flex’s style system) Programmatic skins are only defining the background of the component, you can not draw on top of content nor modify children without creating risky direct parent reference
  • 6. Style Support in Flex : Flex 4 (Spark) CSS in Flex 4 Benefits Setting look and feel based on style declarations Improved CSS declaration support and advanced language features Style names are propagated from the component to the skin Limitations Styles have less support in Flex 4 components ex: Button has color but does not support borderColor, backgroundColor, etc…
  • 7. Style Support in Flex : Flex 4 (Spark) New Skin Architecture in Flex 4 Benefits Replaces Programmatic skin with MXML based skinning system Rapidly create and change skins as need Separates logic from layout You can easily manipulate the components children parts and styles, unlike programmatic skins in Flex 3 Limitations Can require development for each layout / design CSS support within a skin requires extra development
  • 8. Understanding Spark (Flex 4) Brief look at the new Flex 4 (Spark) Architecture Creates a separation of layout from logic A Spark component is made up of two parts: the Skin (look & feel) and the backing Component (logic) Allows the look and feel of a component to be changed at runtime Skins are assigned via CSS (skinClass) and can be changed at any time.
  • 9. Understanding Spark (Flex 4) Brief look at the new Flex 4 (Spark) Architecture
  • 10. CSS in Flex 4 CSS support still exists in Flex 4 (Spark) components New properties have been created for general themes, such as contentBackgroundColor It’s not as supported as Flex 3 but... Many of the previous Flex 3 CSS properties on the new Flex 4 versions of the components do not exist (yet...) Flex 4 has more CSS features! Many new advanced CSS features, such as ID and pseudo selectors (we will examine this in depth later)
  • 11. CSS in Flex: What are styles? What are styles? Settings of a component that enable the ability to change the look and feel of a component dynamically For example, setting the font color on a button <s:Button color="#FF0000" />
  • 12. CSS in Flex: Setting Styles Four ways we can set styles in Flex ActionScript setting styles directly in our code MXML setting properties on our MXML components <Style> Blocks defining a style block in our MXML file External Style Sheets linking to external CSS files to define our styles
  • 13. CSS in Flex: Setting Styles, ActionScript myButton.setStyle("color", 0xFF0000); Styles are not properties of components This means we can’t do things like: myButton.color = 0xFFFF00 Flex provides a Style Manager The Style Manager handles complex style inheritance and other properties of CSS for us To set a style we use the setStyle() method Because styles aren’t properties and are handled by the Style Manager we use the setStyle() method, whose job is to work with the Style Manager to handle all the complex reltionships
  • 14. CSS in Flex: Setting Styles, MXML <s:Button id="myButton" color="#FF0000" /> Styles are exposed as properties in MXML MXML treats styles as properties of our components MXML hides the fact that styles are not properties on a component MXML and the compiler handle converting our style “properties” into setStyle() commands at compile time
  • 15. CSS in Flex: Setting Styles, <Style> Block <fx:Style>.myStyle { color: #FF0000; } </fx:Style> <s:Button id=“myButton” styleName=“myStyle”/> A local style definition is created in the MXML and linked through CSS binding techniques We can create local style definitions and then apply them to our components (more to come...)
  • 16. CSS in Flex: External Stylesheets <fx:Stylesrc=“/assets/css/myStylesheet.css” /> <s:Button id=“myButton” styleName=“myStyle”/> Externally referenced style definitions are linked into our MXML and are applied Similar to our local style definition, we can link to external CSS files which are applied
  • 17. CSS in Flex: Selectors What is a Selector? Defines how a style is applied and in what context There are four selector types in Flex Type Selector Class Selector ID Selector Pseudo Selector
  • 18. CSS in Flex: Type Selectors What is a Type Selector? Defines global styles for any “type” of component that is created, such as a Button, ComboBox, List, etc... /* All Buttons in our application have their font color set to red: */ Button { color: #FF0000;}
  • 19. CSS in Flex: Class Selectors What is a Class Selector? Defines styles that must be explicitly referenced by the component using the “styleName” property: ex: <s:ButtonstyleName="myStyle" /> /* Only components that reference this style has their font color set to red: */ .myStyle { color: #FF0000;}
  • 20. CSS in Flex: ID Selectors What is an ID Selector? Components with the explicit ID apply these styles (new in Flex 4) ex: <s:Button id=“myButton” /> /* Only components that have id=“myButton” has their font color set to red: */ #myButton { color: #FF0000;}
  • 21. CSS in Flex: Pseudo Selectors What is a Pseudo Selector? Pseudo selectors work in conjunction with other selectors (Type, ID, Class) Allows us to changes style based on the current state the component is in (such as a button’s up, over, down & disabled states) The component must support the state to apply the style, stateGroups are not supported /* Change the color based on state: */ Button:up { color: #FF0000;} Button:down { color: #00FF00;}
  • 22. CSS in Flex: Namespaces What is a Namespace? Namespaces are new in Flex 4 and now required for any CSS declarations Allow us to support type selectors When we say “Button” do we mean Halo or Spark buttons? @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; s|Button { color: #FF0000; }
  • 23. CSS in Flex: Chaining Selectors We can now chain selectors Chaining allows us to share properties across different style types s|Button, .blueText, #myLabel { color: #0000FF; }
  • 24. CSS in Flex: Dependent Selectors We can define dependent selectors With a dependent selectors we can apply styles to elements based on their parents, the space between the selectors informs the CSS engine that the style should be applied based on the parent/child relationship s|HGroups|Button { color: #0000FF; } <s:HGroup> <s:Button id=“myButton” /> </s:HGroup>
  • 25. CSS in Flex: Linking Selectors We can link type, class and id selectors to identify elements By linking type, class and id selectors together we can explicitly define what and when an element should have a style applied. The style is linked when there is NO space between the selectors S|Button#myButton.labelText { color: #0000FF; } <s:Button id=“myButton” styleName=“labelText” />
  • 26. CSS in Flex: Cascading Cascading is the C in CSS CSS’ (Cascading Style Sheets) power is the ability to define styles and have them apply down the parent/child hierarchy automatically How does it work? Inheritable Styles: If the parent has a style set (such as color) and the child supports the style, then the child’s style is set to the parents value. Inheritance is defined via the [Style] metadata Non-Inheriting Styles: If the parent has the style set and the child supports the style, the value is NOT passed on Global Styles: Flex supports the global tag, which applies this style to EVERYTHING in the application
  • 27. CSS in Flex: Cascading Chain of Command Understanding the priority order of what style overrides the cascading parents value OR the style definition location is very important Global > Type > Class > ID > local > setStyle() setStyle() overrides a local definition, a local definition overrides an ID definition, an ID definition overrides a Class definition, a Class definition overrides a Type definition and a Type definition overrides a global definition.
  • 28. Supporting CSS in Flex How do we leverage it in our own components? We can support CSS in our custom components by using a combination of Metadata, ActionScript and the new Flex 4 Skin architecture ActionScript Methods Flex provides multiple methods for creating, managing and accessing styles Metadata Metadata allows us to define what styles our components support, how they cascade, their type and their default values Flex 4 Skins & FXG Flex 4 changes where we manage our styles and also supports a new way to apply and visualize our UI with these style settings
  • 29. Supporting CSS in Flex: Methods setStyle() The setStyle() method allows us to define a style directly to our component. We pass in a style name and the style value: setStyle("color", 0xFF0000); getStyle() The getStyle method allows us to determine what the current value for the style is: varourColor:Number = getStyle("color"); styleChanged() The styleChanged() method is called on our component whenever a defined style is updated. updateDisplayList() The updateDisplayList() method is where we should do all our style calculations and application to our content.
  • 30. Supporting CSS in Flex: Metadata Metadata informs the compiler and tools (like Flash Builder) what styles are supported Metadata is how MXML can show a style as a property. Without metadata the compiler would not recognize the style property and throw an error at compile time. Styles can still be used without metadata We can still use the ActionScript methods, such as set and get style, even if the metadata isn’t defined. Metadata is defined on the component (ActionScript) class and not a Skin (Flex 4+) The metadata is assigned to the base component and not to a skin, for a component to fully support in MXML it has to be defined on the class: [Style(name="errorColor", type="uint", format="Color", inherit="yes")]
  • 31. Flex 4: Styling With Skins Creating MXML Skins Flex 4 supports creating new looks for components using the skinning architecture. Similar to Programmatic skins, but easier to create and you can use MXML to define them. Setting Skins Skins are attached to a component using the skinClass style property, they can be defined in CSS using the ClassReference wrapper. skinClass: ClassReference(”com.example.package.skin.SkinFile"); Swapping Skins Because skins are defined via styles we can change them at any time by either referencing a new style declaration or by using setStyle().
  • 32. Flex 4: CSS in Skins Override updateDisplayList() In the Skin class we can override the updateDisplayList() method and then use getStyle() to retrieve the property values defined for the style. Update the skin with the style values Once the values have been pulled from getStyle() we can then apply the values to the parts of the skin that the styles correspond to. Expose style via Metadata on the base component To support style properties in MXML for our skins, the host component the skin is attached to should declare the styles using metadata.
  • 33. Flex 4: Skin States & CSS States allow the skin to update the look of the UI Skin States defined in the host component allow our skins to change the look and feel based on user interaction. Think Button and the up, over, down, and disabled state. Using CSS pseudo selectors enables us to change the style on state changes When we define pseudo selectors ( .myStyle:up{} ) the getStyle() method will return the updated value in the updateDisplayList() method when our states change. This allows us to easily define and support CSS state changes in our skins.
  • 34. CSS in Skins: Using FXG FXG is Adobe’s new declarative graphics language FXG allows us to create vector based assets in MXML <s:Rect top="0" left="0" right="0" bottom="0"> <s:fill><s:SolidColor id="bgColor" color="#CDCDCD"/></s:fill> </s:Rect> Modify FXG properties to enable CSS customizable skins When the state changes we can reference and then update the FXG bgColor.color = getStyle("backgroundColor");
  • 35. Wrapping it up... Flex 4 is adding a lot of styling opportunity Advanced CSS functionality and the new skinning architecture is allowing for easier customization of your application. CSS is currently less prevalent in the current component set The current Spark components are at 100% parity yet, but more default CSS support is being added in Flex 4.5. Create styles for your own application Using customer CSS in both your components and skins allows for rapid changes and flexibility to your applications look and feel.
  • 36. Thank you... Any Questions? Any questions? Ask them if you got them... James Polanco Twitter: @jamespolanco Email: info@developmentarc.com Website: http://www.developmentarc.com