Macromedia flex 2 Manual

Page of 254
Working with events
107
Remember, an MXML component corresponds to an ActionScript class, where the 
ActionScript class name is the filename of the MXML component. Therefore, the MXML 
component defines a new data type. You can then create a variable named whose data type is 
that of the calling file. 
With the reference to the calling file, your MXML component can access any property of the 
calling file, and you can bind the value of the TextInput control in CallingComp.mxml to the 
TextInput control in StateComboBox.mxml. Creating a property of type CallingComp 
provides strong typing benefits and ensures that binding works correctly.
Working with events
Flex applications are event-driven. Events let a programmer know when the user interacts 
with the interface, and also when important changes happen in the appearance or life cycle of 
a component, such as the creation or destruction of a component or its resizing. This section 
describes how to handle events that your custom components generate, and also how to add 
your own event types to your custom components.
Handling events from simple MXML components
Simple MXML components are those that contain a single root tag that is not a container. In 
this topic, the StateComboBox.mxml component is a simple component because it contains a 
definition only for the 
ComboBox
 control.
You have two choices for handling events that a simple component dispatches: handle the 
events within the definition of your MXML component, or allow the file that references the 
component to handle them.