SlideShare a Scribd company logo
Michael Labriola Senior Consultant  >>  Adobe Certified Instructor Adobe Community Expert  >>  Flex Community Champion digital primates  IT Consulting Group MAX 2007 CONNECT. DISCOVER. INSPIRE. Creating Custom Flex Components
How to create a custom component How to do it in a style that fits with the Flex Framework How to make it work well with Flex Builder What are we going to cover?
Examine the Carousel component Talk about the decisions that influenced its design Discuss the way it was built How are we going to do that?
We are going to review a lot of code We are going to move quickly We will provide time for Q&A at the end, but we can also be interactive  Ask questions when they occur and I will try to answer inline What can we expect?
You build components when you need something reusable that encapsulates behavior There are generally two reasons components are built To tweak existing components Tweaking behavior Changing default values Usually involves a higher level base class, Button, Vbox, etc. To create something very different than the standard components Usually involves a lower level class such as Container or UIComponent May involve going all the way to Sprite or ‘lowest’ level UI classes Why build custom components?
You have two main choices in Flex MXML with ActionScript Quick and easy to make basic component extensions Can be used for more advanced work, but at some point loses the benefits ActionScript Only Provides additional control, especially over startup conditions Everything learned about ActionScript components is applicable to MXML We are going to discuss ActionScript components How do you build custom components?
You need to make a decision on a base class Unless you are making something very different, you will probably start with an existing component class or the base class for Container or UIComponent Carousel starts with a Container as its primary function is to contain other children The extremes Why didn’t we use a Canvas? Why didn’t we just use UIComponent? How do we get started?
You need to understand the component lifecycle A lot of interaction with the Flex framework and the other components on the screen is going to happen To be a good component developer, you need to be on top of it all What are the next things to consider?
A series of methods called by the Flex Framework that every component experiences These methods include The component’s constructor commitProperties  method createChildren  method measure  method updateDisplayList  method What is the component lifecycle?
Setup initial properties Do things that need to be done regardless if the component is ever shown on the screen Do NOT do things like creating child components or attempting to position items… your component does not have enough information yet! The constructor is called whenever the component is created. The other methods we will discuss do not occur until a component is added to a container var blah:Button = new Button();  invokes the constructor container.addChild( blah );  adds child to a container Alright, what do we do in the constructor?
The one should be more obvious, it creates any visual children of the component I said creates… it does NOT size or position them… ever! Why? At this point your component does not know how much screen space it has…  Why try tell your children how big they can be when you don’t have this information yet? Why try to position them if you don’t know how big they are? And createChildren?
measure  brings us to my favorite part: the layout manager The layout manager is responsible for, among other things, ensuring that the process of sizing your component is started The layout manager always starts on the outer most component. To know how much space a component needs, you need to know how much space its children need Ok, what about measure?
To determine how much screen space they require, components call their  measure( ) method measure is responsible for setting four properties of the component measuredMinWidth measuredMinHeight measuredWidth measuredHeight The values form the basis of a ‘suggestion’ provided by the component to its parent about how big it would like to be When measure gets called, what does it do?
Yep, that’s where the  updateDisplayList()  comes in If all of the components collectively request 2000 pixels wide, but you only have 1000 on the screen… well something has to make this work When the  updateDisplayList  is called on a given component, it is passed an  unscaledWidth  and an  unscaledHeight ..  Basically, it is told ‘Regardless of what you requested, here is what you get’ While the Flex containers never choose to size one of their children smaller than the minimum requested size, you can do whatever you would like You are always free to ignore a component’s suggestion and make it any size you would like When a Flex container realizes it can not fit all of the components in the allotted space, it chooses to add scrollbars A suggestion?
updateDisplayList  is also responsible for positioning its children The method in which the Flex containers and components position their children is implicit in their type VBox - Vertical HBox – Horizontal DateField – Horizontal The method in which Carousel arranges its children is based on the equation of an circle What else does updateDisplayList do?
commitProperties  is responsible for coordinating property modifications Why coordinate properties? There are times when we need to wait to act until more than one property is set or is ready There are also times when we don’t want to do something complex every single time a change occurs (such as calculations).  commitProperties  allows us to defer some of these things until the screen needs to be redrawn How? commitProperties , just like  updateDisplayList , is ‘scheduled’ and called by the Flex framework when needed.  That leaves commitProperties
So, if these methods are only called when needed, how do we tell the framework they are needed? Invalidate methods invalidateDisplayList() invalidateProperties() invalidateSize() These methods tell the framework to ensure the method is called at the next appropriate time.  You may notice that there is no invalidateChildren… we only create children once, we don’t recreate them (ideally) for every property change What do you mean ‘when needed’?
Our  createChildren  calls the  super.createChildren()  as the default way the Container creates its children works for us We do add a few additional pieces to cover other aspects of the component that are unique The  super.createChildren  is often called last in a component… any thoughts as to why? Our commitProperties method is basic It is responsible for managing the changes to selectedChild, selectedIndex and currentPosition, which is an extremely important property in this component So how are these used in the Carousel?
Our  measure  method is unique. We need to consider how much space our container requires based on children being positioned around an circle in simulated 3D space.  We do a lot of math, but eventually still set the same four properties Our  updateDisplayList  method does all of the real work for this visual component. It considers: Spacing between items Scaling Ensuring items follow the circle as they move So how are these used in the Carousel?
Metadata tags provide information to the compiler and to Flex Builder Most people are familiar with the basic workings of the  [Bindable]  metadata, but there are others that are important to developing components Other useful metadata tags Style  – Specifies style sheet properties that can be assigned in MXML. Provides information to Flex Builder used in Design View. Inspectable  – Defines attributes that can be used by developers. It also limits values for properties. Flex Builder uses this information to provide possible values in code and design view. IconFile  – Defines an icon for your component that appears in Flex Builder. And all the lines that look like [Bindable]?
Flex Builder 3 offers some new advantages for the component developer You can now specify The way the component is categorized The standard view properties Default code So that’s how we work with Flex Builder?
You have all of the information now, it is just putting it in the right order Here is an overview The user changes the  selectedIndex  or  selectedChild We update some internal values and ask for a  commitProperties  call When we are called in  commitProperties , we determine the difference between where the newly  selectedItem  is and where it needs to be We start animating our way through the values from our currentPosition to our selectedIndex As the currentPosition, we set an internal value and ask for a  commitProperties  call When we are called in  commitProperties , we ask flex to redraw its children The  updateDisplayList  uses the currentPosition property to determine where each component should be moved and how it should be scaled So what makes Carousel work?
Questions, comments, clarifications? Contact [email_address] http://blogs.digitalprimates.net/codeSlinger/ Q & A?
Michael Labriola Senior Consultant  >>  Adobe Certified Instructor Adobe Community Expert  >>  Flex Community Champion digital primates  IT Consulting Group MAX 2007 CONNECT. DISCOVER. INSPIRE. Creating Custom Flex Components

More Related Content

What's hot (6)

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
krishmdkk
 
MATE: A Flex Framework - "Extreme Makeover"
MATE: A Flex Framework - "Extreme Makeover"MATE: A Flex Framework - "Extreme Makeover"
MATE: A Flex Framework - "Extreme Makeover"
Theo Rushin Jr
 
Test
TestTest
Test
guest25229c
 
Cis407 a ilab 7 web application development devry university
Cis407 a ilab 7 web application development devry universityCis407 a ilab 7 web application development devry university
Cis407 a ilab 7 web application development devry university
lhkslkdh89009
 
Windows Phone 8 - 8 Tiles and Lock Screen Notifications
Windows Phone 8 - 8 Tiles and Lock Screen NotificationsWindows Phone 8 - 8 Tiles and Lock Screen Notifications
Windows Phone 8 - 8 Tiles and Lock Screen Notifications
Oliver Scheer
 
Integrating external products into eclipse
Integrating external products into eclipseIntegrating external products into eclipse
Integrating external products into eclipse
Girish Balre
 
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
krishmdkk
 
MATE: A Flex Framework - "Extreme Makeover"
MATE: A Flex Framework - "Extreme Makeover"MATE: A Flex Framework - "Extreme Makeover"
MATE: A Flex Framework - "Extreme Makeover"
Theo Rushin Jr
 
Cis407 a ilab 7 web application development devry university
Cis407 a ilab 7 web application development devry universityCis407 a ilab 7 web application development devry university
Cis407 a ilab 7 web application development devry university
lhkslkdh89009
 
Windows Phone 8 - 8 Tiles and Lock Screen Notifications
Windows Phone 8 - 8 Tiles and Lock Screen NotificationsWindows Phone 8 - 8 Tiles and Lock Screen Notifications
Windows Phone 8 - 8 Tiles and Lock Screen Notifications
Oliver Scheer
 
Integrating external products into eclipse
Integrating external products into eclipseIntegrating external products into eclipse
Integrating external products into eclipse
Girish Balre
 

Viewers also liked (8)

Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
michael.labriola
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy
michael.labriola
 
Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehose
michael.labriola
 
Archives of the Columbia-Princeton Electronic Music Center
Archives of the Columbia-Princeton Electronic Music CenterArchives of the Columbia-Princeton Electronic Music Center
Archives of the Columbia-Princeton Electronic Music Center
Nick Patterson
 
Blaze Ds Slides
Blaze Ds SlidesBlaze Ds Slides
Blaze Ds Slides
michael.labriola
 
L2624 labriola
L2624 labriolaL2624 labriola
L2624 labriola
michael.labriola
 
Les nouveautés du Windows Runtime 8.1
Les nouveautés du Windows Runtime 8.1Les nouveautés du Windows Runtime 8.1
Les nouveautés du Windows Runtime 8.1
Microsoft
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
michael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
michael.labriola
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy
michael.labriola
 
Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehose
michael.labriola
 
Archives of the Columbia-Princeton Electronic Music Center
Archives of the Columbia-Princeton Electronic Music CenterArchives of the Columbia-Princeton Electronic Music Center
Archives of the Columbia-Princeton Electronic Music Center
Nick Patterson
 
Les nouveautés du Windows Runtime 8.1
Les nouveautés du Windows Runtime 8.1Les nouveautés du Windows Runtime 8.1
Les nouveautés du Windows Runtime 8.1
Microsoft
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
michael.labriola
 

Similar to 2007 Max Presentation - Creating Custom Flex Components (20)

Apocalypse Soon
Apocalypse SoonApocalypse Soon
Apocalypse Soon
michael.labriola
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructure
michael.labriola
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
Ahmad Hamid
 
WP7 HUB_Introducción a Silverlight
WP7 HUB_Introducción a SilverlightWP7 HUB_Introducción a Silverlight
WP7 HUB_Introducción a Silverlight
MICTT Palma
 
ASP.NET MVC3 RAD
ASP.NET MVC3 RADASP.NET MVC3 RAD
ASP.NET MVC3 RAD
Mădălin Ștefîrcă
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance Tips
Ravi Raj
 
React patterns
React patternsReact patterns
React patterns
Naimish Verma
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
Michael Palotas
 
The State of Front-end At CrowdTwist
The State of Front-end At CrowdTwistThe State of Front-end At CrowdTwist
The State of Front-end At CrowdTwist
Mark Fayngersh
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Michael Fons
 
The virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyThe virtual DOM and how react uses it internally
The virtual DOM and how react uses it internally
Clóvis Neto
 
Modular Web Design With Components
Modular Web Design With ComponentsModular Web Design With Components
Modular Web Design With Components
Nadal Soler
 
O365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - MaterialO365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - Material
Thomas Daly
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experiments
lacyrhoades
 
Building Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript SpaghettiBuilding Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript Spaghetti
Jared Faris
 
Module 5-Positioning and Navigation(Chapters 5 & 6).pptx
Module 5-Positioning and Navigation(Chapters 5 & 6).pptxModule 5-Positioning and Navigation(Chapters 5 & 6).pptx
Module 5-Positioning and Navigation(Chapters 5 & 6).pptx
kamalsmail1
 
What’s under your skin
What’s under your skinWhat’s under your skin
What’s under your skin
jeff tapper
 
Captivate 9 Features
Captivate 9 FeaturesCaptivate 9 Features
Captivate 9 Features
Aman Vohra
 
Berry 10 years_of_dita
Berry 10 years_of_ditaBerry 10 years_of_dita
Berry 10 years_of_dita
Mysti Berry
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructure
michael.labriola
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
Ahmad Hamid
 
WP7 HUB_Introducción a Silverlight
WP7 HUB_Introducción a SilverlightWP7 HUB_Introducción a Silverlight
WP7 HUB_Introducción a Silverlight
MICTT Palma
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance Tips
Ravi Raj
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
Michael Palotas
 
The State of Front-end At CrowdTwist
The State of Front-end At CrowdTwistThe State of Front-end At CrowdTwist
The State of Front-end At CrowdTwist
Mark Fayngersh
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Michael Fons
 
The virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyThe virtual DOM and how react uses it internally
The virtual DOM and how react uses it internally
Clóvis Neto
 
Modular Web Design With Components
Modular Web Design With ComponentsModular Web Design With Components
Modular Web Design With Components
Nadal Soler
 
O365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - MaterialO365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - Material
Thomas Daly
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experiments
lacyrhoades
 
Building Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript SpaghettiBuilding Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript Spaghetti
Jared Faris
 
Module 5-Positioning and Navigation(Chapters 5 & 6).pptx
Module 5-Positioning and Navigation(Chapters 5 & 6).pptxModule 5-Positioning and Navigation(Chapters 5 & 6).pptx
Module 5-Positioning and Navigation(Chapters 5 & 6).pptx
kamalsmail1
 
What’s under your skin
What’s under your skinWhat’s under your skin
What’s under your skin
jeff tapper
 
Captivate 9 Features
Captivate 9 FeaturesCaptivate 9 Features
Captivate 9 Features
Aman Vohra
 
Berry 10 years_of_dita
Berry 10 years_of_ditaBerry 10 years_of_dita
Berry 10 years_of_dita
Mysti Berry
 

More from michael.labriola (10)

Optimizing Browser Rendering
Optimizing Browser RenderingOptimizing Browser Rendering
Optimizing Browser Rendering
michael.labriola
 
Randori design goals and justification
Randori design goals and justificationRandori design goals and justification
Randori design goals and justification
michael.labriola
 
Talking trash
Talking trashTalking trash
Talking trash
michael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
michael.labriola
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributors
michael.labriola
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
michael.labriola
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Development
michael.labriola
 
Any Which Array But Loose
Any Which Array But LooseAny Which Array But Loose
Any Which Array But Loose
michael.labriola
 
Air Drag And Drop
Air Drag And DropAir Drag And Drop
Air Drag And Drop
michael.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 Waters
michael.labriola
 
Optimizing Browser Rendering
Optimizing Browser RenderingOptimizing Browser Rendering
Optimizing Browser Rendering
michael.labriola
 
Randori design goals and justification
Randori design goals and justificationRandori design goals and justification
Randori design goals and justification
michael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
michael.labriola
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributors
michael.labriola
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Development
michael.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 Waters
michael.labriola
 

Recently uploaded (20)

Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 

2007 Max Presentation - Creating Custom Flex Components

  • 1. Michael Labriola Senior Consultant >> Adobe Certified Instructor Adobe Community Expert >> Flex Community Champion digital primates IT Consulting Group MAX 2007 CONNECT. DISCOVER. INSPIRE. Creating Custom Flex Components
  • 2. How to create a custom component How to do it in a style that fits with the Flex Framework How to make it work well with Flex Builder What are we going to cover?
  • 3. Examine the Carousel component Talk about the decisions that influenced its design Discuss the way it was built How are we going to do that?
  • 4. We are going to review a lot of code We are going to move quickly We will provide time for Q&A at the end, but we can also be interactive Ask questions when they occur and I will try to answer inline What can we expect?
  • 5. You build components when you need something reusable that encapsulates behavior There are generally two reasons components are built To tweak existing components Tweaking behavior Changing default values Usually involves a higher level base class, Button, Vbox, etc. To create something very different than the standard components Usually involves a lower level class such as Container or UIComponent May involve going all the way to Sprite or ‘lowest’ level UI classes Why build custom components?
  • 6. You have two main choices in Flex MXML with ActionScript Quick and easy to make basic component extensions Can be used for more advanced work, but at some point loses the benefits ActionScript Only Provides additional control, especially over startup conditions Everything learned about ActionScript components is applicable to MXML We are going to discuss ActionScript components How do you build custom components?
  • 7. You need to make a decision on a base class Unless you are making something very different, you will probably start with an existing component class or the base class for Container or UIComponent Carousel starts with a Container as its primary function is to contain other children The extremes Why didn’t we use a Canvas? Why didn’t we just use UIComponent? How do we get started?
  • 8. You need to understand the component lifecycle A lot of interaction with the Flex framework and the other components on the screen is going to happen To be a good component developer, you need to be on top of it all What are the next things to consider?
  • 9. A series of methods called by the Flex Framework that every component experiences These methods include The component’s constructor commitProperties method createChildren method measure method updateDisplayList method What is the component lifecycle?
  • 10. Setup initial properties Do things that need to be done regardless if the component is ever shown on the screen Do NOT do things like creating child components or attempting to position items… your component does not have enough information yet! The constructor is called whenever the component is created. The other methods we will discuss do not occur until a component is added to a container var blah:Button = new Button(); invokes the constructor container.addChild( blah ); adds child to a container Alright, what do we do in the constructor?
  • 11. The one should be more obvious, it creates any visual children of the component I said creates… it does NOT size or position them… ever! Why? At this point your component does not know how much screen space it has… Why try tell your children how big they can be when you don’t have this information yet? Why try to position them if you don’t know how big they are? And createChildren?
  • 12. measure brings us to my favorite part: the layout manager The layout manager is responsible for, among other things, ensuring that the process of sizing your component is started The layout manager always starts on the outer most component. To know how much space a component needs, you need to know how much space its children need Ok, what about measure?
  • 13. To determine how much screen space they require, components call their measure( ) method measure is responsible for setting four properties of the component measuredMinWidth measuredMinHeight measuredWidth measuredHeight The values form the basis of a ‘suggestion’ provided by the component to its parent about how big it would like to be When measure gets called, what does it do?
  • 14. Yep, that’s where the updateDisplayList() comes in If all of the components collectively request 2000 pixels wide, but you only have 1000 on the screen… well something has to make this work When the updateDisplayList is called on a given component, it is passed an unscaledWidth and an unscaledHeight .. Basically, it is told ‘Regardless of what you requested, here is what you get’ While the Flex containers never choose to size one of their children smaller than the minimum requested size, you can do whatever you would like You are always free to ignore a component’s suggestion and make it any size you would like When a Flex container realizes it can not fit all of the components in the allotted space, it chooses to add scrollbars A suggestion?
  • 15. updateDisplayList is also responsible for positioning its children The method in which the Flex containers and components position their children is implicit in their type VBox - Vertical HBox – Horizontal DateField – Horizontal The method in which Carousel arranges its children is based on the equation of an circle What else does updateDisplayList do?
  • 16. commitProperties is responsible for coordinating property modifications Why coordinate properties? There are times when we need to wait to act until more than one property is set or is ready There are also times when we don’t want to do something complex every single time a change occurs (such as calculations). commitProperties allows us to defer some of these things until the screen needs to be redrawn How? commitProperties , just like updateDisplayList , is ‘scheduled’ and called by the Flex framework when needed. That leaves commitProperties
  • 17. So, if these methods are only called when needed, how do we tell the framework they are needed? Invalidate methods invalidateDisplayList() invalidateProperties() invalidateSize() These methods tell the framework to ensure the method is called at the next appropriate time. You may notice that there is no invalidateChildren… we only create children once, we don’t recreate them (ideally) for every property change What do you mean ‘when needed’?
  • 18. Our createChildren calls the super.createChildren() as the default way the Container creates its children works for us We do add a few additional pieces to cover other aspects of the component that are unique The super.createChildren is often called last in a component… any thoughts as to why? Our commitProperties method is basic It is responsible for managing the changes to selectedChild, selectedIndex and currentPosition, which is an extremely important property in this component So how are these used in the Carousel?
  • 19. Our measure method is unique. We need to consider how much space our container requires based on children being positioned around an circle in simulated 3D space. We do a lot of math, but eventually still set the same four properties Our updateDisplayList method does all of the real work for this visual component. It considers: Spacing between items Scaling Ensuring items follow the circle as they move So how are these used in the Carousel?
  • 20. Metadata tags provide information to the compiler and to Flex Builder Most people are familiar with the basic workings of the [Bindable] metadata, but there are others that are important to developing components Other useful metadata tags Style – Specifies style sheet properties that can be assigned in MXML. Provides information to Flex Builder used in Design View. Inspectable – Defines attributes that can be used by developers. It also limits values for properties. Flex Builder uses this information to provide possible values in code and design view. IconFile – Defines an icon for your component that appears in Flex Builder. And all the lines that look like [Bindable]?
  • 21. Flex Builder 3 offers some new advantages for the component developer You can now specify The way the component is categorized The standard view properties Default code So that’s how we work with Flex Builder?
  • 22. You have all of the information now, it is just putting it in the right order Here is an overview The user changes the selectedIndex or selectedChild We update some internal values and ask for a commitProperties call When we are called in commitProperties , we determine the difference between where the newly selectedItem is and where it needs to be We start animating our way through the values from our currentPosition to our selectedIndex As the currentPosition, we set an internal value and ask for a commitProperties call When we are called in commitProperties , we ask flex to redraw its children The updateDisplayList uses the currentPosition property to determine where each component should be moved and how it should be scaled So what makes Carousel work?
  • 23. Questions, comments, clarifications? Contact [email_address] http://blogs.digitalprimates.net/codeSlinger/ Q & A?
  • 24. Michael Labriola Senior Consultant >> Adobe Certified Instructor Adobe Community Expert >> Flex Community Champion digital primates IT Consulting Group MAX 2007 CONNECT. DISCOVER. INSPIRE. Creating Custom Flex Components