错误#2007:参数child必须为非null

时间:2013-08-16 10:14:34

标签: iphone ios actionscript-3 flash air

今天只有错误!得到这方面的帮助真是太好了。

我正在为AIR应用调用外部子swfs;超级简单 - 用按钮调用它们,然后用“主页”按钮将它们删除,就是这样。但是我得到了这些错误,我无法发布,即使是测试,也不会崩溃整个系统。请帮忙!几个星期以来,我一直坚持这一点!

这是错误:

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at pocketDinos_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame_20_1()  
[pocketDinos_fla.MainTimeline::frame162:18]
Test Movie terminated.

这就是我假设在主时间轴上引起问题的原因(这是主时间轴上的所有代码):

 stop();

//home button

button_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;
}

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

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

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

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

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

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

//back to time period button

back_to_triassic.addEventListener(MouseEvent.CLICK,    
fl_ClickToLoadUnloadSWF_01_2,false,0,true);

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

back_to_triassic.addEventListener(MouseEvent.CLICK,   
fl_ClickToGoToAndStopAtFrame_01_3,false,0,true);

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

}
back_to_triassic.addEventListener(MouseEvent.CLICK,    
fl_ClickToStopAllSounds_01_2,false,0,true);

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

back_to_triassic.addEventListener(MouseEvent.CLICK,    
fl_ClickToGoToAndStopAtFrame_01_4,false,0,true);

function fl_ClickToGoToAndStopAtFrame_01_4(event:MouseEvent):void
{
gotoAndStop("TRI_home");
}


//start button

start_button_TRI_coelophysis.addEventListener(MouseEvent.CLICK,   
fl_ClickToLoadUnloadSWF_01_3,false,0,true);

import fl.display.ProLoader;
import flash.events.Event;

var fl_ProLoader_01:ProLoader;

function fl_ClickToLoadUnloadSWF_01_3(event:MouseEvent):void
{
if(fl_ToLoad_01)
{
    fl_ProLoader_01 = new ProLoader();
    fl_ProLoader_01.load(new URLRequest("dinofilms/triassic_coelophysis.swf"));

fl_ProLoader_01.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete_01)
    addChild(fl_ProLoader_01);
    fl_ProLoader_01.x = 0;
    fl_ProLoader_01.y = 144;
}
else
{
    if(fl_ProLoader_01!=null) {
        removeChild(fl_ProLoader_01);
        fl_ProLoader_01.unloadAndStop();
        fl_ProLoader_01 = null;
    }
}
fl_ToLoad_01 = !fl_ToLoad_01;

}

function onComplete_01(e:Event):void {
e.currentTarget.content.addEventListener(Event.ENTER_FRAME,OEF_01);
}

function OEF_01(e:Event):void {
if(e.currentTarget.currentFrame==e.currentTarget.totalFrames) {
    e.currentTarget.stop();
    e.currentTarget.removeEventListener(Event.ENTER_FRAME,OEF_01);

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

2 个答案:

答案 0 :(得分:0)

在您function fl_ClickToGoToAndStopAtFrame_01_1 removeChild(fl_ProLoader_01);中说出function fl_ClickToLoadUnloadSWF_01_1,但您也可以在{{1}}中将其称为{{1}}。这两个函数都分配给同一个MovieClip / Button,因此它会在第18行给出一个错误,它会在同一个MovieClip / Button上再次调用removeChild。

答案 1 :(得分:0)

我认为它已经解决了!

stop();

//home button

button_home.addEventListener(MouseEvent.CLICK,     
fl_ClickToGoToAndStopAtFrame_01_1,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_1(event:MouseEvent):void
{
if(fl_ProLoader_01 && fl_ProLoader_01.stage){ 
 fl_ProLoader_01.parent.removeChild(fl_ProLoader_01);}
 gotoAndStop("home");
 }


button_home.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds_01_1,false,0,true);
function fl_ClickToStopAllSounds_01_1(event:MouseEvent):void
{
SoundMixer.stopAll();
}



//back to time period button


back_to_triassic.addEventListener(MouseEvent.CLICK,     
fl_ClickToGoToAndStopAtFrame_01_3,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_3(event:MouseEvent):void
{
if(fl_ProLoader_01 && fl_ProLoader_01.stage){ 
 fl_ProLoader_01.parent.removeChild(fl_ProLoader_01);}
 gotoAndStop("TRI_home");
 }

back_to_triassic.addEventListener(MouseEvent.CLICK,     
fl_ClickToStopAllSounds_01_2,false,0,true);
function fl_ClickToStopAllSounds_01_2(event:MouseEvent):void
{
SoundMixer.stopAll();
}

但是,我仍然遇到子文件没有加载到设备本身的问题 - 奇怪 - 它们在“test”导出时加载正常,但是当我发布到设备(在这种情况下是ios)时没有。有没有人有任何想法?