Question

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


                }
    }
};
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top