
About MXML
25
The first line of the document specifies an optional declaration of the XML version. It is good
practice to include encoding information that specifies how the MXML file is encoded. Many
editors let you select from a range of file encoding options. On North American operating
systems, ISO-8859-1 is the dominant encoding format, and most programs use that format by
default. You can use the UTF-8 encoding format to ensure maximum platform compatibility.
UTF-8 provides a unique number for every character in a file, and it is platform-, program-, and
language-independent. If you specify an encoding format, it must match the file encoding you
use. The following example shows an XML declaration tag that specifies the UTF-8 encoding
format:
<?xml version="1.0" encoding="utf-8"?>
To deploy the application, you copy the MXML file to a web application directory. The first time
a user requests the MXML file URL in a web browser, the server compiles the MXML code into a
SWF file. The server then sends the SWF file to the web browser where it is rendered in Flash
Player. Unless the MXML file changes, the SWF file is not recompiled on subsequent requests.
When the Flex compiler autogenerates the HTML file that contains this application, it uses the
height
and
width
properties of the
<mx:Application>
tag to determine height and width
properties of the
<object>
and
<embed>
tags. The
<object>
and
<embed>
tags determine the
size of the Flash drawing surface.
The following figure shows the “Hello World” application rendered in a web browser window:
In addition to being the root tag of a Flex application, the
<mx:Application>
tag represents an
Application container. A
container
is a user-interface component that contains other components
and has built-in layout rules for positioning its child components. By default, an Application
container lays out its children vertically from top to bottom. You can nest other types of
containers inside an Application container to position user-interface components according to
other rules. For more information, see Chapter 1, “Using Flex Components,” in
Developing Flex
Applications
.
The properties of an MXML tag, such as the
text
,
color
, and
fontSize
properties of the
<mx:Label>
tag, let you declaratively configure the initial state of the component. You can use
ActionScript code in an
<mx:Script>
tag to change the state of a component at runtime. For
more information, see Chapter 16, “Working with ActionScript in Flex,” in
Developing Flex
Applications
.
Содержание FLEX-GETTING STARTED WITH FLEX
Страница 1: ...Getting Started with Flex...
Страница 4: ...4 Contents...
Страница 22: ...22 Chapter 1 Introducing Flex...