Chapter 3. MXML
MXML is a declarative markup language used to create the user interface and to view portions of Flex applications. As the name implies, MXML is an XML-based language. If you’re familiar with XML or even HTML, many of the basic MXML concepts we discuss in this chapter will already be familiar to you in a general sense. In this chapter, we’ll look at all the basics of working with MXML, including the syntax and structure of the language, the elements that comprise MXML, creating interactivity in MXML, and how you can use MXML to build applications.
Understanding MXML Syntax and Structure
If you’ve ever worked with XML or HTML, the structure of MXML will be familiar to you. MXML uses tags to create components such as user interface controls (buttons, menus, etc.), and to specify how those components interact with one another and with the rest of the application, including data sources. In the following sections we’ll look at how to write MXML code.
Creating MXML Documents
All MXML must appear within MXML documents, which are plain-text documents. You can use any text editor, XML editor, or IDE that can work with text or XML in order to write MXML, including those listed in the preceding chapter. In order to create a new MXML document, you can create a new file with the .mxml file extension. If you are using Flex Builder, you can use the program’s menus to add either a new MXML application or a new MXML component. Both are MXML documents, differing only in the root element ...