6
USING FLEX 4.5
Getting started
Dernière mise à jour le 19/6/2011
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 listener for the
object. For a complete description of the Flex class library and MXML tag syntax, see the ActionScript 3.0 Reference for
the Adobe Flash Platform.
Understanding the structure of an application built with Flex
You can write an MXML application in a single file or in multiple files. You typically define a main file that contains
the
<s:Application> tag. From within your main file, you can then reference additional files written in MXML,
ActionScript, or a combination of the two languages.
A common coding practice is to divide your Flex application into functional units, or modules, where each module
performs a discrete task. In Flex, you can divide your application into separate MXML files and ActionScript files,
where each file corresponds to a different module. By dividing your application into modules, you provide many
benefits, including the following:
Ease of development Different developers or development groups can develop and debug modules independently of
each other.
Reusability You can reuse modules in different applications so that you do not have to duplicate your work.
Maintainability You can isolate and debug errors faster than if your application is developed in a single file.
In Flex, a module corresponds to a custom component implemented either in MXML or in ActionScript. These
custom components can reference other custom components. There is no restriction on the level of nesting of
component references in Flex. You define your components as required by your application.
You can also use sub-applications rather than modules to develop applications that are not monolithic.
Developing applications
MXML development is based on the same iterative process used for other types of web application files such as HTML,
JavaServer Pages (JSP), Active Server Pages (ASP), and ColdFusion Markup Language (CFML). Developing a useful
Flex application is as easy as opening your favorite text editor, typing some XML tags, saving the file, requesting the
file’s URL in a web browser, and then repeating the same process.
Flex also provides tools for code debugging. For more information, see « Command-line debugger » à la page 2207.
Laying out a user interface using containers
In the Flex model-view design pattern, user interface components represent the view. The MXML language supports
two types of user interface components: controls and containers. Controls are form elements, such as buttons, text
fields, and list boxes. Containers are rectangular regions of the screen that contain controls and other containers.
You use container components for laying out a user interface, and for controlling user navigation through the
application. Examples of layout containers include the HGroup container for laying out child components
horizontally and the VGroup container for laying out child components vertically. Examples of navigator containers
include the MX TabNavigator container for creating tabbed panels and the MX Accordion navigator container for
creating collapsible panels. Typical properties of a container tag include
id, width, and height. For more information
about the standard Flex containers, see « Introduction to containers » à la page 328.
The following example application contains a Spark List control on the left side of the user interface and an MX
TabNavigator container on the right side. Both controls are enclosed in a Spark Panel container:
Praat mee over dit product
Laat hier weten wat jij vindt van de Adobe Flex 4.5. Als je een vraag hebt, lees dan eerst zorgvuldig de handleiding door. Een handleiding aanvragen kan via ons contactformulier.