URLLoaderThreadのエラー検出がうまくいかない
jsonLoaderThread = new URLLoaderThread( new URLRequest(jsonFile) ); jsonLoaderThread.start(); jsonLoaderThread.join(); next(jsonParse); error( IOError, jsonLoadError);
で、存在しないファイル(jsonFile)を読み込んだときに
[MainThread Thread1] Error: TypeError: Error #1034: 強制型変換に失敗しました。flash.errors::IOError@24b9281 を flash.events.Event に変換できません。
んー、
Sorry, this page is not availableとおなじようにやってるつもりなんだけどなー
追記
イベントで取得するようにしてみた
jsonLoaderThread = new URLLoaderThread( new URLRequest(jsonFile) ); jsonLoaderThread.start(); jsonLoaderThread.join(); next(jsonParse); event( jsonLoaderThread.loader, IOErrorEvent.IO_ERROR, jsonLoadError);
一応なんとかなってる
さらに追記
今書き直してみたらうまくいった。
id:yossy44の指摘通り、jsonLoadErrorの引数にEventを書いていたようで。
private function jsonLoadError( e:Error, t:Thread):void { //なんか処理 next(null); }
むむう。