172
Creating Advanced Visual Components in ActionScript
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
TextArea
component, you cannot set the
Button control’s label text in the MXML tag because you do not directly extend the Button
class.
Содержание FLEX 2 - CREATING AND EXTENDING COMPONENTS
Страница 1: ...Creating and Extending Flex 2 Components Adobe Flex 2...
Страница 6: ...6 Contents...
Страница 10: ...10 About Flex Documentation...
Страница 12: ......
Страница 24: ...24 Creating Flex Components...
Страница 74: ...74 Compiling Components...
Страница 76: ......
Страница 118: ...118 Creating Advanced MXML Components...
Страница 120: ......
Страница 182: ...182 Creating Advanced Visual Components in ActionScript...
Страница 194: ...194 Creating Custom Style Properties...
Страница 204: ...204 Creating Template Components...
Страница 206: ......
Страница 216: ...216 Creating Custom Formatters...
Страница 254: ...254 Index...