MileStone Get! Or another way to put it, how to avoid Actionscript 2.0 traps and finally get to Actionscript 3.0

So…not too much at the moment done, but that’s in part because I now may (I presume, that is) the final official jump to Actionscript 3.0!

 

…Okay, this is an important point for me because I’ve been stuck in Actionscript 2.5 (Half 2.0, half 3.0) for…about four years now? I haven’t been actively working on it that entire time, in fact…not really at all last year, and well, I’m proud of this change, at least.

 

I’ve done Python and Java OOP programming fine before, but I first got programming in Actionscript 2.0. Which let you code on frames. Which I do. A lot of the time. So…transitioning to Actionscript 3 has been…not so smooth.

 

Part of the problem…okay, pretty much all of it, has been creating an ActionScript object.

 

Which I got the final working copy of my code working by going here:

 

http://www.flepstudio.org/forum/object-oriented-programming-tutorials/440-tutorial-1-my-first-3-0-class.html

Thing is, this doesn’t *quite* work for me – I wanted variables already, and functions!

 

So…aside from that tutorial, the following things to keep in mind – some of these are somewhat interesting:

 

  • First off – even if you aren’t putting your Actionscript .as files (See the tutorial above if you don’t know what I’m talking about), you still need a package wrapper around your class. Which is different than Java, where having no named package for the file let you leave it alone. Default package is just “package{” – Yeap, no name, just the bracket (Make sure you close it at the end of the file – properly).

 

  • Secondly, the constructor’s…considered a function. So for your constructor, it has to go like so:

public function LightGrid(){

        //....

}

  •  Thirdly, when doing this, and linking it from an item in the library of default Flash (Right-click object in library, go to Linkage, Make sure you select “Export for ActionScript”, and input your .as file’s name in there, and hit the checkmark to validate it), DO NOT leave versions of it on your stage – it’ll complain about them if you reference them, so it’s just better practise.

Um, yeap. About all I can think of now – though you can start viewing the source (When updated) here:

 

http://www.sfu.ca/~ajr12/LudumDare22/LudumDare/

Enjoy!