In case you don’t know about it, the FlashintheCan is going on a cross Canada tour, with stops in Toronto (October 19), Ottawa (October 21), Montreal (October 23), and Vancouver (October 25). Should be a blast - I’m hoping to attend the Toronto date, but am swamped at work and don’t know that I’ll be able to make it out.
Speakers include (in no particular order):
» Kevin Airgid
» Josh Davis
» Tony MacDonnell
» Grant Skinner
» Amit Pitaru
» Mike Downey
» Mike Chambers
» Ben Radatz
» Jared Tarbell
» Jessey White-Cinis
» Shane Mielke
…and many more.
For full details, check out the official site @ flashinthecan.com.
Share me:
These icons link to social bookmarking sites where readers can share and discover new web pages.
Typed Arrays.
Data-typing in Flash is great. It makes debugging your ActionScript much easier, cleaner, etc. The benefits are huge. Unfortunately, as soon as you throw an array into the mix, you’re outta luck - Flash just ignores all you (data-) typing.
Why is this a big deal, you ask? I’ll tell you. It’s a big deal because the second you use an array to store values, the compiler can’t type check for you. Which means you could easily miss bugs that would otherwise show up at compile (publish) time. Which is bad. Because finding bugs at compile time is much better than having to find them at runtime.
Obviously, you could write your own collection class, or you could type-cast the values out of your array, but that’s a major pain in the butt, litters you code with relatively useless conditional statements, and essentially defeats the purpose.
Back to generics.
If you’re familiar with C++ (templates), or with C# 2.0 (generics), you already know what generics are. Why are they good? Because they allow you to create container classes that are typed, without creating multiple implementations for each possible type - you pass the type you want to use to the constructor (essentially - I’m fudging a bit here), and the compiler takes it from there. For example, you can create a List class that can hold strings, integers, or instances of your Person class, all based off a single generic. And the compiler will then throw an error if you attempt to either add a value or use a value from the List that doesn’t match the data-type that has been assigned to it.
Of course, you could just type everything as ‘object’ to have a pseudo-generic, but being realistic that’s not really generic at all. That’s just saying that ANYTHING goes (because everything in ActionScript is a subclass of Object). Technically giving you much of the implementation, but none of the benefits.
So maybe this is just a personal rant. I want generics in Flash. Mainly because I want typed arrays. And because I can’t think of a solid way of realistically implementing them in ActionScript. Especially with compile time type-checking.
Have I mentioned that I also want (true) operator/method/constructor overloading? Yes, I know there are libraries out there that enable method overloading in ActionScript, and there are hacks to more or less give equivalent functionality, but they’re all really hacks, and a mega pain the implement.
Ah, well…pipe dreams will be pipe dreams. I guess I could always switch over to Robin Debreuil’s C# to Swf app, and start writing my Flash in C#…
Share me:
These icons link to social bookmarking sites where readers can share and discover new web pages.