0
votes

Having nothing but errors today! It would be sooo nice to get a bit of help with this one.

I am calling external child swfs for an AIR app; SUPER SIMPLE - calling them with a button, and removing them with a "home" button, that's it. But I get these errors and I cannot publish, even a test, without crashing the entire system. Please help! I have been stuck on this, literally, for weeks!

this is the error:

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.

And this is what I assume is causing the problem on the main timeline (this is ALL the code on the main timeline):

 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
um, this seems to be the code on frame 1, and given your autogenerated function names, your function that gives you problems is located at frame 20. Find it and post its code, please.Vesper

2 Answers

0
votes

In your function fl_ClickToGoToAndStopAtFrame_01_1 you say removeChild(fl_ProLoader_01); but you also call it in function fl_ClickToLoadUnloadSWF_01_1. Both functions are assigned to the same MovieClip/Button, so it will give an error that it is null, on line 18 where you call removeChild on the same MovieClip/Button again.

0
votes

I think it got solved!

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();
}

However, I still am having the problem that the child files are not loading on the device itself - strange - they load fine on "test" export, but not when I publish to device (in this case ios). Does anyone have any ideas?