Flex Component Life-cycle. What is it? Sequence of steps that occur when you create a component object from a component class. As part of this process,

Slides:



Advertisements
Similar presentations
Drawing, Skinning and Degrafa This presentation covers drawing, skinning and the use of Degrafa to make things easier. Understanding the basics of drawing.
Advertisements

Introduction to Macromedia Director 8.5 – Lingo
AS3: Events & Listeners eventListeners in ActionScript 3.
Feature requests for Case Manager By Spar Nord Bank A/S IBM Insight 2014 Spar Nord Bank A/S1.
® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Flex Component Lifecycle: Halo and Spark Deepa Subramaniam Flex SDK
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Lesson 8 Creating Forms with JavaScript
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
Ranga Rodrigo. Class is central to object oriented programming.
1 Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Workflow Manager and General Tuning Tips. Topics to discuss… Working with Workflows Working with Tasks General Tuning Tips.
Flex data binding pitfalls: 10 common misuses and
Tutorial 11 Using and Writing Visual Basic for Applications Code
Tutorial 5 Making a Document Interactive. XP Objectives Explore the different button states Add a button from the Button library Create a button Learn.
Tutorial 5 Making a Document Interactive. XP Objectives Explore the different button states Add a button from the Buttons library Edit a button instance.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
Unit and Functional Testing Your Flex Applications Mike Nimer Dir. Of Engineering nomee.com.
Parsley Introduction Kui Huang Oct. 13, Topics Background Dependency Injection Object Lifecycle Message Bus Sample FW Extensions.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
PROG Mobile Java Application Development PROG Mobile Java Application Development BlackBerry App Lifecycle Java ME API.
Developing the Game User Interface (UI) Lesson 5.
Chapter 8 iComponents and Parameters. After completing this chapter, you will be able to perform the following: –Create iMates –Change the display of.
Developing Flash MX 2004 Components Using the Version 2 Architecture CFUN-04 Chafic Kazoun, Senior Flash Developer B-Line Express:
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Getting a handle on ActionScript A basic primer for non-programmers.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 8 Objects and Classes.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
Working with option button, check box, and list box controls Visual Basic for Applications 13.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
SWING IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Flexible hierarchy design proposal. Flexible hierarchy design  Goals  Allow debug plugins to define their own debug element hierarchy and behaviour.
WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First Application Designer Basics.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
Present by Wu Kun-Tse Simplifying Preference Pages with Field Editors.
CISC 110 Day 5 OOP Part 2. 2 Outline The Display List Display List Classes Adding and Removing Objects Adding Symbol Instances Managing Object Depths.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
JavaScript, Fourth Edition
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
OBSERVER DESIGN PATTERN. Behavioral Patterns  Behavioral patterns are those patterns that are most specifically concerned with communication between.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
2006 Adobe Systems Incorporated. All Rights Reserved. 1 Flex for Flash Developers Sho Kuwamoto Sr. Director, Engineering Adobe Systems, Inc.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
CSC 2720 Building Web Applications FLEX – Data Binding.
Chapter 14: Introduction to Swing Components. Objectives Understand Swing components Use the JFrame class Use the JLabel class Use a layout manager Extend.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Using Workflow With Dataforms Tim Borntreger, Director of Client Services.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Adding Code to the Option Button. Open VB 1.Double click the Calculate button and select General from the Object list box. 2.Add the following code to.
Programming in AS3. AS3 vs MXML MXML is content/structure AS3 ties in with the MXML to create the a functioning program.
® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Creating New Components in Flex 3 and Beyond Deepa Subramaniam Flex SDK
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Visual Basic.NET BASICS Lesson 9 Nested If Statements and Radio Buttons.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
1 float Data Type Data type that can hold numbers with decimal values – e.g. 3.14, 98.6 Floats can be used to represent many values: –Money (but see warning.
Data Binding, Binding Properties Doncho Minkov Telerik School Academy Technical Trainer
A First Look at GUI Applications Radio Buttons and Check Boxes
JavaScript and Events.
More Selections BIS1523 – Lecture 9.
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
PCP Super User.
Tom Link CTO, Universal Mind
Presentation transcript:

Flex Component Life-cycle

What is it? Sequence of steps that occur when you create a component object from a component class. As part of this process, Flex automatically calls component methods, dispatches events, and makes the component visible.

Component Life-cycle steps Creation Construction Configuration Attachment Initialization Life Invalidation Validation

Creation – Construction Purpose Create an instance of a component class Configure the object by setting its initial properties Examples In Actionscript: var b:Button = new Button(); b.label = test; b.addEventListener(MouseEvent.CLICK, onClick); In MXML

Creation – Configuration Purpose Set initial properties with setters Generic setter features Check to see if the value has changed Set a private instance of the value Set a boolean flag to indicate the property has changed Schedule component for invalidation (if necessary) Dispatch binding events (optional) Adobe does this in their component framework.

Creation – Configuration Check to see if the value has changed private var _label:String = ; private var _labelChanged:Boolean = false; public function set label (value:String):void { if (_label != value) { } }

Creation – Configuration Set a private instance of the new value private var _label:String = ; private var _labelChanged:Boolean = false; public function set label (value:String):void { if (_label != value) { _label = value; } }

Creation – Configuration Set a boolean flag to indicate the value change private var _label:String = ; private var _labelChanged:Boolean = false; public function set label (value:String):void { if (_label != value) { _label = value; _labelChanged = true; } }

Creation – Configuration Schedule component for invalidation (optional) private var _label:String = ; private var _labelChanged:Boolean = false; public function set label (value:String):void { if (_label != value) { _label = value; _labelChanged = true; invalidateProperties(); invalidateSize(); invalidateDisplayList(); } }

Creation – Configuration Dispatch binding events (optional) private var _label:String = ; private var _labelChanged:Boolean = false; public function set label (value:String):void { if (_label != value) { _label = value; _labelChanged = true; invalidateProperties(); invalidateSize(); invalidateDisplayList(); dispatchEvent(new Event(labelChanged)); } }

Creation – Configuration Dispatch binding events (optional) [Bindable(labelChanged)] public function get label ():String { return _label; }

Creation – Attachment Purpose Attach the component to the display list. Component life-cycle is stalled after configuration until attachment occurs In Actionscript: panel.addChild(button); In MXML: Don't need to do anything, the child is automatically added according to how it is nested.

Creation – Initialization Consists of 1 life-cycle phase and 3 events preinitialize event is dispatched on the component Component is in a very raw state. Its children have not yet been added (including internal children) Use this event in rare circumstances (set the properties on a parent before the children are created) createChildren() method is called by Flex on the component override this method from UIComponent Add child components that make up your custom component Construct component, set properties, add to display list

Creation – Initialization Consists of 1 life-cycle phase and 3 events initialize event is dispatched At this point, the component's children have been added and the component's initial properties are set, but it has not been sized, positioned, or processed for layout Use this event to perform additional processing before layout childAdd event is dispatched from parent If the parent is also being initialized, its initialize event is dispatched when all of its children are added.

Life – Invalidation Deferred Validation Flex uses a deferred validation for rendering components in their various states Central concept in the component life-cycle Use private variables and boolean flags to defer setting any render-related properties until the proper validation method is reached

Life – Invalidation Deferred Validation 3 methods that trigger validation methods invalidateProperties() --> commitProperties() Use this to set any of the component's properties invalidateSize() --> measure() Use this to change the component's default size invalidateDisplayList() --> updateDisplayList() Use this to change the component's size or position

Life – Validation Purpose Apply the changes deferred until validation 3 Phases occur in validation commitProperties() measure() updateDisplayList()

Life – Validation commitProperties() Purpose Commit any changes to component properties Synchronize changes to occur at the same time or ensure that they are set in a specific order When is it called? Immediately after the initialize event during component creation Whenever invalidateProperties() is called What is its phase order This method is called before measure() or updateDisplayList() This allows you to set property values that influence size or position

Life – Validation commitProperties() Example

Life – Validation measure() Purpose Calculate the component's preferred width and height and its preferred minimum width and height When is it called? After commitProperties() during initialization When the invalidateSize() method is called NOTE: measure() will never be called if the component is given an explicit width or height What is its phase order? After commitProperties() and before updateDisplayList()

Life – Validation measure() Caveats Only 4 properties should normally be set in measure() measuredHeight The default height of the component measuredWidth The default width of the component measuredMinHeight The default minimum height of the component measuredMinWidth The default minimum width of the component Use getExplicitOrMeasuredHeight() and getExplicitOrMeasuredWidth() to get child proportions.

Life – Validation measure() Example

Life – Validation updateDisplayList() Purpose To position and size children Allow use of the Drawing API to draw on the component When is it called? After measure() during the initialization process When invalidateDisplayList() is called What is it's order? After measure()

Life – Validation updateDisplayList() Caveats Position children using move(x, y), size them using setActualSize(width, height) instead of using the x, y, width, height properties Adobe recommends these methods because they work better with Container layouts. These methods are said to be quirky at times, so if they don't work for some reason just set the properties manually.

Life – Validation updateDisplayList() unscaledWidth, unscaledHeight Arguments for updateDisplayList() Indicate the width and height of the component as dictated by its parent. They do not take scaleX and scaleY properties into account, so you will have to calculate scaling manually if needs be. updateComplete event is dispatched by the component after its updateDisplayList() is executed Use this event for actions that must be performed each time a component's characteristics change, not just when it is created.

Life – Validation updateDisplayList() Example