(Not!) casting to ArrayCollection
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
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.
