Article
Bugs and Quirks: Capabilities.playerType
Posted in Article, Bugs on January 17th, 2011 by Ian Ford – Be the first to commentThis isn’t technically a bug, but it is a strange quirk in ActionScript 3. I’ve discussed the Capabilities class before. I still like it. I still think it’s very useful.
I have one problem.
The Capabilities class has no public string constants. I was looking for an article or document explaining why you should use string constants, but I couldn’t find one so I suppose I’ll write my own later.
Anyway, most every other class that passes string values around uses constants to store those values. The Capabilities class does not. This results in code like the following:
if (pt == "ActiveX" || pt == "PlugIn") {
//...
} else if (pt == "External" || pt == "StandAlone") {
//...
}
Remember, it should be “PlugIn,” not “Plugin,” “plugin,” or “plugIn.” If you use any of the latter three your SWF will publish just fine without any compile errors to let you know something is amiss. It won’t be until your conditional fails to select either option that you start scratching your head wondering what went wrong.
I propose that adobe add a PlayerType class to the flash.system package. The class would simply contain four static values:
public static const ACTIVEX:String = “ActiveX”;
public static const PLUGIN:String = “PlugIn”;
public static const EXTERNAL:String = “External”;
public static const STANDALONE:String = “StandAlone”;
The benefit of having such a class is that as long as you used those values, if you committed a typo or some other minor error the compiler would let you know. Wouldn’t that be nice? I’ve submitted this as an issue in the Flash Player Bug management system. Go vote on it.
A Note on Web Video
Posted in Article, H.264, Links, Video, WebM on January 11th, 2011 by Ian Ford – Be the first to commentApparently Google just announced that Chrome will no longer be supporting H.264. This is obviously controversial for a number of reasons.
I caught an interesting article predating the issue discussing the problem with using H.264 to encode your video. It’s worth the read.
The Santa Brand Book
Posted in Article on December 20th, 2010 by Ian Ford – Be the first to commentIn the spirit of christmas and advertising, I figured this just had to be shared
Design Study: Sharing is Sexy!
Posted in Article, Design Study, Graphic Design on December 19th, 2010 by Ian Ford – Be the first to commentI was reading somebody’s Flex blog the other day and noticed they had a Share Widget at the bottom of the post.
I’ve seen this widget around town. It’s a fairly popular way to share content with other networks.
When you roll over the widget, it animates, with a slide reveal effect, to this state:
When you roll over individual icons, they pop out almost all the way.
It’s a neat widget, but I have a few criticisms that seem obvious to me:
- Sharing is not sexy, even if we’re just trying to be playful and clever. I challenge you to find me even one person who finds sharing obscure posts about Flex to be sexy. I challenge you.
- The interface is slow. I don’t mean the transitional reveal is slow, but rather my experience with it is slow.
What do I mean by slow? Let’s play a game: Pick a sharing service off the top of your head, and see how long it takes you to find the correct button for it in this widget. Need I say more?
Android App Inventor
Posted in Android, Article, Mobile on December 16th, 2010 by Ian Ford – Be the first to commentI’ll admit that I was skeptical when I first heard about Google’s Android App Inventor, but I must say that this video is pretty compelling, if not a bit silly.
Algorithms: Outlying Points
Posted in Algorithms, Article, Documentation, Experiments, Flex, Theory, Tips, Tutorial on December 15th, 2010 by Ian Ford – Be the first to commentI thought it would be interesting to share some algorithms that can be used to solve problems you may run into while developing applications.
Given a variable number of numeric values, which of those values is the “outlier.” In this case, by outlier, we mean the most distant number. For example, given the set [1, 2, 3, 10], the outlying number is clearly 10 since it is further in value from the other numbers than any other.
How do we determine this? We calculate the sum of the distances from each value to each other value. That value looks like this:
The value in your list for which this expression is greatest is your outlier. This works for any set of values for which you can define a distance function. In the case of single values, the distance function is simply:

For coordinate values on a cartesian plane, the function is:
These can of course be extended into any number of dimensions depending on your needs. Here’s a demo that applies the idea.
In the demo above you can see that the outlying, or most distant, point glows in black. You can drag the points around and the outlying point will update accordingly. You can also see a skeleton drawn among the points demonstrating the values being calculated in our distance formula.
Optimizing Animations
Posted in Actionscript 3, Animation, Article, Experiments, Flex on December 11th, 2010 by Ian Ford – Be the first to commentI was working recently on a project that called for a certain special effect. Perhaps you’re all familiar with the classic page curl?
There’s an excellent tutorial available for free online at O’Reilly. I followed it in a misguided attempt to create my own page curl in AS3. Unfortunately, AS3 seems to have some trouble rendering complex masking effects correctly, and I was unwilling to drop the project to AS2 to accommodate one pushy art director so we needed another option.
The art director suggested we do the animation manually in InDesign and export a series of still frames that we could use in Flash. It sounded simple enough, so we produced a 50 frame sequence to use for our page curl.
Looks nice, right? Well, we can do better. How? We don’t need to use every frame! We certainly can’t expect visitors to this site to download all 50 frames, especially since there are 4 images total that will need to page flip. But how many frames should we use, and which ones?
Because the art director on this was picky, and because I have no interest in the publish->phone call->debate->repeat cycle, I decided to dump responsibility in his hands in the most explicit way possible: I wrote an app that would let him pick all the parameters for the animation.
What the application does is present every frame available to the animation in the left column. When an item in the list is selected, a preview loads in the top left frame.
The right column shows every frame currently being used in the animation. Users can drag frames from the left column to the right column and back, and a preview animation is updated and played in the top right frame. The speed of the animation can be adjusted by a multiplier of the frame rate of the anticipated swf using a numeric stepper below the animation.
Every frame is numbered and automatically sorted based on its index so that the user doesn’t accidentally produce something worthless.
As I write this I’m waiting to be told which frames to use and how long to display them. I’m not sure how long it will take to get a response, but I know in the time between now and then what I won’t be working on. :)
Try out the Animation Optimizer or Download the Project File
Wikileaks
Posted in Article on December 8th, 2010 by Ian Ford – Be the first to comment
This article sums up my opinions on this matter nicely, though I’d like to point out that we should be very careful not to trivialize the allegations made by the two women who claim that Julian Assange sexually assaulted them. The timing is certainly suspicious, but we should always take charges like this seriously.
Bugs and Quirks: Uninitialized Properties
Posted in Actionscript 3, Article, Best Practices, Tips on December 7th, 2010 by Ian Ford – Be the first to commentUntil you refer to the 3D properties of a DisplayObject, the matrix3D property of its transform object will return null.
The same is true of the DisplayObject’s transform property itself.
This seems, on the one hand to be silly, and on the other hand to be a source of potential bugs and confusion during development. Generally speaking I expect things like this to have a default value other than null or undefined.
Perhaps it’s meant to control memory usage? A noble cause, undoubtedly, but perhaps misguided in its application. You have to assume that people are going to misuse classes, but when they do hopefully the class either fails gracefully or adapts.
In the case of this issue, I would resolve it by rewriting the accessors for both properties like so:
public function get transform():Transform {
if (transform == null)
return new Transform();
return transform;
}
This way, the transform property isn’t instantiated until it’s needed, but at the same time when it’s requested there’s something there. Isn’t that nice?





