我知道这不可能那么难,只是不确定为什么它不会开火。
我有一个“home”按钮,我想在加载时禁用,因为默认情况下会加载“home”内容。
继承我的代码:
import flash.events.Event;
// BUTTON FUNCTIONS FOR SP.
// by SOMDOW
/////////////// VARS ///////////////
var loader:Loader = new Loader();
var defUrlReq = new URLRequest("indexCoontentLoad.swf");
var urlRequest:URLRequest = new URLRequest();
var myLoadedSwf:MovieClip = null;
var swfStage:Stage = this.stage;
/////////////// INITIATE LOADERS ///////////////
loader.load(defUrlReq);
/////////////// START MAIN HANDLER FUNCTION ///////////////
/////IMPORT DEFAULT SWF /////
loader.contentLoaderInfo.addEventListener(Event.INIT, loadedHandler);
function loadedHandler(event:Event){
myLoadedSwf = event.target.content;
addChild(myLoadedSwf);
trace(myLoadedSwf);
myLoadedSwf.gotoAndPlay("intro");
}
//----- END IMPORT DEF SWF -----
///// HOME BUTTON TURNED OFF ON LOAD /////
indexCoontentLoad.addEventListener(Event.INIT, offOnLoad);
function offOnLoad(e:Event):void{
if(myLoadedSwf.currentFrameLabel == "outro"){
indexCoontentLoad.mouseEnabled = false;
trace("lopan");
indexCoontentLoad.removeEventListener(Event.ENTER_FRAME, offOnLoad);
}
}
//----- END IMPORT. -----
///// START LISTENERS AND THEIR FUNCTIONS /////
load1.addEventListener(MouseEvent.CLICK,btn4Loaded);
load2.addEventListener(MouseEvent.CLICK,btn4Loaded);
load3.addEventListener(MouseEvent.CLICK,btn4Loaded);
indexCoontentLoad.addEventListener(MouseEvent.CLICK,btn4Loaded);
//----- END LISTENERS -----
///// test /////
//indexCoontentLoad.addEventListener(Event.ENTER_FRAME,offOnLoad);
/*function btn4Loaded(e:Event):void { //-- START btn4Loaded
if (myLoadedSwf.currentLabel == "outro") {
myLoadedSwf.gotoAndPlay("outro");
trace("STEP 2 -- swf outro playing");
}
*/
//----- test end
///// START BTN FUNCTIONS /////
function btn4Loaded(e:Event):void {
if (e.target == load1 || e.target == load2 || e.target == load3 || e.target == indexCoontentLoad) {
myLoadedSwf.gotoAndPlay("outro");
removeChild(myLoadedSwf);
urlRequest = new URLRequest(e.target.name+".swf");
loader.load(urlRequest);
addChild(myLoadedSwf);
}
if(e.target == load1){
load1.mouseEnabled = false;
load2.mouseEnabled = true;
load3.mouseEnabled = true;
indexCoontentLoad.mouseEnabled = true;
}
if(e.target == load2){
load2.mouseEnabled = false;
load3.mouseEnabled = true;
load1.mouseEnabled = true;
indexCoontentLoad.mouseEnabled = true;
}
if(e.target == load3){
load3.mouseEnabled = false;
load2.mouseEnabled = true;
load1.mouseEnabled = true;
indexCoontentLoad.mouseEnabled = true;
}
if(e.target == indexCoontentLoad){
load3.mouseEnabled = true;
load2.mouseEnabled = true;
load1.mouseEnabled = true;
indexCoontentLoad.mouseEnabled = false;
}
}
//----- END BTN FUNCTIONS
以上这些都没有做任何事情。 “indexCoontentLoad”是一个按钮。
我也尝试过类似的事情:
function indexCoontentLoad(e:Event = null){
//code here
}
然后通过indexCoontentLoad();
调用它但又一无所获。
任何帮助表示赞赏。提前谢谢你。
答案 0 :(得分:0)
首先,您要添加INIT事件并删除ENTER_FRAME事件。这没有逻辑。也许你有没有提供给我们的代码。
我会使用Loader来管理加载并等待COMPLETE事件。然后我会使用。
激活按钮private function loadContent() : void
{
// add listeners and load external SWF
}
private function onLoadContentComplete(event : Event) : void
{
// remove listeners
// setup/activate button here
}