Link to home
Start Free TrialLog in
Avatar of ddlam
ddlamFlag for Hong Kong

asked on

removeChild(), removeEventListener()

Anyone give me some hit in debugging with removeChild(),  removeEventListener()?

fire[fireNumber] = new fire1;
stage.addChild(fire[fireNumber]);

enemy_fire[bulletNumber] = new bullet;
enemy_fire[bulletNumber].addEventListener(Event.ENTER_FRAME, bullet_attack);
stage.addChild(enemy_fire[bulletNumber]);
bulletNumber++;

function bullet_attack(attack:Event) {
   attack.target.removeEventListener(Event.ENTER_FRAME, bullet_attack);//may be error
   stage.removeChild(fire[i]); //may be error
}

========Runtime Error=============================================
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
      at flash.display::DisplayObjectContainer/removeChild()
      at deathnotes_fla::MainTimeline/bullet_attack()
Avatar of ddlam
ddlam
Flag of Hong Kong image

ASKER

ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ddlam

ASKER

thx blue-genie,
i is within a for loop.  I hided all of them.
There is hundred of codes in http://ihome.ust.hk/~eg_lhwac/deathnotes.zip.
If the above codes is logical, I can go through other codes.
Avatar of ddlam

ASKER

I close to the answer now. thanks
so what was the problem?