Adobe Flex 3 Help

About controls

Controls are user-interface components, such as Button, TextArea, and ComboBox controls. You place controls in containers, which are user-interface components that provide a hierarchical structure for controls and other containers. Typically, you define a container, and then insert controls or other containers in it.

At the root of a Flex application is the <mx:Application> tag, which represents a base container that covers the entire Adobe® Flash® Player or Adobe AIR™ drawing surface. You can place controls or containers directly under the <mx:Application> tag or in other containers. For more information on containers, see Introducing Containers.

Most controls have the following characteristics:

  • MXML API for declaring the control and the values of its properties and events
  • ActionScript API for calling the control's methods and setting its properties at run time
  • Customizable appearance by using styles, skins, and fonts

The following image shows several controls used in a Form container:

Several controls used in a Form container

A. Form container B. TextInput controls C. ComboBox control D. Button control

The MXML and ActionScript APIs let you create and configure a control. The following MXML code example creates a TextInput control in a Form container:

<?xml version="1.0"?>
<!-- controls\TextInputInForm.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Form width="300" height="100">
        <mx:FormItem label="Card Name">
            <mx:TextInput id="cardName"/>
        </mx:FormItem>
    </mx:Form>
</mx:Application>

The executing SWF file for the previous example is shown below:

This example produces the following image:

TextInput control in a Form container

Although you commonly use MXML as the language for building Flex applications, you can also use ActionScript to configure controls. For example, the following code example populates a DataGrid control by providing an Array of items as the value of the DataGrid control's dataProvider property:

<?xml version="1.0"?>
<!-- controls\DataGridConfigAS.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        <![CDATA[

        private function myGrid_initialize():void {
          myGrid.dataProvider = [
            {Artist:'Steve Goodman', Album:'High and Outside', Price:8.99},
            {Artist:'Carole King', Album:'Tapestry', Price:11.99},
            {Artist:'The Beach Boys', Album:'Pet Sounds', Price:13.99},
            {Artist:'Original Cast', Album:'Camelot', Price:9.99} ];
        }
        ]]>
    </mx:Script>
    
    <mx:DataGrid id="myGrid" 
        width="350" height="150" 
        color="#7B0974"
        creationComplete="myGrid_initialize();"/>
</mx:Application>

The executing SWF file for the previous example is shown below:

This example produces the following image:

Populates a DataGrid control by providing an Array of items as the value of the DataGrid control's dataProvider property

Text controls

Several Flex components display text or take text input, as the following table shows:

Control

Type of text

Label

Noneditable, single-line text field

Text

Noneditable, multiline text field

TextInput

(Optional) Editable, single-line text field

TextArea

(Optional) Editable, multiline text field

RichTextEditor

Compound control that contains a multiline text field and controls that let you format text by selecting such characteristics as font, size, weight, and alignment

These controls can display plain text that all has the same appearance. The controls can also display rich text formatted by using a subset of the standard HTML formatting tags. For information on using text controls, see Using Text Controls.

Data provider controls

Several Flex components, such as the DataGrid, Tree, and ComboBox controls, take input data from a data provider. A data provider is a collection of objects, similar to an array. For example, a Tree control reads data from the data provider to define the structure of the tree and any associated data assigned to each tree node.

The data provider creates a level of abstraction between Flex components and the data that you use to populate them. You can populate multiple components from the same data provider, switch data providers for a component at run time, and modify the data provider so that changes are reflected by all components that use the data provider.

Consider that the data provider is the model, and the Flex components are the view onto the model. By separating the model from the view, you can change one without changing the other.

Menu controls

Several Flex controls create or interact with menus, as the following table shows:

Control

Description

Menu

A visual menu that can have cascading submenus

MenuBar

A horizontal bar with multiple submenus

PopUpMenuButton

A Menu control that opens when you click a button

For information on menu controls, see Using Menu-Based Controls.

Flex controls

The following table lists all the controls available with Flex:

Control

Description

For more information

Alert

Displays a pop-up alert

Alert control

Button

Displays a variable-size button that can include a label, an icon image, or both.

Button control

ButtonBar

Displays a row of related buttons with a common appearance.

ButtonBar and ToggleButtonBar controls

CheckBox

Shows whether a particular Boolean value is true (checked) or false (unchecked).

CheckBox control

ComboBox

Displays a drop-down list attached to a text field that contains a set of values.

ComboBox control

ColorPicker

Displays a selectable drop-down color swatch panel (palette).

DateChooser and DateField controls

DataGrid

Displays data in a tabular format.

DataGrid control

DateChooser

Displays a full month of days to let you select a date.

DateChooser and DateField controls

DateField

Displays the date with a calendar icon on its right side. When a user clicks anywhere inside the control, a DateChooser control pops up and displays a month of dates.

DateChooser and DateField controls

HorizontalList

Displays a horizontal list of items.

HorizontalList control

HRule/VRule

Displays a single horizontal rule (HRule) or vertical rule (VRule).

HRule and VRule controls

HSlider/VSlider

Lets users select a value by moving a slider thumb between the end points of the slider track.

HSlider and VSlider controls

Image

Imports GIF, JPEG, PNG, SVG, and SWF files.

Image control

Label

Displays a noneditable single-line field label.

LinkButton control

LinkBar

Displays a horizontal row of LinkButton controls that designate a series of link destinations.

LinkBar control

LinkButton

Displays a simple hypertext link.

LinkButton control

List

Displays a scrollable array of choices.

List control

Menu

Displays a pop-up menu of individually selectable choices, much like the File or Edit menu of most software applications.

Menu control events

MenuBar

Displays a horizontal menu bar that contains one or more submenus of Menu controls.

MenuBar control

NumericStepper

Displays a dual button control that you can use to increase or decrease the value of the underlying variable.

NumericStepper control

ProgressBar

Provides visual feedback of how much time remains in the current operation.

ProgressBar control

RadioButton

Displays a set of buttons of which exactly one is selected at any time.

RadioButton control

RadioButton Group

Displays a group of RadioButton controls with a single click event listener.

Creating a group by using the <mx:RadioButtonGroup> tag

RichTextEditor

Includes a multiline editable text field and controls for specifying text formatting.

RichTextEditor control

ScrollBar

(HScrollBar and VScrollBar)

Displays horizontal and vertical scroll bars.

ScrollBar control

SWFLoader

Displays the contents of a specified SWF file or JPEG file.

SWFLoader control

TabBar

Displays a horizontal row of tabs.

TabBar control

Text

Displays a noneditable multiline text field.

TextInput control

TextArea

Displays an editable text field for user input that can accept more than a single line of input.

Using Text Controls

TextInput

Displays an editable text field for a single line of user input. Can contain alphanumeric data, but input is interpreted as a String data type.

TextInput control

TileList

Displays a tiled list of items. The items are tiled in vertical columns or horizontal rows.

TileList control

ToggleButtonBar

Displays a row of related buttons with a common appearance.

ButtonBar and ToggleButtonBar controls

Tree

Displays hierarchical data arranged as an expandable tree.

Tree control

VideoDisplay

Incorporates streaming media into Flex applications.

VideoDisplay control