ActionScript 3 Getting started with ActionScript 3

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

ActionScript 3 is the programming language for the Adobe Flash Player and Adobe AIR runtime environments. It is object-oriented ECMAScript based language used primary for native application development on desktop (Windows/Mac) and mobile (iOS/Android) devices.

Adobe learning resources: http://www.adobe.com/devnet/actionscript/learning.html

History and more details: https://en.wikipedia.org/wiki/ActionScript

Online documentation on classes and reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package-detail.html

Versions

There is a single version of Actionscript 3, named "ActionScript 3.0"

Flash VersionCodenameChanges and ImprovementsRelease Date
Flash Player 9.xZaphodinitial release2006-06-22
Flash Player 10.0Astrointroduced the Vector.<T> type, the Adobe Pixel Bender shader filters in flash.filters.ShaderFilter class, and its hardware support on multiple CPUs.2008-10-15
Flash Player 10.1Argointroduced flash.events.TouchEvent class to work with multitouch devices, and other support of mobile device hardware, such as accelerometer.2010-06-10
Flash Player 10.2Spicyintroduced flash.media.StageVideo class and the general framework to work with stage video playback in AS3.2011-02-08
Flash Player 11Serranoadds H.264 support to video streaming over NetStream objects in both directions. Also it adds SSL/TLS support for Flash connection with SecureSocket class.2011-10-04
Flash Player 11.4Brannanintroduced flash.system.Worker class and the ability to delegate asynchronous work to other threads on the client.2012-08-10
Flash Player 11.8Harrisonremoved hardware support (JIT compilation) for Adobe Pixel Bender shader filters, drastically reducing performance of any PB shader filter execution.2013-05-09

Installation Overview

ActionScript 3 can be used by installing the Adobe AIR SDK or Apache Flex SDK or as part Adobe's Animate CC product (formerly known as Flash Professional).

Adobe Animate CC is a professional software solution that can be used to create AS3 projects using visual tools - once installed, no further steps are necessary to begin creating AS3 projects.

The AIR SDK and Flex SDK can be used with command line tools or with various third party IDEs.

In addition to Adobe Animate CC, there are four other popular IDEs capable of working with AS3. These IDEs have their own instructions on how to get started.

A displayed "Hello World" example

package {
    import flash.text.TextField;
    import flash.display.Sprite;

    public class TextHello extends Sprite {
        public function TextHello() {
            var tf:TextField = new TextField();
            tf.text = "Hello World!"
            tf.x = 50;
            tf.y = 40;
            addChild(tf);
        }
    }
}
 

This class uses the TextField class to display the text.

Apache Flex Installation

from http://flex.apache.org/doc-getstarted.html

  1. Download the SDK installer

  2. Run the SDK installer. The first question you will be asked is the installation directory.

    • on a Mac, use /Applications/Adobe Flash Builder 4.7/sdks/4.14.0/
    • on a PC, use C:\Program Files(x86)\Adobe Flash Builder 4.7\sdks\4.14.0

    You will need to create the 4.14.0 folders. Press Next. Accept SDK Licenses and Install.

IDE Specific Instructions for Apache Flex setup:

Building Flex or Flash projects at the command line using mxmlc

The Flex compiler (mxmlc ) is one of the most important parts of the Flex SDK. You can edit AS3 code in any text editor you like. Create a main class file that extends from DisplayObject .

You can trigger builds at the command line as follows:

mxmlc -source-path="." -default-size [width in pixels] [height in pixels] -default-frame-rate [fps] -o "outputPath.swf" "mainClass.as"
 

If you need to compile a Flash project (as opposed to Flex) you can add a reference to the Flash library as follows (you'll need to have the Adobe Animate IDE installed):

mxmlc -source-path="." -library-path+="/Applications/Adobe Animate CC 2015.2/Adobe Animate CC 2015.2.app/Contents/Common/Configuration/ActionScript 3.0/libs" -static-link-runtime-shared-libraries=true -default-size [width in pixels] [height in pixels] -default-frame-rate [fps] -o "outputPath.swf" "mainClass.as"
 

Or on Windows:

mxmlc -source-path="." -library-path+="C:\Program Files\Adobe\Adobe Animate CC 2015.2\Common\Configuration\ActionScript 3.0\libs" -static-link-runtime-shared-libraries=true -default-size [width in pixels] [height in pixels] -default-frame-rate [fps] -o "outputPath.swf" "mainClass.as"
 

Flash Develop Installation

FlashDevelop is a multi-platform open source IDE created in 2005 for Flash developers. With no cost, it's a very popular way to get started developing with AS3.

To Install FlashDevelop:

  1. Download The Installation File and run the installer
  2. Once installation is complete, run FlashDevelop. On the first launch, the App Man window should appear asking you to pick what SDK's and tools to install.

enter image description here If the AppMan doesn't open automatically, or you want to add something later, open it by choosing 'Install Software' on the 'Tools' menu.

Check the AIR SDK+ ACS 2.0 item (in the 'Compiler' section) and the Flash Player (SA) item in the 'Runtimes' section (plus anything else you'd like to install). Click the install button.

  1. Once the SDK is installed, let's test is by creating a hello world project. Start by creating a new project (from the Project menu)

  2. Choose AIR AS3 Projector from the list, and give it a name/location.

  3. In the project manager panel (choose 'Project Manager' from the view menu if not already visible), expand the src folder, and open the Main.as file.

  4. In the Main.as file, you can now create a first example program like Hello World

  5. Run your project by clicking the play icon, or pressing F5 , or Ctrl+Enter . The project will compile and when finished a blank window should appear (this is your application). In the FlashDevelop output window, you should see the words: Hello World.

You are now ready to start developing AS3 applications with FlashDevelop!

Hello World

An example document class that prints “Hello, World” to the debug console when instantiated.

import flash.display.Sprite;

public class Main extends Sprite {

    public function Main() {
        super();

        trace("Hello, World");
    }

}
 


Got any ActionScript 3 Question?