Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3-嵌套SWF按钮问题_Actionscript 3_Flash_Actionscript_Flash Builder_Flash Cs6 - Fatal编程技术网

Actionscript 3 AS3-嵌套SWF按钮问题

Actionscript 3 AS3-嵌套SWF按钮问题,actionscript-3,flash,actionscript,flash-builder,flash-cs6,Actionscript 3,Flash,Actionscript,Flash Builder,Flash Cs6,所以我有一个主SWF作为主菜单,可以启动其他SWF,它启动的很好,但是当其他应用程序运行时,你仍然可以单击主菜单上的按钮 function startLoad(e:MouseEvent){ var mLoader:Loader = new Loader(); var mRequest:URLRequest; if (e.target == btnOne){ mRequest = new URLRequest("appOne.swf"); }

所以我有一个主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);
}

我可以禁用主菜单按钮,但到目前为止,我还没有找到一种方法来触发主菜单以重新启用它们。

当事件到达startLoad方法时,禁用从e.target获得的按钮将改善代码的行为。然后,区分每个swf的onCompleteHandler方法将使您有机会重新启用相应的按钮

因为我对button类一无所知,所以我称之为YourButtonClass,我将编写disable();并启用();在下面的示例中,用于禁用和启用按钮的方法。请用适当的正确类名方法或属性设置替换它们。此外,检查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错误事件。这两个错误事件都可以由每个按钮/文件的单个处理程序方法处理

您想什么时候重新启用它们?如果您想禁用和启用这两个按钮,您可以在startLoad功能中禁用这两个按钮,并可以实现一个单一的onComplete侦听器,将这两个按钮都启用。