Developing Flash MX 2004 Components Using the Version 2 Architecture CFUN-04 Chafic Kazoun, Senior Flash Developer B-Line Express:

Slides:



Advertisements
Similar presentations
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,
Advertisements

When is Orientated Programming NOT? Mike Fitzpatrick.
Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
Visual Scripting of XML
OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
1 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
Dependency in action A look at how dependency is used in modern programming languages Antony Harfield 22 nd October 2009.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 18 – Macromedia Flash MX 2004: Building an Interactive Game Outline 18.1 Introduction 18.2 Object-Oriented.
CS 211 Inheritance AAA.
Object-Oriented PHP (1)
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,
Macromedia Flash MX 2004 – Design Professional and Interactivity WORKING WITH SYMBOLS.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Chapter 7 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
ASP.NET Programming with C# and SQL Server First Edition
© 2011 Delmar, Cengage Learning Chapter 8 Building Complex Animations.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
OOP (Object Oriented Programming with AS3) Flash ActionScript 3.0 Introduction to Thomas Lövgren, Flash developer Introduction.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Flash Remoting Chafic Kazoun Senior Flash Developer - B-Line Express Work: Play:
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
An Object-Oriented Approach to Programming Logic and Design
Chapter 11 Adding Sound and Video. Chapter 11 Lessons 1.Work with sound 2.Specify synchronization options 3.Modify sounds 4.Use ActionScript with sound.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
© 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.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
1 Kyung Hee University Diagram Editor : Implementation View Spring 2001.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
CSE 501N Fall ‘09 14: Inheritance 20 October 2009 Nick Leidenfrost.
Getting a handle on ActionScript A basic primer for non-programmers.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Tutorial 2 Drawing Shapes, Adding Text, and Creating Symbols.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Introduction to Flash Animation CS 318. Topics Introduction to Flash and animation The Flash development environment Creating Flash animations  Layers.
Object Oriented Software Development
Events DOM Event Model. HTML Events "on" + event name attribute value is javascript javascript runs 1st return false to STOP browser event (if any)
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
XP Tutorial 2 Drawing, Adding Text, and Creating Symbols.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
2006 Adobe Systems Incorporated. All Rights Reserved. 1 Flex for Flash Developers Sho Kuwamoto Sr. Director, Engineering Adobe Systems, Inc.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
© 2011 Delmar, Cengage Learning Chapter 11 Adding Sound and Video.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Object-Oriented Programming: Inheritance and Polymorphism.
Basic Organization of UI Software. 2 The User Interface n Typically want to think of “UI” as only one component of an overall system – The part that “deals.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
® Copyright 2008 Adobe Systems Incorporated. All rights reserved. Creating New Components in Flex 3 and Beyond Deepa Subramaniam Flex SDK
CSCE 240 – Intro to Software Engineering Lecture 3.
Creating a Flash Web Site
Andy Wang Object Oriented Programming in C++ COP 3330
University of Central Florida COP 3330 Object Oriented Programming
Flash Interface, Commands and Functions
Generics, Lambdas, Reflections
Chapter 3 Inheritance © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Inheritance Basics Programming with Inheritance
Advanced Programming Behnam Hatami Fall 2017.
INTRODUCTION TO FLASH ANIMATION
Web Development Using ASP .NET
Object-Oriented Programming
C++ Object Oriented 1.
Presentation transcript:

Developing Flash MX 2004 Components Using the Version 2 Architecture CFUN-04 Chafic Kazoun, Senior Flash Developer B-Line Express: Weblog:

Outline A bit of component theory The need for an architecture The goals of the Version 2 Architecture Setting up our Fla UIObject & UIComponent internals  Required properties  Order of initialization  Required methods  Metadata Tags  Setters  Post-initialization considerations and invalidation  Utility methods  Events  The pre-implemented API Further aspects of the architecture

Some theory The quick boring stuff Components promote re-usable code, one of the goals of OOP Components allow people with no knowledge of the inner workings of components to do a lot very quickly Components allow a developer to focus on smaller parts of a larger application and better develop those parts than if they had to build an entire application with no components UI Components/Widgets are a perfect example

Why an architecture? When developing components, many components will have similar needs. These needs can be abstracted out and re-used. Standards are important. We take it for granted sometimes but  A single styling system  A single event system  Familiar implementation. example: move() Makes components easier to use

The V2 Architecture Latest component architecture by Macromedia that will be with us for a long time, used by Flash, Flex, and in the future most probably Central Designed specifically for RIA development Written in AS2 Helps developers build components faster Promotes good practices Uses Meta-data tags for properties/events/databinding (ex: [Event(“change”)]) New event system (mx.events.*) Smarter focus management Databinding Cons: Large initial file-size hit Steep learning curve Some parts not completely polished

Setting up our component Setup your Fla with symbols, layers, linkage identifiers, and skins  All symbols should not have export in first frame checked  Main component symbol should include parent class symbol and any other required symbols in the 2 nd frame like skins  Should include a bounding Box or dead preview with an instance name of boundingBox_mc  Should have a “stop()” on the first frame  Set the class for the symbol  Set the class in the component properties

UIObject Main base class that a component will inherit from UIObject extends MovieClip Requires child to contain some methods/properties Architecture is built to do away with a lot of the MovieClip specific details (Example: createClassObject() instead of attachMovie()) Includes the Event System Includes the Styling System And most of the core features…

UIComponent Extends UIObject so all of our UIObject knowledge generally applies Implements focus management (tabEnabled) No implementation of sizing. UIObject by default will distort a component (change scaleX and scaleY) Support the enabled property Most of the time you will use UIComponent not UIObject as your base class

Setting up our Class import mx.core.UIComponent; class com.rewindlife.controls.StatusIcon extends UIComponent { private var boundingBox_mc:MovieClip; function StatusIcon() { };

Required Properties symbolName: This property is used by createClassObject() which internally calls attachMovie(). It would correspond to the linkage name of the library symbol for the component (ex: “com.rewindlife.controls.StatusIcon”). symbolOwner: This property is also used by createClassObject() className: This is not required if you won’t be implementing styling for your component. It corresponds to the name of the class usually and is used when deciding what class styles to use. (_global.styles.RadioButton.setStyle("color", "blue"); ) clipParamaters & mergedClipParamaters: These are required if publishing to Flash Player 6. When you publish to the 6 player, there are issues where a setter may not be available in time thus causing the property to be created, only to later on be wiped out and lost by the setter property becoming available.

Adding our required properties import mx.core.UIComponent; import mx.core.UIObject; class com.rewindlife.controls.StatusIcon extends UIComponent { static var symbolName:String = "com.rewindlife.controls.StatusIcon"; static var symbolOwner:Object = com.rewindlife.controls.StatusIcon; private var className:String = "StatusIcon"; private var clipParameters:Object = {status:1}; private static var mergedClipParameters:Boolean = UIObject.mergeClipParameters(com.rewindlife.controls.StatusIcon.prototype.clip Parameters, UIComponent.prototype.clipParameters); private var boundingBox_mc:MovieClip; }

Required Methods - Initialization diagram

Methods: init() & createChildren() init() At a minimum you must call super.init() It is also used for creating instance member variables It is called only once and never again in the life of the component Set boundingBox width/height = 0 and visible = false createChildren() Used to create/attach sub-objects Is only called once during initialization

Adding init() and createChildren() import mx.core.UIComponent; import mx.core.UIObject; class com.rewindlife.controls.StatusIcon extends UIComponent { static var symbolName:String = "com.rewindlife.controls.StatusIcon"; static var symbolOwner:Object = com.rewindlife.controls.StatusIcon; private var className:String = "StatusIcon"; private var boundingBox_mc:MovieClip; private function init():Void { super.init(); trace("init") boundingBox_mc._width = boundingBox_mc._height = 0; boundingBox_mc._visible = false; } private function createChildren():Void { //1 trace("createChildren"); }

Methods: draw() Where most of a component’s implementation exists Is responsible for setting the visual state of the component Should be designed in a way to allow it to be called during initialization and afterwards. Needs to be efficient!

Adding draw() import mx.core.UIComponent; import mx.core.UIObject; class com.rewindlife.controls.StatusIcon extends UIComponent { static var symbolName:String = "com.rewindlife.controls.StatusIcon"; static var symbolOwner:Object = com.rewindlife.controls.StatusIcon; private var className:String = "StatusIcon"; private var boundingBox_mc:MovieClip; private function init():Void { … } private function createChildren():Void { … } private function draw():Void { trace("draw"); }

Methods: size() Called by setSize() implicitly In UIObject it resizes by default it will scale the component UIComponent doesn’t include any resizing logic Should check __width/__height. Sometimes you just invalidate the component rather than implement any sizing (if it is a simple component)

Setters Should set the internal model state (ex: __status) Should add appropriate MetaData tags Should Invalidate afterwards [Inspectable(enumeration="Available,Busy,Idle",defaultValue="Available")] [Bindable] function set status(s:String):Void { __status = s; dispatchEvent({type:"change"}); }; function get status():String { return __status; }

Without Invalidation

With Invalidation

Invalidation in V2 Should call invalidate() after updating the model state It is good practice to store all model state data privately to and have draw() access it later, proceed all private variables with __ (two underscores) If you need to redraw the component immediately do not call draw(), instead call redraw(true) The “draw” event is automatically dispatched during invalidation

Other aspects of the architecture Skinning Styling Advanced focus management Containers Data binding

Further information You may contact me at or visit my weblog at presentation material will be posted therehttp:// Good resources: Ultrashock Tutorials – Wrote two articles on Flash MX 2004 Component Development Macromedia DevNet – Several articles on the new architecture and component development Nigel Pegg ( – One of the lead component developers at Macromedia. Very good information on the internals of the architecture/components. Joey Lott ( ents.html) – An article that deals with components in Flash MX 2004 without the V2 framework. Good for getting a good understanding of components in generalhttp:// ents.html