Best Practices When Designing A Component; Example: Creating A Composite Component - Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

Best practices when designing a
component
Use the following practices when you design a component:
Keep the file size as small as possible.
Make your component as reusable as possible by generalizing functionality.
Use the Border class rather than graphical elements to draw borders around objects.
Use tag-based skinning.
Assume an initial state. Because style properties are on the object, you can set initial
settings for styles and properties so your initialization code does not have to set them
when the object is constructed, unless the user overrides the default state.
Example: Creating a composite
component
Composite components are components that contain multiple components. They might be
graphical assets or a combination of graphical assets and component classes. For example, you
can create a component that includes a button and a text field, or a component that includes
a button, a text field, and a validator.
When you create composite components, you should instantiate the controls inside the
component's class file. Assuming that some of these controls have graphical assets, you must
plan the layout of the controls that you are including, and set properties such as default values
in your class file. You must also ensure that you import all the necessary classes that the
composite component uses.
Because the class extends one of the base classes, such as UIComponent, and not a controls
class like Button, you must instantiate each of the controls as children of the custom
component and arrange them on the screen.
Properties of the individual controls are not accessible from the MXML author's environment
unless you design your class to allow this. For example, if you create a component that extends
the UIComponent class and uses a Button and a
Button control's label text in the MXML tag because you do not directly extend the Button
class.
172
Creating Advanced Visual Components in ActionScript
TextArea
component, you cannot set the

Advertisement

Table of Contents
loading

Table of Contents