Help understanding the nature of this 1006 and 1009 errors?
Hi,
I am working in Flash Professional CC, testing an old game with two levels and a win and lose screen. The game works until you get to the second level scene. Once you're there, the 1006 output errors appear.
TypeError: Error #1006: removeChild is not a function.
at final_project_2_fla::golem_22/onHealth()[final_project_2_fla.golem_22::frame1:6]
removeChild( ) is only used in the golem health function which it is referencing., so I know the problem's probably there. Thing is, I don't know why Flash is telling me I'm using removeChild as a function or why a sixth frame is being reference. Unless that's a code line references?
Here's the code from the enemy I was talking about.
var health:int=4;
this.addEventListener(Event.ENTER_FRAME,onHealth);
function onHealth(evt:Event):void{
if(health==0){
this.removeEventListener(Event.ENTER_FRAME,onHealth);
Object(parent).removeChild(this);
}
}
Also, when you beat the game you get this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at final_project_2_fla::MainTimeline/onLoop2()[final_project_2_fla.MainTimeline::frame4:27]
I read up on the 1006 error because it's really common. I know the steps begin with tracing something, but I'm not sure what to begin tracing because it's referencing the function, but I think it's refencing the 27th line of a fourth frame? Which doesn't make sense because I don't have a fourth frame there.
Here's the onLoop2 function, if it will help out
function onLoop2(evt:Event):void {
charMove();
if(char.hitTestObject(bgr.page1)){
bgr.page1.visible=false;
uipage1.visible=true;
removeListeners2();
echannel=ff.play(0,1);
gotoAndStop(1, "win");
}
///collision with golem 1
if(char.hitTestObject(bgr.golem)){
trace(attack);
if(attack){
bgr.golem.x+=50;
bgr.golem.health--;
attack=false;
}else{
if(bgr.golem.arms.currentFrameLabel=="idle"){
bgr.golem.arms.gotoAndPlay("attack");
}
health-=5;
bgr.x+=10;
}
}
if(health<75){
hp4.visible=false;
}
if(health<50){
hp3.visible=false;
}
if(health<25){
hp2.visible=false;
}
if(health<1){
hp1.visible=false;
removeListeners2();
gotoAndStop(1, "lose");
}
Thank you for your time and effort. ![]()
