0

我刚刚实现了您发送的最后一段代码 - 非常感谢!这是此框架的完整上下文,以及其他按钮的完整代码,以防导致问题。我用这段代码得到的 19 个错误是:

1120:访问未定义的属性 fl_ProLoader_01

 stop();

 //home button

 mythbutt_home.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_01_1,false,0,true);

 function fl_ClickToLoadUnloadSWF_01_1(event:MouseEvent):void
 {
     removeChild(fl_ProLoader_01);
     fl_ProLoader_01.unloadAndStop();
     fl_ProLoader_01 = null;
 }

 mythbutt_home.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_01_1,false,0,true);

 function fl_ClickToGoToAndStopAtFrame_01_1(event:MouseEvent):void
 {
    removeChild(fl_ProLoader_01);

 }

 mythbutt_home.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds_01_1,false,0,true);

 function fl_ClickToStopAllSounds_01_1(event:MouseEvent):void
 {
    SoundMixer.stopAll();
 }

 mythbutt_home.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_01_2,false,0,true);

 function fl_ClickToGoToAndStopAtFrame_01_2(event:MouseEvent):void
 {
    gotoAndStop(1);
 }

 //other buttons at the bottom

 mythbutt_aboriginal_culture.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_01_1);

 function fl_ClickToGoToWebPage_01_1(event:MouseEvent):void
 {
    navigateToURL(new URLRequest("http://www.bigmyth.com/fullversion/password033/download/ABORIGINAL_CULTURE.pdf"), "_blank");
 }

 mythbutt_aboriginal_pantheon.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_01_2);

 function fl_ClickToGoToWebPage_01_2(event:MouseEvent):void
 {
    navigateToURL(new URLRequest("http://www.bigmyth.com/fullversion/password033/download/ABORIGINAL_PANTHEON.pdf"), "_blank");
 }

 mythbutt_aboriginal_exercises.addEventListener( MouseEvent.CLICK, fl_ClickToGoToWebPage_01_3);

 function fl_ClickToGoToWebPage_01_3(event:MouseEvent):void
 {
    navigateToURL(new URLRequest( "http://www.bigmyth.com/fullversion/password033/download/ABORIGINAL_EXERCISES.pdf"), "_blank");
 }

 //start button

 //Change your event handler function.
 start_button_aboriginal.addEventListener(MouseEvent.CLICK,fl_ClickToLoadSWF_01_2);

 function fl_ClickToLoadSWF_01_2(event:MouseEvent):void {
     fl_ProLoader_01=new ProLoader  ;
     fl_ProLoader_01.load(new URLRequest("myths/myth_aboriginal.swf"));
     fl_ProLoader_01.contentLoaderInfo.addEventListener(Event.COMPLETE, 

         //Using closure callback instead of *onComplete_1* function
         function( e : Event ) { 
                e.currentTarget.content.addEventListener( Event.ENTER_FRAME, OEF_01);
         });
     addChild(fl_ProLoader_01);
     fl_ProLoader_01.x=323;
     fl_ProLoader_01.y=41;

 //Swap the event handlers,no need for flag,clear code blocks
     start_button_aboriginal.removeEventListener(MouseEvent.CLICK,fl_ClickToLoadSWF_01_2);
     start_button_aboriginal.addEventListener(MouseEvent.CLICK,fl_ClickToUnLoadSWF_01_2);
 }

 function fl_ClickToUnLoadSWF_01_2(event:MouseEvent):void {
     fl_ProLoader_01.removeEventListener(Event.ENTER_FRAME,OEF_01);

     removeChild(fl_ProLoader_01);
     fl_ProLoader_01.unloadAndStop();
     fl_ProLoader_01=null;

     start_button_aboriginal.removeEventListener(MouseEvent.CLICK,fl_ClickToUnLoadSWF_01_2);
 }

 function OEF_01(e:Event):void {
      if (e.currentTarget.currentFrame==e.currentTarget.totalFrames) {
           e.currentTarget.stop();
           fl_ClickToUnLoadSWF_01_2(null);
      }
 }
4

1 回答 1

2

我认为@GarryWong 是对的。如果您在加载外部 swf之后且在其时间线完成之前单击开始按钮,您将收到错误消息。

我已经改变了你的实现,请试试这个。无需检查空对象。

更新


//Change your event handler function.
startbutton.addEventListener(MouseEvent.CLICK,fl_ClickToLoadSWF_1_2);

function fl_ClickToLoadSWF_1_2(event:MouseEvent):void {
    fl_ProLoader_1=new ProLoader();
    fl_ProLoader_1.load(new URLRequest("myths/myth_aboriginal.swf"));
    fl_ProLoader_1.contentLoaderInfo.addEventListener(Event.COMPLETE, 
                                                      //Using closure callback instead of *onComplete_1* function
                                                      function( e : Event ) {
                                                          e.currentTarget.content.addEventListener(Event.ENTER_FRAME, OEF_1);
                                                          });
    addChild(fl_ProLoader_1);
    fl_ProLoader_1.x=207;
    fl_ProLoader_1.y=41;

    //Swap the event handlers,no need for flag,clear code blocks
    startbutton.removeEventListener(MouseEvent.CLICK,fl_ClickToLoadSWF_1_2);
    startbutton.addEventListener(MouseEvent.CLICK,fl_ClickToUnLoadSWF_1_2);
}

function fl_ClickToUnLoadSWF_1_2(event:MouseEvent):void {
    fl_ProLoader_1.removeEventListener(Event.ENTER_FRAME,OEF_1);

    removeChild(fl_ProLoader_1);
    fl_ProLoader_1.unloadAndStop();
    fl_ProLoader_1=null;

    startbutton.removeEventListener(MouseEvent.CLICK,fl_ClickToUnLoadSWF_1_2);
    //Use the below line only if you want to repeat the procedure of loading the *Proloader*, otherwise omit it.
    startbutton.addEventListener(MouseEvent.CLICK,fl_ClickToLoadSWF_1_2);
}

function OEF_1(e:Event):void {
    if (e.currentTarget.currentFrame==e.currentTarget.totalFrames) {
        e.currentTarget.stop();
        fl_ClickToUnLoadSWF_1_2(null);
    }
}

抱歉,我现在还没有在我的电脑上安装 Flash,所以我的代码中可能会有一些错误。 你让我启动了我的 Windows 分区!

于 2013-06-06T14:37:11.983 回答