8 things that annoy me about ActionScript3
- TextField.text can't be set to a number or object, only a String (unlike trace() for example, which will toString() anything you throw at it). There is no logical reason for this that I can see, and makes for some ugly code with String() casts everywhere. You can't really get around it by extending TextField either, if you want a designer to be able to manually move the textfield on the stage in Flash, which I always do.
- You can't tell if a key is down. I don't agree that this is a security threat, and it's a pain when you're doing games.
- No access to stage before addedToStage. I can't really see the reason why this is the case, and it can make code a lot more verbose, as you can't use stage in your constructors, leading to an extra layer of listeners and complexity. And it's worse if you're not actually extending DisplayObject. In my view, stage is a natural Singleton, and generally I treat it as such nowadays by keeping a static reference in one of my classes.
- Events and all those string constants. I always thought there was something fishy about ActionScript events (like how many custom ones you need), and the brilliant example set by Robert Penner's Signals has proved it to me. I've been using Signals on my latest project and filing bug reports (and the odd fix), which Rob pretty much always implements within a day. This is an awesome open source project that gets better by the day - you will never want to use Events again!
- You can't tell if the mouse is hidden. Why have a Mouse.hide() without Mouse.isHidden? It makes no sense, and if you call Mouse.hide() repeatedly it makes the cursor flicker, which again I can't understand as Flash should know not to hide it if it's already hidden. I have created a simple MouseManager class to get round this, but again, why should I have to. Also, I think there is a potential issue around right-clicking showing a hidden mouse without notifying you. While we're on the subject of the mouse, for games you really want to be able to set the cursor position, as you can I think in Unity3D, and have a truly custom right-click, as you can in Silverlight 4.
- The video API is just wrong. Do you know your netstream from your netconnection? None of these things make sense. It should just be videoPlayer.play("video.flv") right?
- The timeline can't destroy movieclips, only remove them from the stage, and if they have any listeners they can't be garbage collected, so playing timelines is a memory leak minefield.
- There are no convenience functions for anything, anywhere. Thanks guys.