Ultrashock Tutorials > Flash MX 2004 > Introduction to the v2 component architecture  
 
by Chafic Kazoun, Rewindlife.com
Download PDF file 
 
Introduction to the v2 component architecture
 

01. Introduction
02. Setup and Core Implementation 
03. Public API
04. Utility methods

05. Events
06. Additions to the Public API
07. Conclusion

- discuss this tutorial -

II. Public API

One of the benefits of using component architecture, as was mentioned at the beginning of the tutorial, is for us to do less work. So far, that might not seem like the case. So we’ll take a bit of time to check out some of the things that component architecture does do for us.

a. Methods

move(x,y)

The move() Method receives two parameters x and y and will itself move the component to the new location. This is a correct technique for moving components in Flash MX 2004 as users should not manipulate the _x or _y values directly.

setSize(width,height)

You might recall the size() method from earlier discussion. The setSize() method actually implicitly calls the size() method and handles some other required things by the component architecture. It is responsible for preparing the __width, __height, oldWidth, and oldHeight properties before calling the size() method. The important thing to keep in mind is that your size() method implementation should correctly resize things at runtime or else the setSize() method may not work properly and you do not usually override the setSize() method.

b. Read-only Properties

There are many read-only properties that are implemented in UIObject for us. These read only properties are helpful for your users and are also used by some container classes in the version 2 component architecture. It is good to know about these properties, as in many cases you may not realize what was already implemented for you.

Properties

  • right:
  • left:
  • top:
  • bottom:
  • x:
  • y:

c. Properties visible

The visible property allows a user to hide/show the component. Not much required of us here but good to note that this implicitly sets the _visible property and will dispatch the appropriate event, either “reveal” or “hide”. If you want to implement your own handling of the visible property, you can override the setVisible() method.

scaleX/scaleY

These are equivalent to the _xscale/_yscale MovieClip properties.

- discuss this tutorial -
 
©2004 Ultrashock.com - All rights reserved