Chapter 7. MXML Fundamentals

MXML is an XML-based, presentational markup language intended for laying out Flex components much like one would lay out HTML elements on a page. MXML markup may be combined with both CSS styles and ActionScript in the same file to create complete applications. This chapter explores the underlying principles of MXML, its syntax, and the ways in which it can be used with other languages in the Flex ecosystem.

The term "MXML" is not in fact an acronym, even though it is obviously derived from the term "XML". Although Adobe, and Macromedia before it, has never ascribed a definition to this term, the likeliest meaning for a possible acronym is "Macromedia eXtensible Markup Language," or the "M" is a remnant from the Macromedia "MX" line of products when Flex was first under development.

Language Principles

In this section, we'll explore the basic principles of the MXML language.

MXML Is XML

Since an MXML document is in XML, it must conform to the following guidelines:

  • It must start with an XML declaration, like so:

    <?xml version="1.0" encoding="utf-8"?>
  • It must be a well-formed XML document, which means that each element is closed properly, each element is nested properly, attributes are declared with single or double quotation marks, and comments adhere to XML standards.

  • The document must contain a root node. For the main application file for instance, this would be either <mx:Application /> for a Flex application or <mx:WindowedApplication /> for an AIR application. ...

Get Professional Adobe® Flex® 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.