ActionScript 3 (AS3)

The object-oriented programming language

ActionScript 3 is an object-oriented programming language originally created by Macromedia Inc., which continued to evolve after being acquired by Adobe Systems. It is a superset of the ECMAScript standard (more widely known as JavaScript) with a stronger focus on classes, interfaces, and objects. While originally designed for Adobe Flash Player, ActionScript 3 may be used by developers today to build plugin-free, cross-platform, web applications with Apache Royale.

The following code snippet shows some of ActionScript’s core syntax:

package org.apache.royale
{
	public class WelcomeToActionScript
	{
		public function WelcomeToActionScript()
		{
			var message:String = "Hello world";
			sayHi(message, 3);
		}

		private function sayHi(message:String, times:int):void
		{
			for (var i:int = 0; i < times; i++)
			{
				// prints message to debug console
				trace(message);
			}
		}
	}
}

Sections

This document is divided into several sections:

Metadata describe the Metadata decorations that can be used for variables and functions. Code Conventions explains the typical ways Royale developers name files, classes, function, variables and more.

New ActionScript language features in Royale

The Royale compiler extends the ActionScript language with useful, new features. These language extensions are considered optional, and to use the new syntax, you must enable certain compiler flags.

The following new ActionScript features are available with the Royale compiler:

Limitations of ActionScript language extensions

Other ActionScript compilers, such as the one in the Apache Flex SDK, may not support Apache Royale’s extensions to the ActionScript language. Attemping to pass source code or SWC libraries using these language extensions to another compiler may result in compile-time errors or unexpected behavior at run-time. In other words, to write 100% portable ActionScript code that works with any compiler, you should avoid using any of Royale’s extensions.