Flex lets you point to external ActionScript files in your <mx:Script> tags. At compile-time, the compiler copies the entire contents of the file into your MXML application. As with ActionScript in an <mx:Script> block, ActionScript in included files must be variable declarations or in functions. You cannot define classes in included files.
Variables and functions defined in an included ActionScript file are available to any component in the MXML file. An included ActionScript file is not the same as an imported ActionScript class. Flex provides access to the included file's variables and functions, but does not add a new class, since the MXML file itself is a class.
Included ActionScript files do not need to be in the same directory as the MXML file. However, you should organize your ActionScript files in a logical directory structure.
Flex detects changes in ActionScript files using timestamps. If the file has changed since the last request, Flex regenerates the application before responding to the client. If you change the ActionScript in one of the imported ActionScript files, the next time the application is requested, the changes appear.
There are two ways to include an external ActionScript file in your Flex application:
source attribute of the <mx:Script> tag. This is the preferred method for including external ActionScript class files.
#include directive inside <mx:Script> blocks.
The following sections describe these two methods of including an external ActionScript file.
Version 1.5
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000049.htm