ActionScript was introduced with the release of Flash 4 back in 1999. In my never-ending naïveté I assumed it should be pretty mature by now. Almost a decade should be enough for that, shouldn't it? Obviously that isn't the case - otherwise there wouldn't anything to rant about. ;)
I started with ActionScript3 (Flash9+) a few weeks ago. It's supposed to be so much better than ActionScript2. There wasn't much of a reason to not use the latest version; given that about 90% of the users use the latest version of Flash. The remaining 10% quickly fade away if you consider things like the lifespan of small web games (a couple of years easily) and the time it takes to get things rolling for real. A quick look at AS2 was actually enough to discard it completely; it's ugly.
In the past I always wondered how they managed to get the Flash VM this small. Well, now I know. They only cover absolutely basic functionality, which wasn't much of a surprise to be honest. Given the limited scope of Flash applets this isn't really a problem. However, if you take a close look at those things they did implement, you'll be able to see what makes it this lightweight: half the functionality is missing.
Adobe recently added support for H.264 (a video format), (HE-)AAC (an audio format), and MP4/3GP/MOV/etc. (container formats) to their Flash runtime. (HE)-AAC is somewhat similar to Ogg Vorbis; at low bitrates the sound gets "washed out" without introducing those painful artifacts everyone knows from low-bitrate MP3s. Hi-hats in particular are as pleasant as a million rusty nails scratching across a blackboard. With better lossy psychoacoustic audio formats the sound only gets "thinner". For a more visual example compare JPG with wavelet-based formats such as JP2 (JPEG2000). At high compression rates JPG produces heavy block artifacts whereas JP2 only looses details, which is a lot more pleasant to the eye since no noise is added.
Since you don't get those artifacts with (HE-)AAC you can go really low with the bitrate. In my tests I could get as low as ~25kbits with HE-AAC (AAC SBR+PS). To put things into perspective: that's 73kb for a 22s background music loop. An MP3 loop with similar quality requires 64kbits if you convert it to mono or 96kbits if you use joint stereo (for "real" stereo i.e. 2 channel audio you should at least use 256kbits). That's 177kb (+142%) respective 265kb (+263%). While the MP3 sounds a bit "fuller", the AAC track is more pleasant to listen to.
This difference is huge - especially if you consider that you need a million downloads per month for a mere $1000 (the eCPM is typically at about 1$ with those popular ad-wrapper networks). Let's say you got three 22s tracks (or 1 minute and 6 seconds of audio) and you actually manage to get a million downloads. Then you'll have an overhead of 312kb per download (with 64kbits that is), which means you'll waste 312gb of traffic. Of course you'll also make your visitors wait longer than necessary.
As if all of that wouldn't be enough to despise MP3, there is yet another issue: MP3 isn't suitable for looping. By design the format adds leading and trailing silence. There are tools which are supposed to work around this, but they don't work very well.
One might be inclined to try to fix it with some code like this one (don't bother trying it - it doesn't work!):
[Embed(source = 'loop.mp3')]
private var musicClass:Class;
private var music:Sound = new musicClass();
private var soundChannel:SoundChannel=null;
public function Main():void {
[...]
var musicTimer:Timer = new Timer(1);
musicTimer.addEventListener(TimerEvent.TIMER, reloopMusic);
musicTimer.start();
}
private function reloopMusic(evt:TimerEvent):void {
if (soundChannel == null){
soundChannel = music.play(42);
return;
}
if (soundChannel.position >= music.length - 18){
soundChannel.stop();
soundChannel = music.play(42);
}
}42 is the length of the leading silence and 18 is the length of the trailing silence (both in msecs). Looks like it could work, right? Well, it doesn't work. There are two reasons why it doesn't work as expected:
If the Flash IDE is used you can add WAV files, enable MP3 compression, and then some magical voodoo fixes the loop problem for you. But that doesn't help much if you're using the SDK directly, does it?
Subjectively improved quality, smaller download sizes, and no looping issues. What could go possibly wrong with so much awesomeness at one spot? Well, the incomplete Flash API does.
Being able to use Sound would be really nice. Like Bitmap takes JPG, GIF, and PNG; Sound should take MP3, AAC, or whatever else they decide to add in the future. Blatantly obvious, isn't it?
This means you cannot load embedded videos - or what I'm trying in this case - embedded MP4s which only contain an HE-AAC audio stream.
[Embed(source = 'music/mp1.mp4', mimeType = "video/mp4")] //correct mime - doesn't work [Embed(source = 'music/mp1.mp4', mimeType = "application/octet-stream")] //gotta use this
Sound should of course be able to load audio streams from MP4 containers, Video would take an InputStream, there would be also utility streams like ByteArrayInputStream, and Embed would know about those containers and their mime types.
The functionality is there. Of course I want to use it. It's truly mind-boggling that Adobe failed to predict that. There are a lot of hobbyist APIs which are more feature complete than that. It's the sparkling new killer feature; expose it!
They also should have done something about that looping issue. E.g. optional auto trimming which defaults to on. Or even better yet a different audio format. If you look a bit around at various Flash forums you can find thousands of threads about this very topic. This single issue must have wasted massive amounts of time, energy, and money. I don't know how something like that could happen with a supposedly media centric solution like Flash. It can't get any more basic than audio loops, can it?
Needless to say that I'm very disappointed with Flash9. It should get at least the overly obvious things right.
Comments
Wrong analysis
This has nothing to do with actionscript3, this is related to what technologies the flash player offer you (its a proprietary software, u choose to support&develop for it, now accept it or move out), that they are exposed in as1/as2/as3 ... that's another plate on table.
The complaint about the mimeType ... so what, they missed that in FLEX API (not in as3), things like these do happen in development u know.
If you really want to make complaints ... the do it relating to how complex AS became with its 3rd iteration not with your shallow reasons.
re: Wrong analysis
>This has nothing to do with actionscript3 [...]
It's an API issue. The native stuff is there, they just "forgot" to wire it up.
>The complaint about the mimeType [...]
The addition of those container formats and codecs is their latest killer feature. It's only sensible to ensure that that stuff works. Having the mime types there wouldn't change anything though. It's just surprising that they didn't even took care of that.
>[...] how complex AS became [...]
It doesn't look all that complex to me. It's just incomplete.
AS3 is language
> > This has nothing to do with actionscript3
> It's an API issue.
But ActionScript is just a programming language, which could be bundled with different APIs. And that API could be exposed to different languages.
I know it's always popular to think of a language, a library, sometimes an implementation, and even sometimes an IDE, as one inseparable entity, but they are actually separable distinct concepts which can be discussed individually.
Really?
You pose one argument to support your claim that an entire language is "half baked"? How ridiculous is that? And of all things, its about AAC audio?
Seriously, come up with some good arguments and post those. If the language is truly half baked, like you claim, you shouldn't have any trouble coming up with some more examples.
re: AS3 is language
>But ActionScript is just a programming language[...]
Yes, I'm aware of the differences. However, in AS3's case everything is synonymous. The language, the platform, the API... none of that is interchangeable. Well, there are open source Flash players, but they can't do anything differently - or more accurately - they shouldn't do anything differently. You can also swap AS3 with haXe for example, but that won't change anything.
re: Really?
>You pose one argument to support your claim that an entire language is "half baked"?
I wrote so much about this single issue, because I wanted to outline the usual train of thought. Wanting to use HE-AAC for BGM loops is just logical, which in turn makes Adobe's oversight somewhat worse.
Another issue is i18n. They thought it would be a good idea to use the language of the operating system instead of the usual far more logical thing: the locale. Surprisingly Flash Light is supposed to get this right.
There are probably other fundamental flaws, but as I said I just recently started with Flash. Well, my motivation to rant about this was rather simple: this kind of shortsightedness annoys me to no end. Essential things should work and they should be also easy to do. Especially if these things are strongly linked to its raison d'être. Like a car should be able to move or food should be editable. It should fulfill its purpose. Well, I guess you can catch my drift.
Misguided
Maybe you should be congratulating the team for adding AAC/H.264 support instead? The API and Flash Player features were in sync when Flash CS3 was released but since then the FP team have been adding some great features in incremental releases of the FP9. It's much more disruptive to the thousands of Flash developers to change the API than to add in some new features every now and again to tinker with. They didn't forget to wire anything up - the API just doesn't support features of the FP that didn't exist at the time of release of Flash CS3. This is not a language issue (AS3), this is an issue with Flash's libraries/API.
I guess what you are saying is that you would prefer that Adobe rewrite all relevant libraries and update the API before any new feature is added to the Flash Player? I disagree - the features are useful, let's have them, and the API will be updated when Flash CS4 is released. Maybe you would be happier just pretending that those particular features don't exist?
re: Misguided
>Maybe you should be congratulating the team for adding AAC/H.264 support instead?
I already did that. And I also explored some new possibilities.
>I guess what you are saying is that you would prefer that Adobe rewrite all relevant
>libraries and update the API before any new feature is added to the Flash Player?
If they would have thought that through beforehand it wouldn't be necessary to change the API. You hand over some file and if the current runtime has a matching reader, everything will be fine. With Java for example it's just like that. E.g. if you write a simple audio player or image viewer it will be automatically capable of handling new file types as soon as they are added to the JRE.
Video in Flash is just like that. It doesn't care about mime types/file extensions. And video players which were written before 9.0 r115 (9,0,0,115) are capable of playing MP4, MOV or 3GP files right away - as long as they didn't check the file extensions.
Sound could also sniff the file type (by reading the header) and the embedding issue could have also been addressed beforehand (e.g. with streams). It's very simple stuff and it has been done a zillion times before. Adobe itself also did that stuff before. So, why didn't they do it in this case? Apparently it would have been a good idea.
Well said but ...
You present a single example and corectly some people say that the title is somewhat overkill.
You fail to point out how this situation is the norm in AS3..
... which by the way it is!
Come on people, everybody know that flash is broken.
It's hard to accept it when you make a living out from it and can't learn new tricks.
re: Well said but ...
Other "funny" things are the lack of a seedable PRNG and completely broken i18n capabilities. Flash doesn't use the locale (user-changeable language setting) instead it uses the language of the operating system (hardcoded).
Stuff like that makes me really angry. It's completely retarded and there are no excuses.
Post new comment