문제

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


                }
    }
};
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top