The following figure shows the source files used to generate a SWF file that your J2EE server
sends to the client:
The top-level
MXML file
includes
<mx:script> blocks,
imported
ActionScript files,
and components
defined by
ActionScript files
or MXML files.
ActionScript
classes and
packages
referenced in the
application files
are included in the
final SWF.
Using ActionScript in Flex applications
When you write a Flex application, you use MXML to lay out the user interface of your
application, and you use ActionScript to handle the user interactions with the application. You
can use a variety of methods to mix ActionScript and MXML. You can include inline
ActionScript in MXML, or supplement a codeless MXML document with an external
ActionScript controller class.
To use ActionScript in your Flex applications, you can add script blocks using the
tag or include external ActionScript files. In addition, you can import external class files or entire
packages of class files for use by your MXML application. Flex extracts the ActionScript and
creates a class file, which is linked to the final SWF file. For more information, see
for separating ActionScript from MXML" on page
Note: In general, Macromedia recommends that you import ActionScript class files when possible
rather than use
<mx:Script>
multiple files.
Using special characters
Special characters are any characters that might confuse the XML parser. The contents of
tags are treated as XML by Flex. As a result, blocks of ActionScript should be
<mx:Script>
wrapped in a CDATA construct so that Flex does not try to interpret special characters. The
following example shows a CDATA construct:
<![CDATA[
...
]]>
46
Chapter 3: Using ActionScript
Source Files
Compiler/Linker
blocks in your MXML files or include snippets of ActionScript code from
J2EE Server
54.
Client
<mx:Script>
"Techniques
Need help?
Do you have a question about the FLEX-GETTING STARTED WITH FLEX and is the answer not in the manual?
Questions and answers