0

そのため、他の SWF を起動するメイン メニューとしてメイン SWF があり、正常に起動しますが、他のアプリが実行されている場合でも、メイン メニューにあったボタンをクリックすることができます...

function startLoad(e:MouseEvent){
    var mLoader:Loader = new Loader();
    var mRequest:URLRequest;

    if (e.target == btnOne){
        mRequest = new URLRequest("appOne.swf");
    }
    else if (e.target == btnTwo){
        mRequest = new URLRequest("appTwo.swf");
    }

    mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
    mLoader.load(mRequest);
}

メインメニューボタンを無効にすることができ、それは機能しますが、これまでのところ、メインメニューをトリガーして再度有効にする方法が見つかりません.

4

1 に答える 1

1

イベントが startLoad メソッドに到着したときに e.target から取得したボタンを無効にすると、コードの動作が改善されます。次に、swf ごとに onCompleteHandler メソッドを区別すると、対応するボタンを再び有効にする機会が得られます。

私はあなたのボタン クラスについて何も知らないので、それを YourButtonClass と呼びます。disable(); と書きます。および enable(); 以下の例では、ボタンのメソッドを無効化および有効化しています。それらを適切な正しいクラス名メソッドまたはプロパティ設定に置き換えてください。また、e.target クラスとボタンをチェックすることで、不必要な悲劇を回避できます。

function startLoad(e:MouseEvent){
var mLoader:Loader;      // we havent seen the river, lets not inflate our boat.
var mRequest:URLRequest;

if(!(e.target is YourButtonClass)) return;            // no nightmares..
if((e.target != btnOne)&&(e.target != btnTwo))return; // no nightmares..
YourButtonClass(e.target).disable();                  // disable the button here
mLoader = new Loader(); // river! inflate the boat :)
if (e.target == btnOne){
    mRequest = new URLRequest("appOne.swf");
    mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteAppOne);
}
else { // we are sure it is btnTwo if not btnOne now...
    mRequest = new URLRequest("appTwo.swf");
    mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteAppTwo);
}    
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}

// this method is for enabling btnOne
protected function onCompleteAppOne(Event: e){ 
    btnOne.enable();
    commonCompleteOperations(e);// if you have other operations post processing
}

// this method is for enabling btnTwo
protected function onCompleteAppTwo(Event: e){ 
    btnTwo.enable();
    commonCompleteOperations(e);// if you have other operations post processing
}   

// this method is for on complete common operations if you have.
protected function commonCompleteOperations(Event e){
    // do some processing here, for instance remove event listener check for
    // application domain etc...
}

念のため、セキュリティ エラー イベントと io エラー イベントをリッスンします。どちらのエラー イベントも、ボタン/ファイルごとに 1 つのハンドラ メソッドで処理できます。

于 2013-02-21T22:17:26.780 に答える