ActionScript3.0 の Socket を使ってみたとき、接続に失敗したときの処理が分からなかったんだけど、やっと分かった。

try catch でやるのかなーと思ってたけど、どうやら違ってイベントをとらえるらしい。

socket.addEventListener( SecurityErrorEvent.SECURITY_ERROR, onSecurtyError );
socket.addEventListener( IOErrorEvent.IO_ERROR, onIOError );

↑こんな感じで。

◇サンプルソース
client_air.as

いままでサーバがないと不快なエラーメッセージがポップアップされていたけど、テキストで表示されるようになってスッキリした。

いやえがったえがったー。

client_air.air.zip

関連エントリー:

Socket + AIR + ActionScript 3.0

AS3 + Socket + セキュリティエラー

ActionScript 3.0 + ポップアップ2

ActionScript 3.0 + DataGrid もろもろ

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt=""> <pre lang="" line="" escaped="" highlight="">