There’s something strangely satisfying about switching gears from a well structured language like Ruby all the way back to the days of actionscript 2. It brings me back a little. Actionscript 2 has a lot of intricacies and subtle nuances that you wouldn’t expect and that’s one thing that makes it fun. It’s fun because it doesn’t normally work as expected. You have to delve deep into the minds of the poor people who were forced to create it and outsmart them. It’s fun because when you finally get something to work, you can look at your code and say, “there’s no way that should work!” After a few hours of working with the language you begin to anticipate the worst possible scenario. You would think this for instance: If I want to create an array object called bar with 3 elements, I’d do it like this:

var bar:Array = new Array('a', 'b', 'c');

but if I wanted only one element in the array, I’d do it like this:

var bar:Array = new Array(['a']);

Of course! It’s so obvious. The square brackets are obvious because actionscript 2 wants to make doubly sure that bar will actually be an array and not just a string, whereas the commas give it away in the first example so adding square brackets there would just create an array containing an array.

Continue reading »