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.

