To anyone switching from AS2 to AS3

10 posts

Flag Post

Why hello there!
I personally had a little trouble when I was making the leap from AS2 to AS3 so I set up a quick free website explaining how to do it really easily.

http://codingflashfast.webs.com/
Check it out if youre jumping over or want to convert code or something. Nothing else on the site so otherwise dont bother.

 
Flag Post

That site is full of errors; you never talk about access modifiers (nor use them at all), you imply that you can’t instantiate an array via [] in AS3, which is false, not to mention this:

var mage2=this.addChild(new mage());
Is how you create a mage in AS3.

You don’t even follow your own advice and never type that variable, then you set it to the return value of the addChild method, which is a DisplayObject, not a mage.

You never explain a thing (which makes sense, since it’s clear you don’t even know what you’re talking about).

And finally, this piece of gold:

Anyway that about sums up all the differences between AS2 and AS3. If you read everything you shouldnt have any trouble converting your code or starting fresh. Thanks for reading.

And you dare to add a donations button?

 
Flag Post
Originally posted by Senekis93:

That site is full of errors; you never talk about access modifiers (nor use them at all), you imply that you can’t instantiate an array via [] in AS3, which is false, not to mention this:

var mage2=this.addChild(new mage());
Is how you create a mage in AS3.

You don’t even follow your own advice and never type that variable, then you set it to the return value of the addChild method, which is a DisplayObject, not a mage.

You never explain a thing (which makes sense, since it’s clear you don’t even know what you’re talking about).

And finally, this piece of gold:

Anyway that about sums up all the differences between AS2 and AS3. If you read everything you shouldnt have any trouble converting your code or starting fresh. Thanks for reading.

And you dare to add a donations button?

Frosty with all due respect you should actually really study AS3 for many years before advising others how to do so. I appreciate you taking the initiative to move others to AS3 but some of the things in your post, like Senekis said, are blatantly wrong.

 
Flag Post

1) You should be encouraging the use of vectors instead of arrays. They are superior in almost every way.

2) In both AS2 and AS3, [] and new Array() are both valid. When I used AS2, I used the latter almost exclusively.

3) What you have listed doesn’t sum up the differences between the two, not by a long shot. What actually threw me off the most when I started was referencing bitmaps and getting sounds to work, although the former was likely due to working with FD exclusively instead of Flash 8 Pro + FD.

You’ve still got a bit of work to go on that before it’s a viable tutorial/guide/etc. As others have said, get more experience with the language first, because right now, it’s just not very good. Nothing personal.

PS:
These…

var mage2 = _root.attachMovie(“mage”,”mage2″+_root.getNextHighestDepth(), _root.getNextHighestDepth());
is how you create a mage in AS2

var mage2=this.addChild(new mage());
Is how you create a mage in AS3.

…are not the same, and not just for the reasons Senekis pointed out. One is attaching the mage directly to root (toxic…bad…DO NOT WANT) and the other is attaching the mage to whatever class owns that line of code. If it’s anything other than a container, intended for that purpose, you’re going to have bad time. (But a much better time than if you’d just nailed everything to root!) To make them closer to one another:

var mage2:mage = this.attachMovie("mage", "mage2" + this.getNextHighestDepth(), this.getNextHighestDepth());
 
Flag Post

T-T I want to cry now. After opening the link.

 
Flag Post

Yeah it’s not correct. Hope he doesn’t feel bad about it though. You shouldn’t feel bad Frostyfun!

 
Flag Post

I hate AS3, most of the codes are unnecessary difficult.

 
Flag Post

I feel you are all giving this guy a bit of a frosty welcome. Criticism is fine, but keep it constructive and civil.

For someone jumping from AS2 to AS3, they just want their projects to work. Making the jump is hard enough, and it might not be the best time to learn about OOP, access modifiers, vectors and other good coding principles – there’s time to learn those later.

I couldn’t write a good tutorial for AS2 to AS3, because I’ve never used AS2, and I’m a long way away from the beginners perspective. I applaud Frosty’s efforts, and if you think you can do better you should write your own.

 
Flag Post

Like Curious said, this sort of info, presented in such a simple way, is what people need in order to move from AS2 to AS3. Just enough to get a project working, nothing else. If there’s infos on there that’s incorrect (as in, it wouldn’t compile if you tried to use it) that’s not helpful, but if it just isn’t “best practice” then it doesn’t matter, you’re missing the point.

 
Flag Post
Originally posted by CuriousGaming:

I feel you are all giving this guy a bit of a frosty welcome.

Ithinkicwhatyoudidthar.

After reading the tutorial:
It isn’t by any means comprehensive, and some of it is a bit dodgy, but I can see how some people moving from the jumbled crazieness of AS2, to the relative safety of AS3, might find it somewhat useful as a first step. However, the main thing I think you also need to cover is that you cannot put code directly onto an object’s frame in AS3.