2009-08-07 6 views

答えて

1

私はそこにあるとは思わないが、とにかく閉鎖を強制することができると思う。

これはどれくらいシンプルなのか完全にはっきりしていませんが、ここで私の最高の推測となります。あなたのLocalConnectionのインスタンスを作成する際、クライアントに(またはAS2でプロパティとして)これを必ず含めてください:

function close() 
{ 
    myConnection.close(); 
} 

それに加えて、接続が接続持ってしようとしているときに、私はこれが含まれます:

var commName:String = "MY_CONNECTION"; 
var myConnection:LocalConnection = new LocalConnection(); 

// Try to tell any open LocalConnection on this channel to close. 
// This may cause an AsyncErrorEvent, so be sure to add the appropriate 
// Error handling. 
myConnection.send(commName, "close"); 

try 
{ 
    myConnection.connect(commName); 
} 
catch(error:Error) 
{ 

    // If there is another connection already open on the same channel, 
    // that will cause an Error. I have had some luck catching that 
    // Error and then calling connect again. That said, you would be 
    // best to take precautions anyway. 
    try 
    { 
     myConnection.connect(commName); 
    } 
    catch(error:Error) 
    { 
     // Your connection cannot connect!!! 
     // DO SOMETHING!!! 
    } 
} 
myConnection.client = this; 
+0

これはうまく見えます。私は接続名を一意にする必要があることを理解しているので、接続を明示的に閉じることに興味があります。ページがリロードされた場合、接続が浮動して問題を引き起こしたくないです。 – Irwin

0

JavaScriptのアンロードイベントに反応し、ExternalInterfaceを通じてフレックスアプリでクリーンアップ機能を呼び出すことができます。しかし、ExternalInterfaceで多くの作業をしていないので、私は本当によく分かりません。

関連する問題