Using the #include directive
The
directive is an ActionScript statement that copies the contents of the specified file
#include
into your MXML file. The
#include "
The following example includes the myfunctions.as file:
<mx:Script>
<![CDATA[
#include "myfunctions.as"
...
]]>
</mx:Script>
Note: The
#include
semicolon. If you do, you get a "Malformed
surround the target file with quotation marks.
You can only specify a single file for each
directives. You can next
#include
files that have
#include
The
directive supports only relative paths. For more information, see
#include
external files" on page
You can only use the
is not allowed:
if (expr)
#include "foo.as" // First statement is guarded by IF, but the rest are not.
...
The following is allowed:
if (expr) {
#include "foo.as"
}
The use of curly braces ({ }) allows multiple statements because you can add multiple statements
inside the braces.
Macromedia recommends against using the
included ActionScript files. You should try to break the code into separate class files where
appropriate and store them in logical package structures.
50
Chapter 3: Using ActionScript
directive uses the following syntax:
#include
"
directive is a special kind of ActionScript statement. Do not end the line with a
#include
#include
directives.
51.
where multiple statements are allowed. For example, the following
#include
// All statements inside { } are guarded by IF.
directive" error message. In addition, you must
#include
directive, but you can use any number of
directives; files with
directive if you use a large number of
#include
directives can include
#include
"Referring to
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