Compiler Directives


This section contains the directives to include in your ActionScript file to direct the compiler to preprocess certain instructions. Do not place a semicolon (;) at the end of the line that contains the directive.

Compiler Directives summary

Directive

Description

#endinitclip

Indicates the end of a block of initialization actions.

#include

Includes the contents of the specified file, as if the commands in the file are part of the calling script.

#initclip

Indicates the beginning of a block of initialization actions.


#endinitclip directive

#endinitclip

Indicates the end of a block of initialization actions.

Do not place a semicolon (;) at the end of the line that contains the #endinitclip directive.

Availability: ActionScript 1.0; Flash Player 6.0

Example

#initclip ...initialization actions go here... #endinitclip

#include directive

#include "[path]filename.as":String

Includes the contents of the specified file, as if the commands in the file are part of the calling script. The #include directive is invoked at compile time. Therefore, if you make any changes to an external file, you must save the file and recompile any FLA files that use it.

If you use the Check Syntax button for a script that contains #include statements, the syntax of the included files is also checked.

You can use #include in FLA files and in external script files, but not in ActionScript 2.0 class files.

You can specify no path, a relative path, or an absolute path for the file to be included. If you don't specify a path, the AS file must be in one of the following locations:

  • The same directory as the FLA file. The same directory as the script containing the #include statement

  • The global Include directory, which is one of the following:

    --Windows 2000 or Windows XP: C:\Documents and Settings\user \Local Settings\ Application Data\Macromedia\Flash 8\language\Configuration\Include

    --Macintosh OS X: Hard Drive/Users/Library/Application Support/Macromedia/Flash 8/language/Configuration/Include

  • The Flash 8 program\language\First Run\Include directory; if you save a file here, it is copied to the global Include directory the next time you start Flash.

To specify a relative path for the AS file, use a single dot (.) to indicate the current directory, two dots (..) to indicate a parent directory, and forward slashes (/) to indicate subdirectories. See the following example section.

To specify an absolute path for the AS file, use the format supported by your platform (Macintosh or Windows). See the following example section. (This usage is not recommended because it requires the directory structure to be the same on any computer that you use to compile the script.)

If you place files in the First Run/Include directory or in the global Include directory, back up these files. If you ever need to uninstall and reinstall Flash, these directories might be deleted and overwritten.

Do not place a semicolon (;) at the end of the line that contains the #include directive.

Availability: ActionScript 1.0; Flash Player 4.0

Parameters

[path]filename.as:String - filename.as The filename and optional path for the script to add to the Actions panel or to the current script; .as is the recommended filename extension.

Example

The following examples show various ways of specifying a path for a file to be included in your script:

// Note that #include statements do not end with a semicolon (;) // AS file is in same directory as FLA file or script // or is in the global Include directory or the First Run/Include directory #include "init_script.as" // AS file is in a subdirectory of one of the above directories // The subdirectory is named "FLA_includes" #include "FLA_includes/init_script.as" // AS file is in a subdirectory of the script file directory // The subdirectory is named "SCRIPT_includes" #include "SCRIPT_includes/init_script.as" // AS file is in a directory at the same level as one of the above   directories // AS file is in a directory at the same level as the directory // that contains the script file // The directory is named "ALL_includes" #include "../ALL_includes/init_script.as" // AS file is specified by an absolute path in Windows // Note use of forward slashes, not backslashes #include "C:/Flash_scripts/init_script.as" // AS file is specified by an absolute path on Macintosh #include "Mac HD:Flash_scripts:init_script.as"

#initclip directive

#initclip [order:Number]

Indicates the beginning of a block of initialization actions. When multiple clips are initialized at the same time, you can use the order parameter to specify which initialization occurs first. Initialization actions are executed when a movie clip symbol is defined. If the movie clip is an exported symbol, the initialization actions are executed before the actions on Frame 1 of the SWF file. Otherwise, they are executed immediately before the actions of the frame that contains the first instance of the associated movie clip symbol.

Initialization actions are executed only once when a SWF file is played. Use them for one-time initializations, such as class definition and registration.

Do not place a semicolon (;) at the end of the line that contains the #initclip directive.

Availability: ActionScript 1.0; Flash Player 6.0

Parameters

order:Number [optional] - A non-negative integer that specifies the execution order of blocks of #initclip code. This is an optional parameter. You must specify the value by using an integer literal (only decimal values are allowed, not hexadecimal), and not by using a variable. If you include multiple #initclip blocks in a single movie clip symbol, then the compiler uses the last order value specified in that movie clip symbol for all #initclip blocks in that symbol.

Example

In the following example, ActionScript is placed on Frame 1 in a movie clip instance. A variables.txt text file is placed in the same directory.

#initclip trace("initializing app"); var variables:LoadVars = new LoadVars(); variables.load("variables.txt"); variables.onLoad = function(success:Boolean) {  trace("variables loaded:"+success);  if (success) {  for (i in variables) {  trace("variables."+i+" = "+variables[i]);  }  } }; #endinitclip



ActionScript 2.0 Language Reference for Macromedia Flash 8
ActionScript 2.0 Language Reference for Macromedia Flash 8
ISBN: 0321384040
EAN: 2147483647
Year: 2004
Pages: 113

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net