Hot on the heels of my articles about utility functions for objects and classes, today’s article has a set of utility functions for DisplayObjects.
Archive for category AS3
On the heels of last Friday’s article on Utility Functions For Objects, today’s article will show a few utility functions for the Class class. In case you’re not familiar with it, Class represents a class like you would write and is useful main for more dynamic programming where you want to instantiate a class based on a variable (eg. var c:Class) rather than a constant (eg. BitmapData). So how do you get a Class variable? The Flash API provides some ways to go about it and I’ll provide some ways to make that more convenient.
Like most programmers writing non-trivial applications, I’ve piled up a lot of utility functions over the years. Most of them are simple and effective. They are short and get their job done. You or someone you know has probably written these functions, but maybe not in AS3. So today I’m going to share a few utility functions for Objects in AS3.
A recent post by Simo Santavirta featured an algorithm with an irresistible name: Extremely Fast Line Argorithm. A comment on that article piqued my interest and I decided to test the algorithm out against Adobe’s Graphics.lineTo.
MXMLC’s -define feature allows you to do two things: compile-time constants (as covered previously) and conditional compilation. Both are very useful, so today I’m covering conditional compilation.
I’ve recently been seeing more and more usage of while loops by those who I presume are interested in performance. I’ve always assumed that these was not faster than for loops, but today I am finding out.
The BitmapData class is among the most useful classes in AS3. When it was introduced in Flash 8 it dramatically improved Flash development by opening up new potential for features and optimization. Since it’s used so often, it’s good to know as much about it as possible. Today I’m going to cover the performance difference that turning alpha (a.k.a. transparency) on makes.
I recently received an e-mail from Dmitry Zhelnin (translation) with a test he did concerning the speed of a couple ways to get a value for a key, which I like to call a map and Wikipedia likes to call an associative array. I’d been meaning to do a similar test for a while now and, guess what, I finally have! UPDATE: fixed miss test for fixed-size Vectors.
For a change, today’s article has nothing to do with performance. Instead, I’m going to tackle a simple task that I find myself doing all the time while working with Flash UIs: displaying icons. It sounds boring and, well, it really aught to be. However, I’m constantly asked by UI designers to populate some list item clips, frames, other other little holders with icons that are dynamically loaded by context. I figure that many others must be asked to do the same, so today’s article shows you a little function to help with that task.
Alec McEachran’s latest article about constants reminded me of a trick I’ve recently learned and became a big fan of. His article expresses the pain endured by those who wish for both speed and maintainability in their AS3 apps. The solution the article doesn’t reach though is that of compile-time constants. This is truly the best of both worlds, so let’s learn about it.