How to know if actionscript 1, actionscript 2, or actionscript 3?

actionscript, actionscript-2, actionscript-3, flash

Solution

Update: My experience with AS1/2 is limited and this is based on what I've seen in AS forums. From the comments it seems that the second and third methods of event handling are valid in both AS1 and AS2.

The syntax of handling events are different:

ActionScript 3

addEventListener(MouseEvent.MOUSE_UP, handleClick);
private function handleClick(e:MouseEvent):void
{
  //Just do it
}

ActionScript 2

onRelease = function():Void{ //it's not void - it's Void
  //do something
}

ActionScript 1

on(release){
  //do something
}

You might find this page helpful: Migrating from AS2 to AS3

AS3 way of adding a new children is `new` followed by `addChild`

var s:Sprite = new Sprite();
var tf:TextField = new TextField();
this.addChild(s);
s.addChild(tf);

It used to be `createMovieClip` and `createTextField` methods earlier - not sure about exact version though.

_root.createTextField("mytext",1,100,100,300,100);
//that is name, depth, x, y, width, height
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = false;

Earlier, if you had the `name` property of a child, you could access the child from the parent using `parent.childName` even if the parent class didn't have a property called `childName`. With AS3, it is possible only if the parent class have a property called `childName` (of appropriate type) and you have assigned the child's reference to it (or you have created that property on the dynamic class `MovieClip`). There is `getChildByName()` - but it will return the first child with the given name (and it is possible to have duplicate names in a child list).

Problem

I don't have a specific code sample, but is there a general way to guess what version of Actionscript the code snippet is: 1 or 2 or 3? I read somewhere that if it's code in the timeline, it's considered Actionscript 1.

Original source