2011-05-17 71 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