5
USING FLEX 4.5
Getting started
Dernière mise à jour le 19/6/2011
• xmlns:s="library://ns.adobe.com/flex/spark" The namespace for the Spark component set.
In general, you include the Spark and MX component namespaces so that you can use any components from those
sets. Where possible, use the Spark components. However, not all MX components have Spark counterparts, so the
components in the MX namespace are also sometimes necessary.
You can define additional namespaces for your custom component libraries. For more information on namespaces,
see « Using XML namespaces » à la page 9.
About MXML tag properties
The properties of an MXML tag, such as the
text, fontWeight, and fontSize properties of the <s:Label> tag, let
you declaratively configure the initial state of the component. You can use ActionScript code in an
<fx:Script> tag
to change the state of a component at run time. For more information, see « Using ActionScript » à la page 32.
Compiling MXML to SWF Files
If you are using Flash Builder, you compile and run the compiled SWF file from within Flash Builder. After your
application executes correctly, you deploy it by copying it to a directory on your web server or application server.
You can deploy your application as a compiled SWF file, as a SWF file included in an AIR application or, if you have
Adobe LiveCycle Data Services ES, you can deploy your application as a set of MXML and AS files.
End users of the application do not typically reference the SWF file directly in an HTTP request. Instead, you embed
the application SWF file in an HTML page. The HTML page then uses a script to load the SWF file. Collectively, the
HTML page and the script are known as the wrapper.
When the SWF file is embedded in the HTML page, users then access the deployed SWF file by making an HTTP
request to the HTML page, in the form:
http://hostname/path/filename.html
For more information on wrappers, see « Creating a wrapper » à la page 2553.
Flex also provides a command-line MXML compiler, mxmlc, that lets you compile MXML files. You can use mxmlc
to compile hello.mxml from a command line, as the following example shows:
cd flex_install_dir/bin
mxmlc --show-actionscript-warnings=true --strict=true c:/app_dir/hello.mxml
In this example, flex_install_dir is the Flex installation directory, and app_dir is the directory containing hello.mxml.
The resultant SWF file, hello.swf, is written to the same directory as hello.mxml.
For more information about mxmlc, see « Flex compilers » à la page 2162.
The relationship of MXML tags to ActionScript classes
Adobe implemented Flex as an ActionScript class library. That class library contains components (containers and
controls), manager classes, data-service classes, and classes for all other features. You develop applications by using the
MXML and ActionScript languages with the class library.
MXML tags correspond to ActionScript classes or properties of classes. Flex parses MXML tags and compiles a SWF
file that contains the corresponding ActionScript objects. For example, Flex provides the ActionScript Button class
that defines the Flex Button control. In MXML, you create a Button control by using the following MXML statement:
<s:Button label="Submit"/>
When you declare a control using an MXML tag, you create an instance of that class. This MXML statement creates a
Button object, and initializes the
label property of the Button object to the string "Submit".
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.