While putting some final polish on my latest flash game, something utterly bizarre happened. I usually save putting in sounds for the last job, but due to re-used interface code the menu sounds (on rollover) for this game were already in place. While sorting through my somewhat pathetic sound library (around $15’s worth off of SoundRangers) on my laptop, I came to the sad realization that Windows Media Player was the only software on it that would play mp3s. I loaded up my library and listened to everything a few times to try to sort out which sounds would go where. Once done, I closed WMP and switched back over to NetBeans. I dropped in the code for a few new sound effects to test, compiled, and loaded the SWF. Nothing. Nada. No sound. Not even the menu sounds, which I KNEW were already working.
After doing some debugging to make sure my sound listeners were actually getting the proper events and firing off the sounds, I was pretty perplexed. A bunch of google searches with queries like “as3 sound won’t play”, “as3 sound broken”, etc… yielded nothing interesting–the code was correct! Then it hit me. Every so often when I play a video or sound file in Windows Media Player, close the application, and then try to delete the video–I’ll get an error saying the file is still in use. There seems to be some sort of bug in WMP–it doesn’t always release assets properly, even when you completely close the application.
The odd thing is that the flex compiler didn’t throw any kind of warning that the assets it was trying to embed weren’t available. They just never played. After deleting the files from my assets directory, copying them back in from my sound library, and recompiling (with no code changes), everything worked like a charm. No matter how much I love my X-Box, Mac and Linux just keep getting more and more tempting…
