® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Creating New Components in Flex 3 and Beyond Deepa Subramaniam Flex SDK

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

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,
Introduction to Macromedia Director 8.5 – Lingo
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
TU e technische universiteit eindhoven / department of mathematics and computer science Modeling User Input and Hypermedia Dynamics in Hera Databases and.
Spring Semester 2013 Lecture 5
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Flex Component Lifecycle: Halo and Spark Deepa Subramaniam Flex SDK
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
UPortal: A framework for the Personalization of Library Services John Fereira: Programmer/Analyst Cornell University Mann Library.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation.
Sequence Diagram Tutorial
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Flex data binding pitfalls: 10 common misuses and
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
Building Search Portals With SP2013 Search. 2 SharePoint 2013 Search  Introduction  Changes in the Architecture  Result Sources  Query Rules/Result.
Parsley Introduction Kui Huang Oct. 13, Topics Background Dependency Injection Object Lifecycle Message Bus Sample FW Extensions.
Publishing a Macromedia Flash Movie – Lesson 131 Publishing a Macromedia Flash Movie Lesson 13.
10/4/2015Tables1 Spring, 2008 Modified by Linda Kenney 4/2/08.
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,
© 2012 Adobe Systems Incorporated. All Rights Reserved. Copyright 2012 Adobe Systems Incorporated. All rights reserved. ® INTRODUCTION TO FLASH ANIMATION.
® Copyright 2010 Adobe Systems Incorporated. All rights reserved. ® ® 1 INTRODUCTION TO ADOBE FLASH PROFESSIONAL CS5.
Putting together a complete system Chapter 10. Overview  Design a modest but complete system  A collection of objects work together to solve a problem.
PROG Mobile Java Application Development PROG Mobile Java Application Development BlackBerry App Lifecycle Java ME API.
Developing Flash MX 2004 Components Using the Version 2 Architecture CFUN-04 Chafic Kazoun, Senior Flash Developer B-Line Express:
2006 Adobe Systems Incorporated. All Rights Reserved. 1 Flex architectural patterns James Ward Technical Evangelist
Agency Overview0 0Presentation Title Flex Hands-On Experience Kristen Olsen Web Systems Engineer September 27, 2008.
® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential.1 Moving from Flex 3 to Flex 4 The Good, the Bad, and the Ugly… Joan.
Description, Classes, Interfaces, Hierarchy, Specifics George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Component frameworks Roy Kensmil. Historical trens in software development. ABSTRACT INTERACTIONS COMPONENT BUS COMPONENT GLUE THIRD-PARTY BINDING.
Lecture 3 Uses Cases Topics UML Use Cases pop quiz Readings: Chapter 3 January 24, 2008 CSCE 492 Software Engineering.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Flex 2 We’re Not in Kansas Anymore! or Welcome to Flex Theo Rushin Jr TeraTech, Inc.
Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
Porting methodology Porting of an WEB Site using PTK To insert your company logo on this slide From the Insert Menu Select “Picture” Locate your logo file.
Object Oriented Software Development
Game Maker – Getting Started What is Game Maker?.
Introduction to Spring Web Flow Andrew Petro Software Developer Unicon, Inc. Jasig 2011 Westminster, CO 23 May 2011 © Copyright Unicon, Inc., Some.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
© 2011 Delmar, Cengage Learning Chapter 10 Using ActionScript to Enhance User Experience.
2006 Adobe Systems Incorporated. All Rights Reserved. 1 Flex for Flash Developers Sho Kuwamoto Sr. Director, Engineering Adobe Systems, Inc.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Chapter 11 Adding Media and Interactivity. Chapter 11 Lessons Introduction 1.Add and modify Flash objects 2.Add rollover images 3.Add behaviors 4.Add.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
Flux & React Web Application Development Mark Repka, Rich McNeary, Steve Mueller.
By: Eliav Menachi.  Android custom 2D graphics library  OpenGL ES 1.0 for high performance 3D graphics.
CSCE 240 – Intro to Software Engineering Lecture 3.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
Thomas Burleson. Using MVC with Flex & Coldfusion Projects June 27, 2007 See how Coldfusion MVC is similar to Flex MVC…
DHTML.
Objective % Select and utilize tools to design and develop websites.
Roberta Roth, Alan Dennis, and Barbara Haley Wixom
Object-Oriented Analysis and Design
Android Layouts 24 July 2018 S.RENUKADEVI/AP/SCD/ANDROID LAYOUTS 1.
Objective % Select and utilize tools to design and develop websites.
.NET and .NET Core 7. XAML Pan Wuming 2017.
Variables ICS2O.
Game Loop Update & Draw.
Copyright 2007 Oxford Consulting, Ltd
Web Development Using ASP .NET
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Creating New Components in Flex 3 and Beyond Deepa Subramaniam Flex SDK

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. 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. Gumbo/Spark  Gumbo is the codename for the next version of Flex and Flex Builder  Spark is the component and skinning architecture in Gumbo.  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. Lets write a component!

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. 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.

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Halo Component Lifecycle – Broken Down 3 Phase Lifecycle 1. Initialization  Construction  Configuration  Attachment  Initialization 2. Updating  Component responds to changes by using the Invalidation/Validation Model 3. Destruction  Out of sight, out of mind  Detachment  Garbage collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Lifecycle Phase 1: Initialization 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. Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Lifecycle Phase 1: Initialization 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. Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Lifecycle Phase 1: Initialization Attachment: Addition to the display list  What is the display list?  Component is added to the display list through an addChild() call by its parent.  Without attachment, component lifecycle will stall. Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Lifecycle Phase 1: Initialization Initialization  Full invalidation/validation cycle is invoked (we will come back to this)  5 main lifecycle actions occur at this step: 1. preinitialize event is dispatched 2. createChildren() is called 3. initialize event is dispatched 4. First full invalidation/validation pass occurs 5. creationComplete event is dispatched Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Lifecycle Phase 1: Initialization 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).  UIComponents must go inside other UIComponents  Containers must contain only UIComponents Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Lifecycle Phase 1: Initialization 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! Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Phase 2: Updating 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. Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. The Elastic Racetrack 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. Images courtesy of Sean Christmann Traditional Flash Player Elastic Racetrack

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Deferred Validation Model Waiting for update request Update Requested Invalidation Validation Validation occurs right before Rendering

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Deferred Validation Model: An Optimization Invalidation/validation model is split into 3 phases:  Update component properties  Update sizing & measurement information  Update drawing and positioning invalidateProperties() invalidateSize() invalidateDisplayList() commitProperties() measure() updateDisplayList()

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. commitProperties() 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()) Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. measure() 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.  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. Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. updateDisplayList() Layout and Drawing Phase of Invalidation  Purpose: Lay out component contents and perform any drawing  Layout and positioning occurs from the top down, given:  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 Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. 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

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. 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.

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Phase 3: Destruction 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. Construction Configuration Attachment Initialization Invalidation Validation Detachment Garbage Collection

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. VideoWidget  FxVideoWidget

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Component Architecture Patterns Defining Patterns in Halo  Invalidation/Validation Model  Event Driven Interaction Model  Composition Defining Patterns in Gumbo  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

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Time to Gumbo-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() *

® Copyright 2008 Adobe Systems Incorporated. All rights reserved. In Conclusion…    Thank You.  Flash Player Elastic Racetrack: Learn it, love it, live it.  Invalidation: All the cool kids are doing it.  The best component lifecycle reference is right in front of you: Read Framework Code.