2

UrlLoader.load()私はフラッシュアプ​​リで使用します。
そしてUncaughtErrorEvent.UNCAUGHT_ERROR、キャッチされない例外が発生したときにアプリを停止するように処理しています。

UrlLoader.load()インターネットに正常に接続している場合に動作します。
ただし、ブラウザがアプリをロードした後にインターネットへの接続が失われた 場合は、が呼び出されたSecurityErrorときに発生します。 使用して SecurityError をキャッチできず、UNCAUGHT_ERROR が発生してアプリが停止します。重要でない情報を記録するために使用しているだけなので、失敗した ときにアプリを停止したくありません。 また、読み込みに時間がかかる場合もタイムアウトエラーが発生する可能性があると思います。 また、タイムアウトエラーのためにアプリを停止したくありません。 どうすればこれらの問題を解決できますか?UrlLoader.load()

try catch

UrlLoader.load()UrlLoader.load()





また、発生してアプリを停止する可能性のある他の種類のエラーはありますか?

4

1 に答える 1

2

ある種のセキュリティ違反が発生すると、SecurityError例外がスローされます。

セキュリティエラーの例:

An unauthorized property access or method call is made across a security sandbox boundary.
An attempt was made to access a URL not permitted by the security sandbox.
A socket connection was attempted to an unauthorized port number, e.g. a port above 65535.
An attempt was made to access the user’s camera or microphone, and the request to access the device was denied by the user.

次に、任意の外部URLからswfをロードする必要があるとします。

    // URL of the external movie content
    var myRequest:URLRequest=new URLRequest("glow2.swf");

    // Create a new Loader to load the swf files
    var myLoader:Loader=new Loader();

    // 1st level IO_ERROR input and output error checking
    // Listen error events for the loading process
    myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);

    function ioError(event:ErrorEvent):void 
    {
      // Display error message to user in case of loading error.
         output_txt.text = "Sorry that there is an IO error during the loading of  an  
                            external movie. The error is:" + "\n" + event;
    }

    function checkComplete(evt:MouseEvent) 
    {
      // 2nd level SecurityError error checking
      // Use the try-catch block
      try
      {
         // Load the external movie into the Loader
         myLoader.load(myRequest);
      }
      catch (error:SecurityError) 
      {
         // catch the error here if any
         // Display error message to user in case of loading error.
            output_txt.text = "Sorry that there is a Security error during the 
                               loading of an external movie. The error is:" + "\n" +
                               error;
      }
    }

 movie1_btn.addEventListener(MouseEvent.CLICK, checkComplete);

 // Listen when the loading of movie (glow.swf) is completed
 myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadMovie1);

 function loadMovie1(myEvent:Event):void 
 {
     // Display the Loader on the MainTimeline when the loading is completed
     addChild(myLoader);
     // Set display location of the Loader
     myLoader.x = 200;
     myLoader.y = 80;
 }

これがあなたのために働くことを願っています。

于 2011-10-06T08:49:37.667 に答える