Pergunta

Is there any function in AS 3.0 that plays a MovieClip and then does removeChild() after it has been played? I don´t want to stop() it i just want to remove the child from stage.

Foi útil?

Solução

As a code example, suggested by Sr.Richie, here is what is required:

Inside the MC to play and remove, add this frame code:

addEventListener(Event.ENTER_FRAME, function (e:Event):void {
   if(currentFrame==totalFrames) {
      removeEventListener(Event.ENTER_FRAME, arguments.callee);
      parent.removeChild(this);     
   }
}

Note I haven't tested this code, but it's the general idea.

Outras dicas

No, there's no built-in method to do it.

But you can let your objects extend MovieClip, and create a custom method triggered by an ENTER_FRAME event to check if the last frame is reached, and remove them from the parent then

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top