User Guide

16 Chapter 1: Introducing Flex
When you declare a control using an MXML tag, you create an instance object of that class. This
MXML statement creates a Button object, and initializes the
label property of the Button object
to the string Submit.
An MXML tag that corresponds to an ActionScript class uses the same naming conventions as the
ActionScript class. Class names begin with an uppercase letter, and uppercase letters separate the
words in class names. Every MXML tag attribute corresponds to a property of the ActionScript
object, a style applied to the object, or an event handler for the object. For a complete description
of the Flex class library and MXML tag syntax, see the Flex ActionScript and MXML API
Reference.
Using MXML and ActionScript
You develop Flex applications using a combination of MXML and ActionScript. MXML is a
declarative language that you use to define the basic layout and contents of your application.
ActionScript is a procedural language that you use to perform runtime control and data
processing in your application.
Defining the user interface in MXML
Your application can consist of one or more MXML files. Using multiple MXML files promotes
code reuse, simplifies the process of building a complex application, and makes it easier for more
than one developer to contribute to a project.
The following example is an MXML application that uses a Button control to trigger a copy of
the text from a TextInput control to a TextArea control:
<?xml version="1.0"?>
<!-- ?xml tag must start in line 1 column 1 -->
<!-- MXML root element tag. -->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
<!-- Flex controls exist in a container. Define a Panel container. -->
<mx:Panel title="My Application">
<!-- TextInput control for user input. -->
<mx:TextInput id="myInput" width="150" text="" />
<!-- Button control that triggers the copy. -->
<mx:Button id="myButton" label="Copy Text" />
<!-- Output TextArea control. -->
<mx:TextArea id="myText" text="" width="150" />
</mx:Panel>
</mx:Application>
The first line of this application specifies the XML declaration and must start in line 1, column 1
of the MXML file.