ActionScript in a Nutshell - slategroup/tsg-analytics-plugin GitHub Wiki

ACTIONSCRIPT IN A NUTSHELL: ActionScript is a sibling of JavaScript. Both are branches of ECMAScript. The syntax is nearly identical and they share all of the same keywords. ActionScript 3 is based on an Object Oriented version of ECMAScript (which ECMA has since abandoned). Where object-oriented JavaScript is accomplished through prototyping, ActionScript 3 has a more familiar class-based approach that's somewhat familiar to C# or Java. The main differences between ActionScript and JavaScript are ActionScript has packages & classes and variables & functions are more specifically declared and strongly typed. Compare:

JavaScript string variable:

var myString = "Hello World.";

ActionScript string variable:

private static var _myString:String = "Hello World";

Note that you can now declare private, public, & protected variables as well flagging things as static. The biggest difference between these declarations from C# or Java is that the type is appended to the variable name with a colon(:)

Here are a couple functions to further illustrate that pattern: JavaScript:

function helloWorld(string){ alert(string); }

ActionScript:

private static function helloWorld(string:String):Boolean { trace(string); return true; }

Note that you type the parameter (String) as well as the method signature (Boolean).