If the sounds are fairly simple videogame-ey sound effects, you might want to take a look at my
as3sfxr library. It can generate and play sound effects at runtime, and changing the frequency is just one variable change. Pick your sound in the
tool, then copy and paste it right into your code, done!
This should set you in the right direction.
1. Until Flash 11 the API for going between Sound and Bytearray was incomplete(could not construct a Sound on-the-fly). Shouldn't affect you, but one to know.
2. Flash achieves stereo sound by interleaving the two channels in a single stream. (byte 0 is left, byte 1 is right, etc.)
3. SampleDataEvent wants a certain minimum number of bytes in the buffer. You have to fill that many or more, or it's "unfinished."
Not quite right on 2 & 3.
2. It's actually alternating floats for each channel, which are 4 bytes each. So bytes 0-3 are the left channel, 4-7 are the right channel, 8-11 are left again and so on.
3. Its true that you need a minimum number of samples per event - 2048 samples in fact (1 sample is both floats for stereo channels, so 8 bytes per sample), but there's also a maximum: 8192 samples. The sweet spot however is
3072 samples, which gives you the best balance of short latency and fast execution. It's also worth noting that for any sound, the first number of samples you pass it must be matched every event, or the sound will be assumed to be over and will stop.