15.4 Reserved Words

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 15.  Lexical Structure

Some reserved words are used by the ActionScript interpreter to denote specific built-in language features, such as statements and operators. They are reserved for use by the interpreter, and we must avoid using them as identifiers in our code. Using a reserved word for any purpose other than its reserved internal purpose causes an error in most cases. ActionScript's reserved words are listed in Table 15-1.

Table 15-1. ActionScript's reserved words

add[1]

delete

ge[1]

le[1]

onClipEvent

this

and[1]

do

gt[1]

lt[1]

or[1]

typeof

break

else

if

ne[1]

return

var

case

eq[1]

ifFrameLoaded[1]

new

super

void

continue

for

in

not[1]

switch

while

default

function

instanceof

on

tellTarget[1]

with

[1] Flash 4 reserved words that have been deprecated as of Flash 5.

You should also try to avoid using the keywords listed in Table 15-2. They are not reserved words for ActionScript in Flash MX, but they may become a part of the language in the future, because they are slated for potential use by ECMA-262.

Table 15-2. Potential reserved words in the future

abstract

const

final

int

protected

transient

boolean

debugger

finally

interface

public

try

byte

double

float

long

short

volatile

catch

enum

goto

native

static

 

char

export

implements

package

synchronized

 

class

extends

import

private

throws

 

In addition to the formally defined reserved keywords, you should also avoid using the names of built-in properties, methods, and objects as identifiers in your code. Doing so overrides the default behavior of the property, method, or object in question.

The following is a bad idea because the Date variable overrides the built-in constructor of the same name:

Date = new Object();   // Oops! We just disabled the Date( ) constructor

Now we can no longer create Date objects:

var now = new Date( );  // Sets now to undefined trace(now);            // Displays the empty string, not the current time and date
     



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

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