Reputation: 5477
I'm trying to remove a movieclip with removeChild() function. My code is below, but it doesn't work.
addEventListener(Event.ENTER_FRAME, lemons_collide);
function lemons_collide(ev : Event) : void
{
if(currentFrame==1)
{
if(cup2.hitTestObject(lemons))
{
lemons.stopDrag();
lemons.x = 35;
lemons.y = -150;
lemons.gotoAndPlay(1);
if(lemons.currentFrame>=14){
removeChild(lemons);
}
}
}
};
Upvotes: 0
Views: 324
Reputation: 46523
The "currentFrame" check is run directly after the "gotoAndPlay".. so the currentFrame is always "1". You will have to run a separate event listener tracking "ENTER_FRAME" on that object, then have that remove the child once it is on Frame 14.
Upvotes: 1