Adding Custom Properties And Methods To A 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

With loosely coupled components, you typically define properties of the component to pass
information to it. These properties, defined by using variables or setter and getter methods,
specify the data type of the parameter value. For more information about defining component
properties, see
"Adding custom properties and methods to a component" on page
92.
The best practice for defining components that return information back to the main
application is to design the component to dispatch an event that contains the return data. In
that way, the main application can define an event listener to handle the event and take the
appropriate action. For more information on dispatching events, see
"Working with events"
on page
107.
Adding custom properties and methods
to a component
MXML components provide you with a simple way to create ActionScript classes. When
defining classes, you use class properties to store information and class methods to define class
functionality. When creating MXML components, you can also add properties and methods
to the components.
One of the reasons that you add properties and methods to your components is to make them
configurable. By allowing the user to pass information to the components, you can create a
reusable component that you can use in multiple locations throughout your application, or in
multiple applications.
This section describes how to define properties of MXML components in MXML tags or as
ActionScript variables, and how to define new methods of an MXML component by using
ActionScript functions.
Defining properties and methods in MXML
components
You can define methods for your MXML components in ActionScript, and properties in
ActionScript or MXML. The Flex compiler converts the MXML component into an
ActionScript class, so there is no performance difference between defining a property in
MXML and defining it in ActionScript.
92
Creating Advanced MXML Components

Advertisement

Table of Contents
loading

Table of Contents