我有下面的代碼加載一個聲音,'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