Lassie Migrates to AS3

I’ve been meaning to get a developer’s blog going for a while, so here it is. Finally!

Let’s start with some back story: I started tinkering with ActionScript 3 during Christmas break of 2007. I had a big game project coming up for the Peace Corps (now live at http://www.peacecorps.gov/game) which mandated that I get a firm grasp on AS3 before going into the new year. While I’d been tinkering with AS3 for a few months, I hadn’t gotten beyond sticking some MovieClip classes on stage before I was ready to tear my hair out in frustration. Every single thing I did upset the compiler and caused an error. It was like having a nightmare girlfriend: you could never make her happy no matter how hard you tried. Go the extra step to add a couple extra package and namespace declarations and then it’d start complaining about parenting and display accessibility. Ultimately, I found that a little failure went a long way toward sending me back into the safe and comfortable realm of AS2 — which glowed with the warmth of a cozy fire on a cold night. Maybe that’s a little poetic, but the imagery isn’t far off. Putting aside something that you’re good at to get into something new that you suck at is tough. AS3 is particularly difficult because it’s so much like AS2 but with so many little differences. There’s a lot of relearning required to take the plunge.

However, like so many times before, Lassie was the project that got me up to speed and pointed in a new direction. It’s a hobby project with no pressure or deadlines which helps dramatically; plus I can have fun with it! Of course, I had the same old frustrations off the starting blocks… errors, errors, errors. However, I hit my big AS3 epiphany when I realized how to read call stack errors. Then I was on fire.

So, if you’re new to AS3 then you’ve probably been frustrated by something like this before:

TypeError: Error #2007: Parameter child must be non-null.
   at flash.display::DisplayObjectContainer/addChild()
   at demo_fla::MainTimeline/init()
   at demo_fla::MainTimeline/demo_fla::frame1()

Oie. What does that mean? I used to read the first line, not understand it, get frustrated, and storm off back to AS2. Then I realized that this is a trace of the call stack, which lists the chain of events that led up to the problem… meaning that you should read it from the bottom. Suddenly it all made sense! In the above error, a frame1 action calls my init() method, which tries to add a child. However, the error tells me that a problem occurred while trying to call addChild(): “Parameter child must be non-null”. Translation: I was trying to add a null object as a child of the stage during my init() method… ohhhhhh.

Everything was easier after that. My programming took off. I was growing the Lassie game player quickly until min-January 2008 when I realized that I really needed a means to dynamically manage game data before moving forward, so I switched gears and have been building the game admin tool (Lassie Shepherd) ever since. Progress is slow, but a lot of that is because I’m starting from square-one in AS3 and have had to build all systems from the ground up; so I’ve had a lot of ground to cover!

However, it’s been a great move. I can’t say enough good things about the syntax, structure, and possibilities with AS3. While it was a tough transition, it was well worth it. I made my first real progress with AS3 a few days before Christmas 2007 when I got a Lassie room layout to render based on a static data structure. By the end of Christmas break I’d gotten the majority of the room application up and running. It was pretty cool to see it all coming together, and to see my code naturally deviate into better OOP form just based on the syntax and structure of AS3. It is truly a remarkable improvement over some of the derilect qualities of AS2.

Advertisements

1 comment so far

  1. ganesh on

    It sounds so good, that how small failure turns you to look back to as2, but in heart you wanted to take new challenges of as3. I know how it feels cause I am facing theses similar problems now, with one of my project. But my problem is that I am time bound.. Thanks nice post


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: