SlideShare una empresa de Scribd logo
1 de 39
Building User Interface Components FLEX 2.01
In this presentation Component lifecycle and optimization tips Generalizing components  Designing component API
Why create Components? Ease of development   Reusability   Maintainability 
What are Components? Owner Events Events Events UI Component subcomponents Data Properties Data Properties Data Properties
MXML vs. AS Flex Components  Some basic guidelines include the following:  ,[object Object]
Composite components that contains other components & the Layout of those other components can be set using one of the Flex layout containers, use MXML.
Complex components, such as to modifying the way a container lays out its children, use ActionScript.
Visual component forinstance creating a subclass from UIComponent, use ActionScript.
Nonvisual component, such as a formatter, validator, or effect, use ActionScript. ,[object Object]
Component Lifecycle in FLEX Implementing the lifecycle boils down to these methods: Constructor() createChildren() commitProperties() measure() updateDisplayList() Custom events
Construction MXML-able components must have zero arg constructors Call super()…or the compiler will do it for you. Good place to attach your own event handlers Try to avoid creating children here…for best performance
Construction CONSUMER <local:RandomWalk /> or Varinstance:RandomWalk = newRandomWalk(); COMPONENT public function RandomWalk() { super(); this.addEventListener( MouseEvent.CLICK, clickHandler); }
Configuration MXML assigns properties before sub-components are attached and initialized (avoids duplicate code execution). Your properties (get, set functions) need to expect that subcomponents haven’t been created yet. Avoid creating performance bottlenecks: make set functions defer work until validation.
Configuration property2 property3 property1 invalidateProperties Properties invalidated? yes commitProperties
Configuration (pattern) CONSUMER … instance.dataProvider = xmlDataSet; instance.width = 600; instance.height = 200; instance.labelText = “hello”; ... Or via binding …  labelText=“{hello}” width=“600” … dataprovider=“{xmlDataSet}” COMPONENT private var _labelText:String; private var  _labelTextDirty; public function set labelText(value:String):void { If (_labelText != value) { _labelText= value; //BAD _label.text = _labelText; _labelTextDirty = true; invalidateProperties(); //invalidation  } }
Attachment ,[object Object]
Styles may not be initialized until its ancestors get rooted to the displayList()
Parent.addChild(At) calls initialize() method to trigger next phase…you can call this explicitly if necessaryParent addChild (ComponentInstance) Component initialization begins
Startup Trigger preinitialize initialization Phase createChildren() Trigger initialize Validation Phase commitProperties() measure() updateDisplayList() Trigger creationComplete Trigger render
Startup Startup happens in multiple sub-phases: 1. ‘preinitialize’ event is dispatched 2. createChildren method is called, adds sub-components 3. ‘initialize’ event is called – component is fully created 4. First validation pass occurs 5. ‘creationComplete’ event is fired – component is fully commited, measured, and updated.
Startup 1. Parent-> preinitialize Parent-> createChildren      Child-> preinitialize      Child-> createChildren grandChild->  preinitialize grandChild-> createChildren grandChild->  initialize      Child-> initialize      Child2-> preinitialize      Child2-> createChildren      Child2-> initialize Parent-> initialize 2. Parent-> commitProperties      Child-> commitProperties grandChild-> commitProperties grandChild-> measure      Child-> measure Parent-> measure 3.  Parent-> updateDisplayList      Child-> updateDisplayList grandChild-> updateDisplayList 4.  Parent-> render      Child-> render grandChild->  render grandChild->  creationComplete      Child-> creationComplete Parent-> creationComplete
Initialization : createChildren() Creating children here streamlines startup performance Follow the same pattern MXML uses: create, configure, attach. Flex components give subclasses first-crack at defining subcomponents. Don’t forget to call super.createChildren(); Defer creating dynamic and data-driven components to commitProperties();
Initialization : createChildren //example protected varcommitButton:UIComponent; override protected function createChildren():void { if (commitButton == null) //only create once—why ? { commitButton = new Button(); 		Button(commitButton).label = “OK”; } addChild(commitButton); commitButton.addEventListener(MouseEvent.CLICK, commitHandler); super.createChildren(); }
Invalidation  Flex imposes a deferred validation model Aggregate changes, defer work until the last possible moment avoid creating performance traps for your consumers Three main invalidation functions: invalidateProperties() invalidateSize() invalidateDisplayList()
Invalidation  Rules of Thumb: 1. Change values immediately 2. Dispatch events immediately 3. Defer Side-effects and calculations to commitProperties() 4. Defer rendering to updateDisplayList() 5. Be suspicious of rules of Thumb 
Validation : commitProperties Invoked by the framework immediately before measurement and layout Use it to calculate and commit the effects of changes to properties and underlying data Avoid extra work: Use flags to filter what work needs to be done Proper place to destroy and create  dynamic subcomponents based on changes to properties or underlying data.
Validation : commitProperties //example override protected function commitProperties():void { if (_cme_datachanged)     {   _ cme_datachanged = false; //reset flag 	   //data change effects applied here  } super.commitProperties();  }
Validation : measure Invoked by the framework when a component’s invalidateSize() is called Components calculate their ‘natural’ size based on content and layout rules. Implicitly invoked when component children change size. Don’t count on it: Framework optimizes away unnecessary calls to measure. Quick Tip: start by explicitly sizing your component, and implement this later.
Validation : updateDisplayList Invoked by the framework when a component’s invalidateDisplayList() is called The ‘right’ place to do all of your drawing and layout
Interaction Properties:  Talk to your component Events:  Listen to your component Public methods: Only in very specific cases where you can not use properties or events to fulfill the need
Interaction: Events Events consist of: Name: A unique (per target) name identifying the type of event Target: the object that dispatched the event Event: An Object containing additional information relevant to the event Handler: the function invoked when the event occurs.
Interaction: Events 1. Handling Events     Registering, removing, capture, bubble 2. Dispatching Events     Flex’s event system is extensible – you can define the events you need to make your component useful. – more on this later Remember that events will bubble up from your sub-components. If you don’t want that to happen, you need to explicitly stop them from propagating.
How the Flash Player Works?
Other topics Generalizing Components Designing Components
Generalizing Components Three important concepts for generalizing your component SKINNING! STYLING! TEMPLATING!
Generalizing Components Three important concepts for generalizing your component Use Properties to generalize the behavior and data Use Skinning and Styling to generalize the look Use Templating to generalize the content.
Generalizing Component : Templating Instance properties Properties typed as UIComponent can be set in MXML like any other property. Reparenting allows you to embed passed values into your own display tree. Allows you to define complex components with configurable parts public function set thumbnailView(value:UIComponent) {     _thumbnailView = value; addChild(thumbnailView); }
Generalizing Component : Templating 2. 	Item Renderers (Factories) Factories are used to generate multiple child components Data driven components use them to generate renderers for the data Allows you to separate management of the data from displaying the data. Quick Tips: Type your item renderers as IFactory Use the IDataRenderer interface to pass your data to the instances If you have additional data to pass, define a custom interface and test to see if it is supported first.
Generalizing Component : Binding Databinding is there to eliminate boilerplate data routing code <mx:Button enabled=“{randomWalk.selectedItem != null}” /> Any property can be the destination of a binding, but the source needs special Support Good rule of thumb: If you think someone might want to bind to it…make it bindable.

Más contenido relacionado

La actualidad más candente

Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivitiesmaamir farooq
 
DotNetNuke Client API -DragDropAdminModules.pdf
DotNetNuke Client API -DragDropAdminModules.pdfDotNetNuke Client API -DragDropAdminModules.pdf
DotNetNuke Client API -DragDropAdminModules.pdfarunagulla
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - AndroidWingston
 
Create an other activity lesson 3
Create an other activity lesson 3Create an other activity lesson 3
Create an other activity lesson 3Kalluri Vinay Reddy
 
Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NETPeter Gfader
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning componentsthomaswaud
 
View groups containers
View groups containersView groups containers
View groups containersMani Selvaraj
 
Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Katy Slemon
 
Part 1 implementing a simple_web_service
Part 1 implementing a simple_web_servicePart 1 implementing a simple_web_service
Part 1 implementing a simple_web_servicekrishmdkk
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...mharkus
 

La actualidad más candente (16)

Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Activity
ActivityActivity
Activity
 
DotNetNuke Client API -DragDropAdminModules.pdf
DotNetNuke Client API -DragDropAdminModules.pdfDotNetNuke Client API -DragDropAdminModules.pdf
DotNetNuke Client API -DragDropAdminModules.pdf
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
Create an other activity lesson 3
Create an other activity lesson 3Create an other activity lesson 3
Create an other activity lesson 3
 
Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NET
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning components
 
MVC
MVCMVC
MVC
 
View groups containers
View groups containersView groups containers
View groups containers
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...
 
Part 1 implementing a simple_web_service
Part 1 implementing a simple_web_servicePart 1 implementing a simple_web_service
Part 1 implementing a simple_web_service
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
Advance RCP
Advance RCPAdvance RCP
Advance RCP
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
 

Destacado

Enterprise Project Management Essential #1
Enterprise Project Management Essential #1Enterprise Project Management Essential #1
Enterprise Project Management Essential #1Nah Wee Yang
 
Root Cause Analysis (RCA) Tools
Root Cause Analysis (RCA) ToolsRoot Cause Analysis (RCA) Tools
Root Cause Analysis (RCA) ToolsJeremy Jay Lim
 
AMA_PMP Exam Prep Express
AMA_PMP Exam Prep ExpressAMA_PMP Exam Prep Express
AMA_PMP Exam Prep ExpressKarnika Dalal
 
Circuit Tiles Guide
Circuit Tiles GuideCircuit Tiles Guide
Circuit Tiles GuideNah Wee Yang
 
Rally Fream Work
Rally Fream WorkRally Fream Work
Rally Fream Workvivek jog
 
Project Management Basics Training Promotion
Project Management Basics Training PromotionProject Management Basics Training Promotion
Project Management Basics Training PromotionJeremy Jay Lim
 
Project Management
Project ManagementProject Management
Project Managementtkrikau
 
What is Business Strategy ?
What is Business Strategy ?What is Business Strategy ?
What is Business Strategy ?Jonathan Donado
 
KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...
KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...
KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...King Consulting Services
 
KCS Academy PMP Exam Prep Course Chapter 3 - Project Management Processes
KCS Academy PMP Exam Prep Course Chapter 3 - Project Management ProcessesKCS Academy PMP Exam Prep Course Chapter 3 - Project Management Processes
KCS Academy PMP Exam Prep Course Chapter 3 - Project Management ProcessesKing Consulting Services
 
Deconstructing the PMP Exam Question - The Deep Dive
Deconstructing the PMP Exam Question - The Deep DiveDeconstructing the PMP Exam Question - The Deep Dive
Deconstructing the PMP Exam Question - The Deep DiveKing Consulting Services
 
KCS Academy PMP Exam Prep Course Chapter 1 - Introduction
KCS Academy PMP Exam Prep Course Chapter 1 - IntroductionKCS Academy PMP Exam Prep Course Chapter 1 - Introduction
KCS Academy PMP Exam Prep Course Chapter 1 - IntroductionKing Consulting Services
 
Ch09 human resources management v1.2
Ch09   human resources management v1.2Ch09   human resources management v1.2
Ch09 human resources management v1.2Cornelius Mellino
 
Ch01 pmp exam prep guideline v1.1
Ch01   pmp exam prep guideline v1.1Ch01   pmp exam prep guideline v1.1
Ch01 pmp exam prep guideline v1.1Cornelius Mellino
 
PMP Exam Prep - Communications Management
PMP Exam Prep - Communications ManagementPMP Exam Prep - Communications Management
PMP Exam Prep - Communications Managementtkrikau
 
Business Strategy & Alignment to Project Management
Business Strategy & Alignment to Project ManagementBusiness Strategy & Alignment to Project Management
Business Strategy & Alignment to Project ManagementJonathan Donado
 
Strategy Questions by A Project Manager - PMP
Strategy Questions by A Project Manager - PMPStrategy Questions by A Project Manager - PMP
Strategy Questions by A Project Manager - PMPJonathan Donado
 

Destacado (20)

Enterprise Project Management Essential #1
Enterprise Project Management Essential #1Enterprise Project Management Essential #1
Enterprise Project Management Essential #1
 
Root Cause Analysis (RCA) Tools
Root Cause Analysis (RCA) ToolsRoot Cause Analysis (RCA) Tools
Root Cause Analysis (RCA) Tools
 
AMA_PMP Exam Prep Express
AMA_PMP Exam Prep ExpressAMA_PMP Exam Prep Express
AMA_PMP Exam Prep Express
 
Circuit Tiles Guide
Circuit Tiles GuideCircuit Tiles Guide
Circuit Tiles Guide
 
We're Talking About Planning
We're Talking About PlanningWe're Talking About Planning
We're Talking About Planning
 
Rally Fream Work
Rally Fream WorkRally Fream Work
Rally Fream Work
 
Project Management Basics Training Promotion
Project Management Basics Training PromotionProject Management Basics Training Promotion
Project Management Basics Training Promotion
 
Project Management
Project ManagementProject Management
Project Management
 
What is Business Strategy ?
What is Business Strategy ?What is Business Strategy ?
What is Business Strategy ?
 
SMART Objective
SMART ObjectiveSMART Objective
SMART Objective
 
KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...
KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...
KCS Academy PMP Exam Prep Course Chapter 2 - Organizational Influences and Pr...
 
KCS Academy PMP Exam Prep Course Chapter 3 - Project Management Processes
KCS Academy PMP Exam Prep Course Chapter 3 - Project Management ProcessesKCS Academy PMP Exam Prep Course Chapter 3 - Project Management Processes
KCS Academy PMP Exam Prep Course Chapter 3 - Project Management Processes
 
Deconstructing the PMP Exam Question - The Deep Dive
Deconstructing the PMP Exam Question - The Deep DiveDeconstructing the PMP Exam Question - The Deep Dive
Deconstructing the PMP Exam Question - The Deep Dive
 
KCS Academy PMP Exam Prep Course Chapter 1 - Introduction
KCS Academy PMP Exam Prep Course Chapter 1 - IntroductionKCS Academy PMP Exam Prep Course Chapter 1 - Introduction
KCS Academy PMP Exam Prep Course Chapter 1 - Introduction
 
Ch09 human resources management v1.2
Ch09   human resources management v1.2Ch09   human resources management v1.2
Ch09 human resources management v1.2
 
Ch01 pmp exam prep guideline v1.1
Ch01   pmp exam prep guideline v1.1Ch01   pmp exam prep guideline v1.1
Ch01 pmp exam prep guideline v1.1
 
Resource Strategy 2013
Resource Strategy 2013Resource Strategy 2013
Resource Strategy 2013
 
PMP Exam Prep - Communications Management
PMP Exam Prep - Communications ManagementPMP Exam Prep - Communications Management
PMP Exam Prep - Communications Management
 
Business Strategy & Alignment to Project Management
Business Strategy & Alignment to Project ManagementBusiness Strategy & Alignment to Project Management
Business Strategy & Alignment to Project Management
 
Strategy Questions by A Project Manager - PMP
Strategy Questions by A Project Manager - PMPStrategy Questions by A Project Manager - PMP
Strategy Questions by A Project Manager - PMP
 

Similar a Flex Building User Interface Components

Flex component lifecycle
Flex component lifecycleFlex component lifecycle
Flex component lifecycleYaniv Uriel
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期增强 杜
 
Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder BurritoJeff Bollinger
 
Building Components In Flex3
Building Components In Flex3Building Components In Flex3
Building Components In Flex3Tikal Knowledge
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
Learn about dot net attributes
Learn about dot net attributesLearn about dot net attributes
Learn about dot net attributessonia merchant
 
Invalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your CraniumInvalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your Craniumsakrirosenstrom
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinBarry Gervin
 
Flex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakesFlex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakesElad Elrom
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Componentsmichael.labriola
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Watersmichael.labriola
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive FinalRJ Owen
 
Learning .NET Attributes
Learning .NET AttributesLearning .NET Attributes
Learning .NET AttributesPooja Gaikwad
 
Learn dot net attributes
Learn dot net attributesLearn dot net attributes
Learn dot net attributessonia merchant
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
Flex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle PracticeFlex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle Practicejexchan
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applicationsdcoletta
 

Similar a Flex Building User Interface Components (20)

Flex component lifecycle
Flex component lifecycleFlex component lifecycle
Flex component lifecycle
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期
 
Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder Burrito
 
Building Components In Flex3
Building Components In Flex3Building Components In Flex3
Building Components In Flex3
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Learn about dot net attributes
Learn about dot net attributesLearn about dot net attributes
Learn about dot net attributes
 
Invalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your CraniumInvalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your Cranium
 
Test
TestTest
Test
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
 
Flex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakesFlex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakes
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive Final
 
Learning .NET Attributes
Learning .NET AttributesLearning .NET Attributes
Learning .NET Attributes
 
Learn dot net attributes
Learn dot net attributesLearn dot net attributes
Learn dot net attributes
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Flex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle PracticeFlex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle Practice
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applications
 
WPF Fundamentals
WPF FundamentalsWPF Fundamentals
WPF Fundamentals
 

Último

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

Flex Building User Interface Components

  • 1. Building User Interface Components FLEX 2.01
  • 2. In this presentation Component lifecycle and optimization tips Generalizing components Designing component API
  • 3. Why create Components? Ease of development  Reusability  Maintainability 
  • 4. What are Components? Owner Events Events Events UI Component subcomponents Data Properties Data Properties Data Properties
  • 5.
  • 6. Composite components that contains other components & the Layout of those other components can be set using one of the Flex layout containers, use MXML.
  • 7. Complex components, such as to modifying the way a container lays out its children, use ActionScript.
  • 8. Visual component forinstance creating a subclass from UIComponent, use ActionScript.
  • 9.
  • 10. Component Lifecycle in FLEX Implementing the lifecycle boils down to these methods: Constructor() createChildren() commitProperties() measure() updateDisplayList() Custom events
  • 11. Construction MXML-able components must have zero arg constructors Call super()…or the compiler will do it for you. Good place to attach your own event handlers Try to avoid creating children here…for best performance
  • 12. Construction CONSUMER <local:RandomWalk /> or Varinstance:RandomWalk = newRandomWalk(); COMPONENT public function RandomWalk() { super(); this.addEventListener( MouseEvent.CLICK, clickHandler); }
  • 13. Configuration MXML assigns properties before sub-components are attached and initialized (avoids duplicate code execution). Your properties (get, set functions) need to expect that subcomponents haven’t been created yet. Avoid creating performance bottlenecks: make set functions defer work until validation.
  • 14. Configuration property2 property3 property1 invalidateProperties Properties invalidated? yes commitProperties
  • 15. Configuration (pattern) CONSUMER … instance.dataProvider = xmlDataSet; instance.width = 600; instance.height = 200; instance.labelText = “hello”; ... Or via binding … labelText=“{hello}” width=“600” … dataprovider=“{xmlDataSet}” COMPONENT private var _labelText:String; private var _labelTextDirty; public function set labelText(value:String):void { If (_labelText != value) { _labelText= value; //BAD _label.text = _labelText; _labelTextDirty = true; invalidateProperties(); //invalidation } }
  • 16.
  • 17. Styles may not be initialized until its ancestors get rooted to the displayList()
  • 18. Parent.addChild(At) calls initialize() method to trigger next phase…you can call this explicitly if necessaryParent addChild (ComponentInstance) Component initialization begins
  • 19. Startup Trigger preinitialize initialization Phase createChildren() Trigger initialize Validation Phase commitProperties() measure() updateDisplayList() Trigger creationComplete Trigger render
  • 20. Startup Startup happens in multiple sub-phases: 1. ‘preinitialize’ event is dispatched 2. createChildren method is called, adds sub-components 3. ‘initialize’ event is called – component is fully created 4. First validation pass occurs 5. ‘creationComplete’ event is fired – component is fully commited, measured, and updated.
  • 21. Startup 1. Parent-> preinitialize Parent-> createChildren Child-> preinitialize Child-> createChildren grandChild-> preinitialize grandChild-> createChildren grandChild-> initialize Child-> initialize Child2-> preinitialize Child2-> createChildren Child2-> initialize Parent-> initialize 2. Parent-> commitProperties Child-> commitProperties grandChild-> commitProperties grandChild-> measure Child-> measure Parent-> measure 3. Parent-> updateDisplayList Child-> updateDisplayList grandChild-> updateDisplayList 4. Parent-> render Child-> render grandChild-> render grandChild-> creationComplete Child-> creationComplete Parent-> creationComplete
  • 22. Initialization : createChildren() Creating children here streamlines startup performance Follow the same pattern MXML uses: create, configure, attach. Flex components give subclasses first-crack at defining subcomponents. Don’t forget to call super.createChildren(); Defer creating dynamic and data-driven components to commitProperties();
  • 23. Initialization : createChildren //example protected varcommitButton:UIComponent; override protected function createChildren():void { if (commitButton == null) //only create once—why ? { commitButton = new Button(); Button(commitButton).label = “OK”; } addChild(commitButton); commitButton.addEventListener(MouseEvent.CLICK, commitHandler); super.createChildren(); }
  • 24. Invalidation Flex imposes a deferred validation model Aggregate changes, defer work until the last possible moment avoid creating performance traps for your consumers Three main invalidation functions: invalidateProperties() invalidateSize() invalidateDisplayList()
  • 25. Invalidation Rules of Thumb: 1. Change values immediately 2. Dispatch events immediately 3. Defer Side-effects and calculations to commitProperties() 4. Defer rendering to updateDisplayList() 5. Be suspicious of rules of Thumb 
  • 26. Validation : commitProperties Invoked by the framework immediately before measurement and layout Use it to calculate and commit the effects of changes to properties and underlying data Avoid extra work: Use flags to filter what work needs to be done Proper place to destroy and create dynamic subcomponents based on changes to properties or underlying data.
  • 27. Validation : commitProperties //example override protected function commitProperties():void { if (_cme_datachanged) { _ cme_datachanged = false; //reset flag //data change effects applied here } super.commitProperties(); }
  • 28. Validation : measure Invoked by the framework when a component’s invalidateSize() is called Components calculate their ‘natural’ size based on content and layout rules. Implicitly invoked when component children change size. Don’t count on it: Framework optimizes away unnecessary calls to measure. Quick Tip: start by explicitly sizing your component, and implement this later.
  • 29. Validation : updateDisplayList Invoked by the framework when a component’s invalidateDisplayList() is called The ‘right’ place to do all of your drawing and layout
  • 30. Interaction Properties: Talk to your component Events: Listen to your component Public methods: Only in very specific cases where you can not use properties or events to fulfill the need
  • 31. Interaction: Events Events consist of: Name: A unique (per target) name identifying the type of event Target: the object that dispatched the event Event: An Object containing additional information relevant to the event Handler: the function invoked when the event occurs.
  • 32. Interaction: Events 1. Handling Events Registering, removing, capture, bubble 2. Dispatching Events Flex’s event system is extensible – you can define the events you need to make your component useful. – more on this later Remember that events will bubble up from your sub-components. If you don’t want that to happen, you need to explicitly stop them from propagating.
  • 33. How the Flash Player Works?
  • 34. Other topics Generalizing Components Designing Components
  • 35. Generalizing Components Three important concepts for generalizing your component SKINNING! STYLING! TEMPLATING!
  • 36. Generalizing Components Three important concepts for generalizing your component Use Properties to generalize the behavior and data Use Skinning and Styling to generalize the look Use Templating to generalize the content.
  • 37. Generalizing Component : Templating Instance properties Properties typed as UIComponent can be set in MXML like any other property. Reparenting allows you to embed passed values into your own display tree. Allows you to define complex components with configurable parts public function set thumbnailView(value:UIComponent) { _thumbnailView = value; addChild(thumbnailView); }
  • 38. Generalizing Component : Templating 2. Item Renderers (Factories) Factories are used to generate multiple child components Data driven components use them to generate renderers for the data Allows you to separate management of the data from displaying the data. Quick Tips: Type your item renderers as IFactory Use the IDataRenderer interface to pass your data to the instances If you have additional data to pass, define a custom interface and test to see if it is supported first.
  • 39. Generalizing Component : Binding Databinding is there to eliminate boilerplate data routing code <mx:Button enabled=“{randomWalk.selectedItem != null}” /> Any property can be the destination of a binding, but the source needs special Support Good rule of thumb: If you think someone might want to bind to it…make it bindable.
  • 40. Generalizing Component: Binding Add [Bindable] to your class: [Bindable] public class RandomWalk extends UIComponent { … Makes all public varsbindable Convenience feature for value objects. Add [Bindable] to your property [Bindable] public varselectedItem:Object; [Bindable] public function get selectedItem():Object { … Wraps the variable or property in an autogenerated get/set Good for simple properties. Roll your own event based bindings: [Bindable(event=“selectedItemChange”)] public function get selectedItem():Object { … dispatchEvent(new Event(“selectedItemChange”)); Works well for read only and derived properties
  • 41. Designing you API: base Class? What Base Class should you extend? UIComponent: Base class for all component and containers Gateway to key flex functionality: styles, Containers, invalidation, etc. Best choice for most components Container (and derivatives): Only use if your customers will think of your component as a container Allows developers to specify children in MXML (but there are other ways) Scrolling, clipping, and chrome management for free Other ‘Leaf’ Components Good for minor enhancements and guaranteeing type compatibility Major Functionality changes run the risk of ‘dangling properties’ Consider using aggregation instead
  • 42. Designing your API: MXML schema Remember, Your API defines your MXML schema Specifically: ClassName -> XML Tags Name Package -> XML Namespace Properties -> XML Attributes Complex Properties -> Child Tags
  • 43. Designing your API: Examples A Few Examples: Choose Properties over Methods Properties can be set from MXML Avoid write-once properties Anything that can be set in MXML can be bound to. Use value objects for complex and multi-valued properties MXML makes object graphs simple <DataGrid> <columns> <DataGridColumncolumnName=“revenue” width=“30” dataField=“revYr” /> <DataGridColumncolumnName=“profit” width=“30” dataField=“profYr” /> </columns> </DataGrid> Use different names for styles, events, and properties.

Notas del editor

  1. A common coding practice is to divide an application into functional units, or modules, where each module performs a discrete task. Dividing your application into modules provides you with many benefits, including the following:Ease of development Different developers or development groups can develop and debug modules independently of each other. Reusability You can reuse modules in different applications so that you do not have to duplicate your work.Maintainability By developing your application in discrete modules, you can isolate and debug errors faster than you could if you developed your application in a single file.
  2. Ideally components are placed inside another component or container or document. They fire events and have properties for configuration. As we said earlier components may contain other subcomponents. A point I’m going to stress now and always. Its never recommended to have public methods for components you should always try to introduce events for listening to your component and modify data properties to configure your components. using events and properties allow you to integrate smoothly with the UI model of flex and not create performance issues.
  3. Simple Components: are components that standardize the look and feel for another component by extending it.Composite Components: are components that group one or more components together to control their layout using on of flexlayout container(vBox,hBox,canvas,panel)Complex Components: are “complex” , they modify a container, control behaviour and the way it lays its data Nonvisual Components: such as formatters, validator,
  4. Constructor is called when you instantiate your component.CreateChildren is for instantiating your subcomponents Commitproperties for reading all assign properties … this may be called more than once Measure doing all measurmentsUpdateDisplaylist layout and drawing
  5. Keep in mind , overriding methods is always little bit better than handling events inside a component because IF used correctly they reduce the number rendering cycles
  6. Binding calls the setter of the property
  7. Recommnedations Check if the value actually changed Create a flag to notify the component that the property changed Invalidate the component so it reapplies the property.
  8. 2. Differentiate events from internal methods3. Constructor stuff -> preinitialize createChildren stuff -> initializecommitproperties, measure, updateDisplayList ->render, creationComplete (causing rerendering )
  9. Dynamic data driven properties components like those that you don’t need if certain properties are set. Flex calls it when the call to the addChild() ….. That is why it might be called more than once check next slide
  10. Recommendation Check if a subcomponent is already instantiated because createChildren might be called more than when
  11. invalidateProperties() for deferred calculation, child managementinvalidateSize() for changes to the measured size of a componentinvalidateDisplayList() for changes to the appearance of a component