Language Basics

Language basics in ActionScript 3

ActionScript is a superset of the ecma 4 spec. That gives it the same roots as Javascript and code will look very similar. The biggest difference is the optionally typed quality of ActionScript, and classes. Ecma 6 added classes to Javascript as well, but Javascript classes are less structured that ActionScript classes.

Because ActionScript was forked from the ecma spec at version 4, there are features that Javascript has which are missing from ActionScript and vice versa. Below is an overview of the main ActionScript features.

Scope

There are four levels of access scope in ActionScript:

  1. public
  2. private
  3. protected
  4. internal

These are defined by declaring an access modifier before a declaration.

More details to fill in…

Accessor Types

There are three basic accessor types in ActionScript

  1. function
  2. var
  3. const

ActionScript does not support arrow functions or let. The use of the three accessor types are similar to Javascript.

Instance and Class Accessors

By default any accessors of a class are instance accessors. For class-level methods, vars and const, you need to add the static modifier. For more details read about static accessors in classes.

Primitive Types

TODO

XML Types

TODO

Vector Types

TODO

Type Casting

There’s two ways to do type casting: Foo(myInstance) and fooInstance as Foo. There is a noteworthy difference between these two: Foo(myInstance) will throw an error if th type cannot be cast, while fooInstance as Foo will assign null if it cannot be cast without throwing an error. Runtime type checking can be turned off in the compiler. (add details)

TODO what else belongs here?