AS2 and AS3: Differences 1
Posted on: 26th March 2009
This tutorial is aimed at people who know AS2 and are looking to learn AS3. It is the first in a series of AS3 tutorials aimed at guiding people through the learning process, starting from the very beginning.
Lets start by taking a look at some AS2 code. Imagine I wanted to create a text field...
myMovieClip.createTextField("myText", depth, x, y, width, height);
What this code does, is creates a new text field with a name of 'myText' at depth 'depth', at position (x,y) with width of width and height of height, obviously. In AS3 we'd do something like this:
var myText:TextField = new TextField();
You'll probably notice straight away that this looks a lot simpler. As rather than having to remember about createTextField, we simply set up a variable with the class TextField with the same syntax that we would use if we were creating any sort of variable, whether it be a number, string, whatever. This makes it much easier to remember than the AS2 equivalent. You might have noticed that we do not have the properties set like we do with the AS2, but we can still do this either separately or in the brackets at the end of the AS3 line of code.
Lets take a look at some more code:
// AS 2.0
myMovieClip.attachMovie(“mySymbol”, “newMC”, depth);
// AS 3.0
var myMC:MovieClip = new MovieClip();
Okay, so these too bits of code don't do exactly the same thing but the principle is pretty much the same. In both of these examples, we've had less code to write but this is not always the case in AS3. The key thing to notice here is that the AS3 for both text fields and movieclips have identical syntax and we're doing the same thing for each. AS3 brings in standardisation, it doesn't matter what we\'re creating it's all the same standards. This makes AS2 both easier to use and learn.
Tags: AS2, AS3, tutorials, differences, AS3NoobToPro
1 Comments
Tutorials
Posted on: 8th March 2009
I was hoping to have the first one up by now, but I've been sidetracked by other projects and haven't got around to writing it up yet, but just a quick note on tutorials... I've decided that although some AS tutorials will be written in AS2, particularly to start with, the majority will be written in AS3 as I think it's good to keep up too date. A lot of people on the NG flash forum still seem to be using AS2, so I'm not going to completely neglect it, just slowly phase the tutorials out. I will be starting the AS3 tutorials at a very basic level, for those who have no previous experience with AS3 or AS2 and then we'll delve in to more complicated stuff before going for full blown game tutorials like the AS2 tutorials will be. Every tutorial will have the source files for download. Normally, I will port the code to AS3, if the tutorial was in AS2, and vice-versa.
On a slightly different subject, I'm hoping to set stuff up so I can make some video tutorials to go with them but this depends on me getting stuff set up and that my microphone doesn't record with the worst sound quality ever. If you have any links to decent screen recorders, that tend not to lag, reply to this post.
Look forward to posting the first one.
