How would I go about playing a sound object in reverse in Actionscript 3?
For a project I'm working on, it's necessary that I am able to play a sound object in reverse. How would I be able to do this in 开发者_如何学GoAS3?
This is doable as of player 10, but it's not a quick/simple implementation. You'll have to build your own custom support. Lets take a look:
var soundSource:Sound; //assuming this actually references a real sound file such as a MP3
var position:int = soundSource.bytesTotal;
var numBytesToReadEachSample:int = 8192;
var snd:Sound = new Sound();
snd.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleData);
snd.play();
function sampleData(e:SampleDataEvent):void {
position -= numBytesToReadEachSample;
//here we read data from our source, and write it to the playing sound
e.data.writeBytes(soundSource.extract(position, numBytesToReadEachSample))
}
That's NOT TESTED AND INCOMPLETE, but is the general idea of what you want to do. Hopefully it points you into the right direction!
More information here: http://www.adobe.com/livedocs/flex/3/langref/flash/events/SampleDataEvent.html#SampleDataEvent%28%29
Best of luck!
精彩评论