Getting started with actionscript
Remarks#
Actionscript formerly developed by Macromedia Inc., which now have been acquired by Adobe Systems Inc. is a powerful object-oriented programming language based on ECMAScript. Initially created with very limited set of navigation controls like play(), stop(), gotoAndPlay() etc., usually used for 2D vector based animation and required Actionscript Virtual Machine(AVM) like Flash Player for execution, have now evolved into a robost and flexible programming language ideal for rapid rich internet application development, capable of hardware accelerated rendering with Stage3D, targeting not only Flash Player, but also Adobe AIR based desktop and mobile platforms.
Versions#
Version | Release Date |
---|---|
Flash 4 actions | 1999-01-01 |
Actionscript 1 | 2000-09-01 |
Actionscript 2 | 2003-09-01 |
Actionscript 3 | 2006-06-27 |
Source: https://en.wikipedia.org/wiki/ActionScript
Installation or Setup
Detailed instructions on getting actionscript set up or installed.
Hello World Example
ActionScript 2.0:
_root.createTextField("message", 0, 5, 5, 300, 50);
var tf:TextFormat = new TextFormat();
tf.color = 0xFF0000;
tf.size = 32;
tf.bold = true;
message.setTextFormat(tf);
message.text = "Hello World!";
First function creates a TextField named “message” in the depth 0 of the _root(MainTimeline) at coordinates (5,5) having dimensions 300x50, where unit is pixel.
Then we create an instance of TextFormat class and assign color, size and bold properties and apply it to the TextField using second function to make our TextField red with fontsize 32 pixels and bold.
Finally, we assign the text property of our newly created TextField to “Hello World!“.
ActionScript 3.0:
import flash.text.TextField;
import flash.text.TextFormat;
var message:TextField = new TextField();
message.x = message.y = 5;
message.width = 300;
message.height = 50;
var tf:TextFormat = new TextFormat();
tf.color = 0xFF0000;
tf.size = 32;
tf.bold = true;
message.defaultTextFormat = tf;
message.text = "Hello World!";
MovieClip(root).addChild(message);
Both of the above examples should output something like this: