Skip to main content
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.
Comments
I personally like the separation of video into netstream, netconnection etc. The thing is that a netstream is for any streaming media, not just for video. A netconnection is useful for sockets or data transfer. If you want to have basic video, then there's always the VideoPlayer class.
I do think that Flash has lost its focus on games and is trying to be all things to all people, which is great in many ways, but makes for a more sprawling, irritant prone language. However, I think Adobe get less credit than they deserve for listening to developers and fixing stuff. 10.1 promises to be a great release...
I'm not sure Flash ever had a focus as a games development platform to lose - it's been pushed, punched and tweaked in that direction by content creators who have adapted to its timeline / animation working model.
When it comes to video - Silverlight walks all over it in terms of ease of deployment, which is only *slightly* frustrating ;)
And you can detect if a key is down, just not natively, Check here
2. Make a little helper class its soooo easy
3. You got the logical solution youself
4. You are right on that one
5. I never used that.
6. See Point 5
7. Do you understand garbage collection? Makes perfect sense that objects that have listners dont get collected. You might use weak references.
8. LOL
@Chris the key detection thing is something I have been working in my new open source project - details soon.
@Lionga - function set text(_text:Object) would have worked just as well for the textfield API and saved us a bit the of work. Overloaded functions would be even better.
I absolutely understand garbage collection, my point was that Flash does some things automatically when the playhead moves that can be dangerous, whereas this was a problem in AVM1. It's probably the reason so many developers completely shun the timeline.
I agree with most of it
Another thing that annoys me personally is that you can't make private constructors. (I can't make a simple singleton class like I would want to) It's not that I suffer from it or anything, it just reminds me that actionscript could be a more 'mature' language than what it is now.
More details here: http://board.flashkit.com/board/showpost.php?p=4198441&postcount=18 )
CasalibDocs
By the way, did you know that code in a constructor can be slower than other code? For whatever reason, it isn't JITed by the runtime, so it's actually better to move initialization code out of the constructor, even if you're just calling another function from the constructor. Weird, but true.