I've encountered a very strange and annoying bug of sorts, unlike anything I've ever seen in Flash. This might take a while to explain - so don't feel obligated to read the entire post before responding! ;)
Up until recently, I could use Test Movie, and my game would run and load just fine every time.
Then I finally added music, and chaos ensued. The gist is that the game can't seem to load more than a certain number of bytes worth of sounds, and makes the preloader halt (or worse). However, this "certain number" changes every time I do Test Movie. If I use around 2.5 or 3 megabytes of sound, doing Test Movie will result in one of the four scenarios:
1) The movie fails to load the first frame - it shows the background color and nothing more, and the right-click menu has most of the options missing (zoom in, play, rewind, etc.) , and the rest (all 2 of them) are grayed out. Re-opening the generated swf will result in nothing happening (not even another blank window).
2) Preloader stops at some seemingly random number between 0 and 100. If I re-open the generated swf, the preloader will again stop at the EXACT SAME number. I added a button to skip past the preloader even if it's not done loading - but when the movie gets to/past the point in the timeline where the sounds are, the movie stops and can't go on.
3) The game loads to 100% and works perfectly fine.
4) This scenario is rare, but: the game works alright, but a few of the vector graphics are royally messed up, and/or some of the mp3s have weird garbled parts.
The more sound data there is, the greater chance there is of it messing up. Anything more than around 3 megs will be almost certain to fail, while 2.5 megs fails only some of the time, and under 1 or 2 megs works fine pretty much every time.
Here are some things I've done to try to fix it:
- Compressing mp3s inside Flash (useful, but no dice - and I have to wait for the music to compress every time I hit Test Movie).
- NOT compressing the sound (exact same problem, only the mp3s are much bigger).
- Using mp3s from a reputable website, instead of ones I encoded myself (still no difference).
- Using "export in first frame" to load the mp3s in the first frame - this just makes it so instead of halting the preloader (scenario 2), it halts before the first frame loads (scenario 1).
- Instead of using music in actionscript, including it only in the timeline or in a movieclip - guess what? Doesn't work.
One thing that I haven't yet tried is STREAMING the music. However, I'm not sure if that's a good idea. The game usually runs at a steady 15 fps, but dips quite a bit below during certain intense moments - would streaming music make it skip frames instead of causing a temporary slow-down? Because that would be bad for various reasons...
Another thing I haven't tried is seeing if 4 megabytes worth of images will cause this same problem. Worth testing I think, I'll get back about this tomorrow.
One thing that I THINK I noticed (maybe I'm just crazy, or maybe it's just a coincidence) is that using different bitrates (kbps) for different mp3s yields a greater chance of failure than using the same bitrate for all mp3s.
Right now, it's looking like these are my options:
a) Take the blue pill and stay in wonderland - compress my mp3s to abysmal quality, or simply use less songs in my game. I'll be pretty sad if I have to do this...
b) Take the red pill and learn about this bizarre behaviour - has anyone ever encountered anything like this before, or have ANY IDEAS AT ALL about what might be causing it, or how to fix it? I would greatly appreciate any help or feedback, even if it's just a hunch or idea =D
c) Use streaming music (light blue pill?)
I'm using Macromedia Flash 8 (actionscript 2), and my mp3 wishlist is around 4-6 megabytes (depending on how much I decide to compress them).
On a related note... will a 6 meg swf cause unreasonable loading times? Maybe I need to reconsider the quantity of music the game needs...?
Thanks for reading, please give some input if you can! =)