Update: Duh. Juan reminded me of the mx:SoundEffect class which can be used just like all of the other effects. You can use the [Bindable] and [Embed] tags and you can use mx:SoundEffect inside the mx:Parallel and mx:Sequence tags as a way to incorporate it into other effects:
1 2 3 4 5 6 7 8 | [Bindable] [Embed(source="assets/click_sound.mp3")] public var sound : Class; <mx:Parallel id="seq"> <mx:Fade alphaFrom="1" alphaTo="0" duration="500" /> <mx:SoundEffect source="{sound}" /> </mx:Parallel> |
As a Flex developer I spend a lot of time thinking about my UIs and how the components are going to fit and look together. But after watching Lee’s demos on the tour, I realized there is an important element that I don’t use in my Flex applications. In fact a lot of the Flex applications I use on a regular basis don’t seem to incorporate the element either: sound.
The sounds Lee uses add a lot of polish to his applications and demos. He’s got little sounds for rollover buttons, a nice, small sound effect inside of his “Spit Em Out” application, and a couple of others. Sounds add to both the usability and immersion of an application. Combining visual and audio queues when a user does something can help usability and even appeal more broadly to your users (not everyone is a visual person). I think in the Flash world sounds are very appropriately used but in Flex applications, because sound isn’t really baked into the framework at all (unlike, say, rollover effects) we don’t have them. So I encourage you to check out the Sound classes. Adding sound is really, really easy:
1 2 3 4 5 6 7 8 9 10 | <mx:Script> <![CDATA[ public function onClick(event:Event) : void { var sound : Sound = new Sound(new URLRequest('assets/click_sound.mp3')); sound.play(); } ]]> </mx:Script> <mx:Button id="btn" width="100" height="30" click="onClick(event);" /> |
Look! Code on my blog….sort of. I created a very stupid simple project and put it on SVN with the source code above. It’s not really worth looking at but I may expand it later as I get into the sound classes more.
As you explore the sound classes more you’ll see that you can attach events to your sounds for handling the ID3 tags, get progress events, and errors. In Flash Player 10 we’re doing a lot more to let you manipulate sounds directly inside of the Flash Player.
Finding Sounds
The hardest part for me was figuring out where I could get sounds to add to my applications. Luckily, Lee knew so he gave me a few resources that should get you started:
- Flash Kit Sounds – Great free sound resource
- Soundrangers – Royalty free sounds you can buy
- FindSounds – A pretty good sound search engine
If you know of any more, let me know in the comments. If you’re interested in mixing, converting, or adjusting sounds, you can check out the CS4 beta of Soundbooth. I’m grabbing it as we speak because I think it would be cool to have a library of nature sound effects to use in my apps.
Tweet
I’ve been impressed by the number of “Top” lists that are starting to include AIR. It turns out a lot of people are finding some cool apps in different categories to write about. Lifehacker is probably one of the most prominent of the “tops” and one of the best blogs out there so it’s really cool to see they’ve compiled a list of the
I’m not a huge user of 