< 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 .
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:
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.
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:
|
< Day Day Up > |