Chapter 12: Creating Template Components; About Template Components - 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

CHAPTER 12
1 2
Creating Template
Components
One way to create reusable components is to define them as template components. A template
component defines properties with a general data type that lets the component user specify an
object of a concrete data type when using the component. By using a general data type to
define component properties, you create highly reusable components that can work with
many different types of objects.
This topic describes how to create template components.
Contents

About template components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

Implementing a template component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
About template components
A standard component defines a property with a concrete data type, such as Number or
String. The component user must then pass a value that exactly matches the property's data
type or else Flex issues a compiler error.
A template component is a component in which one or more of its properties is defined with a
general data type. This property serve as a slot for values that can be of the exact data type of
the property, or of a value of a subclass of the data type. For example, to accept any Flex visual
component as a property value, you define the data type of the property as UIComponent. To
accept only container components, you define the data type of the property as Container.
When you use the template component in an application, the component user sets the
property value to be an object with a concrete data type. You can think of the property as a
placeholder for information, where it is up to the component user to define the actual data
type of the property, rather than the component developer.
195

Advertisement

Table of Contents
loading

Table of Contents