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.
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).
Between AS3 and AS1/2 there are a lot of differences and in most cases you will see it right away (look for addChild and addEventListener in AS3). The differences between AS1 and AS2 however where far less obvious, but probably the most relevant language-wise is the introduction of the "class" concept together with a few statements and keywords for OOP development (class, public, private, etc...).
EDIT: look, the wikipedia explains it much better:
2003–2006: ActionScript 2.0 The next major revision of the language, ActionScript 2.0, was introduced in September 2003 with the release of Flash MX 2004 and its corresponding player, Flash Player 7. In response to user demand for a language better equipped for larger and more complex applications, ActionScript 2.0 featured compile-time type checking and class-based syntax, such as the keywords class and extends. (While this allowed for a more structured object-oriented programming approach, the code would still be compiled to ActionScript 1.0 bytecode, allowing it to be used on the preceding Flash Player 6 as well. In other words, the class-based inheritance syntax was a layer on top of the existing prototype-based system.) With ActionScript 2.0, developers could constrain variables to a specific type by adding a type annotation so that type mismatch errors could be found at compile-time. ActionScript 2.0 also introduced class-based inheritance syntax so that developers could create classes and interfaces, much as they would in class-based languages such as Java and C++. This version conformed partially to the ECMAScript Fourth Edition draft specification.
http://en.wikipedia.org/wiki/ActionScript#ActionScript_2.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With