SlideShare uma empresa Scribd logo
1 de 24
Flex Component Lifecycle Kevin Schmidt | LiveCycle Solutions Engineer | kevins@adobe.com | @schmidtkevinall
Vocab Lesson  Flex Component Lifecycle A mechanism the framework uses to create, manage and destroy components A mechanism that makes the most of the player rendering model.  Halo:Component architecture used in Flex 3 and earlier versions.  Spark: Spark is the component and skinning architecture in Flex 4.  Spark is built on top of Halo.  Parts:Internal parts of a component that are composited together to create a whole component.  Composition is the name of the game.
Halo Component Architecture Patterns  Defining Patterns in Halo Invalidation/Validation Model  Methodology to aggregate changes and defer work until an optimal later time  Event Driven Interaction Model  Inform the component if something is about to or has already occurred  Composition  Parameterization of a component’s appearance or content.  Most often occurs through factories and item renderers.
Halo Component Lifecycle – Broken Down  3 Phase Lifecycle Initialization Construction Configuration Attachment Initialization Updating  Component responds to changes by using the Invalidation/Validation Model  Destruction  Out of sight, out of mind  Detachment  Garbage collection
Lifecycle Phase 1: Initialization  Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Construction: Component begins its lifecycle  Decide on the right base-class  Component is instantiated, through the new operator in ActionScript or in markup Constructor must have zero required arguments Constructor can add event listeners, hard code initialization properties of super classes Minimal work should occur here.
Lifecycle Phase 1: Initialization  Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Configuration: Component properties are set internally to be processed later Property values are assigned before parts are attached or initialized to avoid duplicate code execution.  Properties must expect that parts haven’t been created yet.
Lifecycle Phase 1: Initialization  Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Attachment: Addition to the display list  Component is added to the display list through an addChild() call by its parent.  Without attachment, component lifecycle will stall.
Lifecycle Phase 1: Initialization  Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Initialization 	Full invalidation/validation cycle is invoked (we will come back to this)  	5 main lifecycle actions occur at this step:  preinitializeevent is dispatched createChildren() is called initialize event is dispatched  First full invalidation/validation pass occurs creationCompleteevent is dispatched
Lifecycle Phase 1: Initialization  Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 createChildren() - The attachment workhorse  Ideal place for adding children that are required throughout the lifetime of the component  Dynamic or data-driven parts which should be added in commitProperties() Check to make sure the children have not been instantiated already Follow the same pattern Flex uses: construct, configure, attach.  Halo Rules:  UIComponents can contain anything (Sprites, Shapes, MovieClips, Video, etc). UIComponentsmustgo inside other UIComponents Containers must contain only UIComponents
Lifecycle Phase 1: Initialization  Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 First full invalidation/validation pass occurs here Invalidation is captured by 3 methods: invalidateProperties() invalidateSize() invalidateDisplayList() Validation is captured by 3 methods: commitProperties() measure() updateDisplayList()  Phase 1 Done!
Phase 2: Updating Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Our component has been created!  It’s a living, breathing entity, and now it needs to know how to update.  Updates occur When a user interacts with a component When methods or properties are invoked/set  A component should use Flex’s Invalidation/Validation Model to respond to changes.
The Elastic Racetrack  Traditional Flash Player Elastic Racetrack Images courtesy of Sean Christmann Flex component lifecycle is built atop this frame model Invalidation/Validation takes advantage of the elastic racetrack to get work done in an efficient manner.
Deferred Validation Model Waiting for update request Validation occurs right before Rendering Update Requested Invalidation Validation
Deferred Validation Model: An Optimization  Invalidation/validation model is split into 3 phases: Update component properties Update sizing & measurement information Update drawing and positioning commitProperties() invalidateProperties()  invalidateSize()  measure() invalidateDisplayList()  updateDisplayList()
commitProperties() Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Property management phase of validation Purpose: Commit values typically set using a property setter Invoked by the framework before measurement and layout.  There is a definite pattern that should be followed in order to avoid extra work.  Dirty flags and storage variables  This is the place to add/remove children not required through the life of the entire component (as opposed to createChildren())
measure() Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Sizing phase of validation Purpose: Component can calculate its ‘natural’ size based on content and layout rules. Implicitly invoked when component children change size. (Don’t call measure() on your children).  Measurement occurs from the bottom up.  			<mx:Application> 				<mx:HBox> 				            <mx:Button /> 				</mx:HBox> 			</mx:Application> Don’t count on it: Framework optimizes away unnecessary calls to measure(). The measure() function calculates and sets four properties: measuredWidth, measuredHeight measuredMinWidth, measuredMinHeight To get up and running fast, explicitly size your component.
updateDisplayList() Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection	 	 Layout and Drawing Phase of Invalidation  Purpose: Lay out component contents and perform any drawing Layout and positioning occurs from the top down, given:  			<mx:Application> 				<mx:HBox> 				            <mx:Button /> 				</mx:HBox> 			</mx:Application> In updateDisplayList() you must set position and size of each child If the child is a UIComponent, size it with setActualSize() and position it with move() If the child is not a UIComponent, set the x, y, width and height properties.  Good place to use Flash Player Drawing API
Styles  Style support is built into UIComponent Add Style metadata so the style can be set inline as an attribute in MXML Set default initial value in user’s application or defaults.css Override styleChanged() to codify how the component should react when a style has changed.  Check which style has changed and call the right invalidation method If it has more to do with presentation it should be a style.  If you have a constant related to presentation, it should be a style
Events in Flex  Components dispatch and listen to events  Add Event metadata to allow event to be set inline as an attribute in MXML Use custom Event classes  Define static constants to enable compile-time checking of event types.  If you dispatch the same event as a base class, you must use the same event class. Tip: Chose descriptive event names.
Phase 3: Destruction  Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Destroying the component  Detachment: Remove the component from the display list Components do not get validated or drawn when off the display list  Once off the display list:  You can re-parent the component, and it will be brought back to life.  Re-parenting is cheaper then re-instantiating a component  Garbage Collection No active references can be tough Common culprits include event listeners, dictionaries and timers.
Component Architecture Patterns  Defining Patterns in Halo Invalidation/Validation Model  Event Driven Interaction Model   Composition  Defining Patterns in Spark Clean separation of component logic from its visuals Spark Skinning Architecture  Component functionality can be composited together to build up or pare down. Designer/Developer contract maintained by data, parts and states Component makes no assumptions about appearance Skin doesn’t require digging into code
Time to Sparker-cise! Step 1: Sit down and think What is the core essence of the component? Step 2: Identify skin parts Which are required, which are optional?  Step 3: Add in Spark-specific code Chose a proper base-class  Implement partAdded(), partRemoved() Decide on the proper set of states Author a skin that includes skin parts.   Skins are associated with components through CSS  Skins use MXML Graphics  Step 4: Yank out Halo-specific code Rip out createChildren(), measure() and updateDisplayList() *
In Conclusion… ,[object Object]
Questions?

Mais conteúdo relacionado

Mais procurados

Rc085 010d-vaadin7
Rc085 010d-vaadin7Rc085 010d-vaadin7
Rc085 010d-vaadin7Cosmina Ivan
 
New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11Ramu Palanki
 
New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11G.C Reddy
 
Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test Gregory Solovey
 
QTP Training by INFOTECH
QTP Training by INFOTECHQTP Training by INFOTECH
QTP Training by INFOTECHPravinsinh
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
Less01 1 introduction_module
Less01 1 introduction_moduleLess01 1 introduction_module
Less01 1 introduction_moduleSuresh Mishra
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_completebinuiweb
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test AutomationDmitry Buzdin
 
Less09 2 e_testermodule_8
Less09 2 e_testermodule_8Less09 2 e_testermodule_8
Less09 2 e_testermodule_8Suresh Mishra
 

Mais procurados (14)

Rc085 010d-vaadin7
Rc085 010d-vaadin7Rc085 010d-vaadin7
Rc085 010d-vaadin7
 
New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11
 
Lab4 RTC Builds
Lab4 RTC BuildsLab4 RTC Builds
Lab4 RTC Builds
 
New features in qtp11
New features in qtp11New features in qtp11
New features in qtp11
 
Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test
 
QTP Functions
QTP FunctionsQTP Functions
QTP Functions
 
Resource lab
Resource labResource lab
Resource lab
 
QTP Training by INFOTECH
QTP Training by INFOTECHQTP Training by INFOTECH
QTP Training by INFOTECH
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
70 499
70 49970 499
70 499
 
Less01 1 introduction_module
Less01 1 introduction_moduleLess01 1 introduction_module
Less01 1 introduction_module
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_complete
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test Automation
 
Less09 2 e_testermodule_8
Less09 2 e_testermodule_8Less09 2 e_testermodule_8
Less09 2 e_testermodule_8
 

Semelhante a Flex component lifecycle

Building Components In Flex3
Building Components In Flex3Building Components In Flex3
Building Components In Flex3Tikal Knowledge
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface ComponentsAhmad Hamid
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期增强 杜
 
Flex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle PracticeFlex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle Practicejexchan
 
Fundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfStephieJohn
 
Invalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your CraniumInvalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your Craniumsakrirosenstrom
 
React Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptxReact Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptxBOSC Tech Labs
 
What’s under your skin
What’s under your skinWhat’s under your skin
What’s under your skinjeff tapper
 
Salesforce lwc development workshops session #6
Salesforce lwc development workshops  session #6Salesforce lwc development workshops  session #6
Salesforce lwc development workshops session #6Rahul Gawale
 
Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder BurritoJeff Bollinger
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDmitry Vinnik
 
3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS Components3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS ComponentsSurendra kumar
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universitylhkslkdh89009
 
Exploring Adobe Flex
Exploring Adobe Flex Exploring Adobe Flex
Exploring Adobe Flex senthil0809
 

Semelhante a Flex component lifecycle (20)

Building Components In Flex3
Building Components In Flex3Building Components In Flex3
Building Components In Flex3
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期
 
Test
TestTest
Test
 
Flex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle PracticeFlex Custom Component Lifecycle Practice
Flex Custom Component Lifecycle Practice
 
Fundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdf
 
Invalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your CraniumInvalidation Routines Pounded Into Your Cranium
Invalidation Routines Pounded Into Your Cranium
 
React Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptxReact Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptx
 
What’s under your skin
What’s under your skinWhat’s under your skin
What’s under your skin
 
Salesforce lwc development workshops session #6
Salesforce lwc development workshops  session #6Salesforce lwc development workshops  session #6
Salesforce lwc development workshops session #6
 
Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder Burrito
 
MVC Training Part 2
MVC Training Part 2MVC Training Part 2
MVC Training Part 2
 
Flex 4 tips
Flex 4 tipsFlex 4 tips
Flex 4 tips
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 
3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS Components3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS Components
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry university
 
Actionview
ActionviewActionview
Actionview
 
Exploring Adobe Flex
Exploring Adobe Flex Exploring Adobe Flex
Exploring Adobe Flex
 
Flash Testing with Selenium RC
Flash Testing with Selenium RCFlash Testing with Selenium RC
Flash Testing with Selenium RC
 

Último

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Flex component lifecycle

  • 1. Flex Component Lifecycle Kevin Schmidt | LiveCycle Solutions Engineer | kevins@adobe.com | @schmidtkevinall
  • 2. Vocab Lesson Flex Component Lifecycle A mechanism the framework uses to create, manage and destroy components A mechanism that makes the most of the player rendering model. Halo:Component architecture used in Flex 3 and earlier versions. Spark: Spark is the component and skinning architecture in Flex 4. Spark is built on top of Halo. Parts:Internal parts of a component that are composited together to create a whole component. Composition is the name of the game.
  • 3. Halo Component Architecture Patterns Defining Patterns in Halo Invalidation/Validation Model Methodology to aggregate changes and defer work until an optimal later time Event Driven Interaction Model Inform the component if something is about to or has already occurred Composition Parameterization of a component’s appearance or content. Most often occurs through factories and item renderers.
  • 4. Halo Component Lifecycle – Broken Down 3 Phase Lifecycle Initialization Construction Configuration Attachment Initialization Updating Component responds to changes by using the Invalidation/Validation Model Destruction Out of sight, out of mind Detachment Garbage collection
  • 5. Lifecycle Phase 1: Initialization Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Construction: Component begins its lifecycle Decide on the right base-class Component is instantiated, through the new operator in ActionScript or in markup Constructor must have zero required arguments Constructor can add event listeners, hard code initialization properties of super classes Minimal work should occur here.
  • 6. Lifecycle Phase 1: Initialization Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Configuration: Component properties are set internally to be processed later Property values are assigned before parts are attached or initialized to avoid duplicate code execution. Properties must expect that parts haven’t been created yet.
  • 7. Lifecycle Phase 1: Initialization Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Attachment: Addition to the display list Component is added to the display list through an addChild() call by its parent. Without attachment, component lifecycle will stall.
  • 8. Lifecycle Phase 1: Initialization Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Initialization Full invalidation/validation cycle is invoked (we will come back to this) 5 main lifecycle actions occur at this step: preinitializeevent is dispatched createChildren() is called initialize event is dispatched First full invalidation/validation pass occurs creationCompleteevent is dispatched
  • 9. Lifecycle Phase 1: Initialization Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection createChildren() - The attachment workhorse Ideal place for adding children that are required throughout the lifetime of the component Dynamic or data-driven parts which should be added in commitProperties() Check to make sure the children have not been instantiated already Follow the same pattern Flex uses: construct, configure, attach. Halo Rules: UIComponents can contain anything (Sprites, Shapes, MovieClips, Video, etc). UIComponentsmustgo inside other UIComponents Containers must contain only UIComponents
  • 10. Lifecycle Phase 1: Initialization Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection First full invalidation/validation pass occurs here Invalidation is captured by 3 methods: invalidateProperties() invalidateSize() invalidateDisplayList() Validation is captured by 3 methods: commitProperties() measure() updateDisplayList() Phase 1 Done!
  • 11. Phase 2: Updating Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Our component has been created! It’s a living, breathing entity, and now it needs to know how to update. Updates occur When a user interacts with a component When methods or properties are invoked/set A component should use Flex’s Invalidation/Validation Model to respond to changes.
  • 12. The Elastic Racetrack Traditional Flash Player Elastic Racetrack Images courtesy of Sean Christmann Flex component lifecycle is built atop this frame model Invalidation/Validation takes advantage of the elastic racetrack to get work done in an efficient manner.
  • 13. Deferred Validation Model Waiting for update request Validation occurs right before Rendering Update Requested Invalidation Validation
  • 14. Deferred Validation Model: An Optimization Invalidation/validation model is split into 3 phases: Update component properties Update sizing & measurement information Update drawing and positioning commitProperties() invalidateProperties() invalidateSize() measure() invalidateDisplayList() updateDisplayList()
  • 15. commitProperties() Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Property management phase of validation Purpose: Commit values typically set using a property setter Invoked by the framework before measurement and layout. There is a definite pattern that should be followed in order to avoid extra work. Dirty flags and storage variables This is the place to add/remove children not required through the life of the entire component (as opposed to createChildren())
  • 16. measure() Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Sizing phase of validation Purpose: Component can calculate its ‘natural’ size based on content and layout rules. Implicitly invoked when component children change size. (Don’t call measure() on your children). Measurement occurs from the bottom up. <mx:Application> <mx:HBox> <mx:Button /> </mx:HBox> </mx:Application> Don’t count on it: Framework optimizes away unnecessary calls to measure(). The measure() function calculates and sets four properties: measuredWidth, measuredHeight measuredMinWidth, measuredMinHeight To get up and running fast, explicitly size your component.
  • 17. updateDisplayList() Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Layout and Drawing Phase of Invalidation Purpose: Lay out component contents and perform any drawing Layout and positioning occurs from the top down, given: <mx:Application> <mx:HBox> <mx:Button /> </mx:HBox> </mx:Application> In updateDisplayList() you must set position and size of each child If the child is a UIComponent, size it with setActualSize() and position it with move() If the child is not a UIComponent, set the x, y, width and height properties. Good place to use Flash Player Drawing API
  • 18. Styles Style support is built into UIComponent Add Style metadata so the style can be set inline as an attribute in MXML Set default initial value in user’s application or defaults.css Override styleChanged() to codify how the component should react when a style has changed. Check which style has changed and call the right invalidation method If it has more to do with presentation it should be a style. If you have a constant related to presentation, it should be a style
  • 19. Events in Flex Components dispatch and listen to events Add Event metadata to allow event to be set inline as an attribute in MXML Use custom Event classes Define static constants to enable compile-time checking of event types. If you dispatch the same event as a base class, you must use the same event class. Tip: Chose descriptive event names.
  • 20. Phase 3: Destruction Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection Destroying the component Detachment: Remove the component from the display list Components do not get validated or drawn when off the display list Once off the display list: You can re-parent the component, and it will be brought back to life. Re-parenting is cheaper then re-instantiating a component Garbage Collection No active references can be tough Common culprits include event listeners, dictionaries and timers.
  • 21. Component Architecture Patterns Defining Patterns in Halo Invalidation/Validation Model Event Driven Interaction Model Composition Defining Patterns in Spark Clean separation of component logic from its visuals Spark Skinning Architecture Component functionality can be composited together to build up or pare down. Designer/Developer contract maintained by data, parts and states Component makes no assumptions about appearance Skin doesn’t require digging into code
  • 22. Time to Sparker-cise! Step 1: Sit down and think What is the core essence of the component? Step 2: Identify skin parts Which are required, which are optional? Step 3: Add in Spark-specific code Chose a proper base-class Implement partAdded(), partRemoved() Decide on the proper set of states Author a skin that includes skin parts. Skins are associated with components through CSS Skins use MXML Graphics Step 4: Yank out Halo-specific code Rip out createChildren(), measure() and updateDisplayList() *
  • 23.
  • 28.