78
Creating Simple MXML Components
For example, Flex supplies a ComboBox control that you can use as part of a form that
collects address information from a customer. You can use a ComboBox to let the user select
the State portion of the address from a list of the 50 states in the U.S. In an application that
has multiple locations where a user can enter an address, it would be tedious to create and
initialize multiple ComboBox controls with the information about all 50 states.
Instead, you create an MXML component that contains a ComboBox control with all 50
states defined within it. Then, wherever you must add a state selector to your application, you
use your custom MXML component.
Creating MXML components
An application that uses MXML components includes a main MXML application file, which
contains the
<mx:Application>
root tag, and references one or more components that are
defined in separate MXML and ActionScript files. Each MXML component extends an
existing Flex component, or another MXML component.
You create an MXML component in an MXML file where the component’s filename becomes
its MXML tag name. For example, a file named StateComboBox.mxml defines a component
with the tag name of
<StateComboBox>
.
The root tag of an MXML component is a component tag, either a Flex component or
another MXML component. The root tag specifies the http://www.adobe.com/2006/mxml
namespace. For example, the following MXML component extends the standard Flex
ComboBox
control.
<?xml version="1.0"?>
<!-- mxml/StateComboBox.mxml -->
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:dataProvider>
<mx:String>AK</mx:String>
<mx:String>AL</mx:String>
<!-- Add all other states. -->
</mx:dataProvider>
</mx:ComboBox>
As part of its implementation, a custom MXML component can reference another custom
MXML component.
Содержание 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...