2011-05-17 70 views
0

我遇到了聲音問題。我正在動態加載它,url來自flashvars。 應用程序正在工作,但stil給出錯誤,未處理的ioError。但我已經處理了它。Actionscript 3聲音ioError問題

` VAR的聲音:聲音=新聲音()

try{ 
    sound.load(new URLRequest(req)); 
} catch(e:IOError){ 
    trace("catch ioerror"); 
} 
sound.addEventListener(IOErrorEvent.IO_ERROR, function(evt:IOErrorEvent):void { trace("error:",evt) });  

sound.addEventListener(Event.COMPLETE, function(e:Event):void{ 
    channel = sound.play(0,int.MAX_VALUE); 
});` 

回答

0

只是爲了排除這種可能性,嘗試註釋掉行channel = sound.play(0,int.MAX_VALUE);也許正是這種被拋出的錯誤,而不是負擔,而你沒有抓住這個。

+0

該行是循環。是否需要嘗試catch塊,如果加載,事件將觸發。你們試過了嗎? – atilkan 2011-05-20 08:56:31

0

嘗試在代碼方面具有更簡潔的方法,可能只是你的佈局,這樣的問題:

var request:URLRequest = new URLRequest(req); 
sound.load(request); 

sound.addEventListener(IOErrorEvent.IO_ERROR, _ioError); 
sound.addEventListener(Event.COMPLETE, _complete); 

function _ioError(e:IOErrorEvent):void 
{ 
    trace("File was not found"); 
    _removeListeners(); 
} 

function _complete(e:Event):void 
{ 
    channel = sound.play(0,int.MAX_VALUE); 
    _removeListeners(); 
} 

function _removeListeners():void 
{ 
    sound.removeEventListener(IOErrorEvent.IO_ERROR, _ioError); 
    sound.removeEventListener(Event.COMPLETE, _complete); 
} 
+0

確定我的代碼正在工作。對不起,我沒有在這裏複製粘貼。我創造了2次,這給了我錯誤。現在我明白了。謝謝 – atilkan 2011-05-20 09:01:51