Archive for the 'ActionScript' Category

(Not!) casting to ArrayCollection

Wednesday, August 8th, 2007

This one tripped me up a few times, so maybe I’ll save some of you a little time.

If you have an Array that you’re transforming to an ArrayCollection, don’t forget the new statement! Often I’ll forget I’m creating an ArrayCollection from an Array and not just casting, so I’ll try something like

var powerfulArrColl:ArrayCollection = ArrayCollection(boringArray)

This, of course, yields a Type Coercion failed: cannot convert (gobblygook) to mx.collections.ArrayCollection.

When you’re bleary-eyed day is at and end, very practical and simple error messages like get caught in the gaps opening between your brain folds. “WTF?! What do you mean you can’t cast fricking array to arraycoll…fricking, filth foul….oh….yeah, I’m not casting. I’m creating a new ArrayCollection with the old array as a parameter.”

So don’t forget your new statement.

Javaction Script

Tuesday, July 31st, 2007

With ActionScript 3.0 and the ExternalInterface API, flash developers like me are in a dreamy time-warp … back in the day I like so many other designer/developers cut my programming teeth on Danny Goodman’s JavaScript books. Now AS3.0 is derived from the same mother tongue (ECMAScript) and JavaScript is becoming an integral part of Flex applications and not something just to wrestle with when trying to embed a .swf (”…why…won’t…it…work??!!”)

So when I read this post by Rubinelli, I was glad to hear that some view JavaScript as the “Next Big Language.” Soon, everyone will be putting colons between their variable names and type declarations, and you will know that it is good.