我有下面的代码加载一个声音,'test.mp3',然后降低它的音调,也放慢了它。声音播放的音调较低,但在采样结束时,我收到了以下错误:'RangeError:Error#2004:其中一个参数无效'。我做错了什么,我该如何解决这个问题?任何对此的帮助将非常感激。ActionScript 3 - RangeError:Error#2004 - 我在做什么错?
var sourceSound:Sound = new Sound();
var outputSound:Sound = new Sound();
var urlRequest:URLRequest=new URLRequest('test.mp3');
sourceSound.load(urlRequest);
sourceSound.addEventListener(Event.COMPLETE, soundLoaded);
function soundLoaded(event:Event):void {
outputSound.addEventListener(SampleDataEvent.SAMPLE_DATA, processSound);
outputSound.play();
}
function processSound(event:SampleDataEvent):void {
var bytes:ByteArray = new ByteArray();
sourceSound.extract(bytes, 4096);
var returnBytes:ByteArray = new ByteArray();
bytes.position=0;
while (bytes.bytesAvailable > 0) {
returnBytes.writeFloat(bytes.readFloat());
returnBytes.writeFloat(bytes.readFloat());
bytes.position -= 4;
returnBytes.writeFloat(bytes.readFloat());
}
event.data.writeBytes(returnBytes);
}
感谢您的回答!任何关于如何开始执行for循环的指针?正如你可以告诉的那样,我对ActionScript的经验不是很多...... – DLiKS 2011-04-03 20:31:25