다음 tryscript 3 코드에서 try-catch 블록을 사용하고 있습니다.try-catch가 작동하지 않습니까?
try {
this._subtitle = new SubtitleController(subtitlePath, _framerate);
this._subtitle.addEventListener(Event.COMPLETE, subtitleLoaded);
}
catch (e:Error) {
trace('subtitle not found');
}
SubtitleController
생성자는 subtitlePath
을로드하려고 시도하고 Error #2044: Unhandled ioError
을 throw하지만 try
문은 오류를 포착하지 않습니다. 오류는 단순히 try
문이 존재하지 않는 것처럼 던져집니다.
물론, 그 코드를
this._subtitle.addEventListener(IOErrorEvent.IO_ERROR, function (ev:Event) { trace('subtitle not loaded'); });
this._subtitle = new SubtitleController(subtitlePath, _framerate);
this._subtitle.addEventListener(Event.COMPLETE, subtitleLoaded);
로 대체 할 수 있습니다. 거의 작동하지만 그 오류를 멈추지 않고 대신 다른 것을 던집니다.
그러나 try-catch
블록의 전체 지점이 그렇게하지 못합니까? try-catch
에서 작동하지 않는 이유는 무엇입니까?하지만 일반 이벤트 수신기에서 작동합니까?
adobe가 만드는 액션 스크립트 라이브러리는 정말 못 생기고, 여러 가지 유형의 '이벤트 처리기'패턴과 예외가 매우 복잡해 보입니다. 예외/오류는 이벤트와 대개 원래의 호출에서 자주 방송되는 것처럼 보입니다. . – meandmycode