Appendix A. ActionScript 2.0 Language Quick Reference

 <  Day Day Up  >  

The following reference lists the datatypes recognized by the ActionScript 2.0 compiler for the built-in classes, objects, global properties, and global functions in Flash Player 7. This list will help you preemptively avoid type mismatch errors when declaring datatypes. Or, if you've encountered a compiler error because you've used a built-in class, object, property, or function with the wrong datatype, this list will help you find the correct datatype and fix the error. Remember that if the datatype is specified as Object , the compiler will accept data of any datatype. See Chapter 3 for complete information on datatypes in ActionScript 2.0.

The ActionScript compiler retrieves datatype information at compile time from so-called intrinsic files, which catalog the methods and properties supported by each class. You can find the intrinsic files in your Flash program installation folder, under Flash MX 2004\en\First Run\Classes .

Numerous errors plague the intrinsic files that shipped with Flash MX 2004 and Flash MX Professional 2004 (both the original version and the 7.0.1 updated version). Hence, in those versions of the authoring tool, the compiler will incorrectly skip type checking for some items and report mistaken datatype errors for others. Macromedia is aware of the problem and intends to update the intrinsic files in a future version of the authoring tool.


In response to the general problem of errors in the intrinsic files, I've chosen to list the correct datatypes for all items in this appendix, not the erroneous datatypes found in the intrinsic files. For example, according to the Boolean.as intrinsic file that shipped with Flash MX 2004 and Flash MX Professional 2004 (versions 7.0.0 and 7.0.1), the return type of Boolean.valueOf( ) is Number . But in this appendix, we've listed the return type as Boolean , which is the correct return type for Boolean.valueOf( ) .

When this appendix contradicts an intrinsic file, I'll make a special note so you won't be surprised by the compiler's behavior. For example, in the case of Boolean.valueOf( ) , I'll point out that the intrinsic files for versions 7.0.0 and 7.0.1 of the authoring tool use Number not Boolean as the return type. It's then up to you to conclude that, say, assigning true.valueOf( ) to a variable of type Boolean will (mistakenly) generate an error, as shown here:

 // Generates a (mistaken) error in versions 7.0.0 and 7.0.1 of // Flash MX 2004 and Flash MX Professional 2004. var val:Boolean = true.valueOf( ); **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Type mismatch in assignment statement: found Number where Boolean is required. 

To work around the mistaken error, leave the variable val in the preceding code example untyped or, alternatively, fix your installation's Boolean.as intrinsic file manually by following these steps:

  1. Open the following file, substituting your operating system user account name for USER and your Flash language code for LANGUAGE_CODE such as "en" for English:


    On Windows:

    c:\Documents and Settings\ USER /Local Settings\Application Data\Macromedia\Flash MX 2004\ LANGUAGE_CODE \Configuration\Classes\Boolean.as

    Note that the Local Settings folder is a hidden folder that must be revealed explicitly in Windows File Explorer using Tools Folder Options View Advanced Settings Files and Folders Hidden Files and Folders Show Hidden Files and Folders.


    On Mac:

    HD:/Users/ USER /Library/Application Support/Macromedia/Flash MX 2004/ LANGUAGE_CODE /Configuration/Classes/Boolean.as

  2. In the file Boolean.as , change the following line:

     function valueOf( ):Number; 

    to:

     function valueOf( ):Boolean; 

  3. Save the file Boolean.as .

You should also be sure to check for updated intrinsic files from Macromedia at http://www.macromedia.com/support/flash. I'll post news of any updates on my blog (http://www.moock.org/blog) and my mailing list (http://www. moock .org/moockupdates).

In general, I've done my best to represent the correct datatype in anticipation of future corrected intrinsic files. That said, to confirm the datatypes used by the compiler in your specific installation of the Flash authoring tool, you should always consult the appropriate intrinsic file. If you want to know which version of Flash you currently have installed, use Help About Flash.

Throughout this appendix, items marked with * are those that Macromedia erroneously omitted from the intrinsic files for Flash MX 2004 and Flash MX Professional 2004, versions 7.0.0 and 7.0.1. In those versions of the authoring tool, no type checking is performed on items marked with *. Future versions of the authoring tool will likely have updated intrinsic files and perform type checking on items marked with *.


Only core classes and objects defined by the Flash Player itself are presented in this appendix. Other classes, such as classes for Flash Remoting or Flash UI Components, are not listed. You can find datatype information for components in the component source files, stored in Flash's program installation folder, in the following locations: Flash MX 2004\en\First Run\Classes\mx\controls , Flash MX 2004\en\First Run\Classes\mx\containers , and Flash MX 2004\en\First Run\Classes\mx\managers .

For a description of the items in this reference, consult the Flash MX 2004 online Help and O'Reilly's ActionScript for Flash MX: The Definitive Guide (note, however, that depending on the edition, some items presented here may not be listed in that book).

The following classes are new in Flash MX 2004 and Flash MX Professional 2004. They cannot be used when exporting to Flash Player 6 format:

ContextMenu
ContextMenuItem
MovieClipLoader
PrintJob
TextField.StyleSheet
TextSnapshot
 <  Day Day Up  >  


Essential ActionScript 2.0
Essential ActionScript 2.0
ISBN: 0596006527
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Colin Moock

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