Movieclip: Function callback on animation end

Hello!

Is there a designated way of automatically calling a function after an animation created with “movieclip.newAnim” has ended playing?

Thanx!

Hi @EleXX,

This is a rather old library (movieclip), so I’m not familiar with all its functionality. At a quick glance, however, I think you should be able to build in a quick function call in the “next frame” function that senses when the end frame is reached, it calls another function.

Is there a reason you’re using this library specifically, versus a normal animated sprite?

Regards,

Brent

Hi!

I’m using the movieclip library for the simple reason, that it is described and documented on this page:

http://developer.coronalabs.com/content/animation

It seemed an easy and feasible way for what I wanted to do: Just play a small animation clip (without any kind of interaction).

But I will change that to sprites if that is the recommended way. Is there a callback at the end of the animation when using sprites?

Thx

Hi @EleXX,

Yes, sprites have several listeners (callbacks) which is another reason why I suggested using them. These include:

“began” = the sprite has started playing.

“ended” = the sprite has finished playing.

“bounce” = the sprite has bounced from forward to backward while playing.

“loop” = the sprite has looped to the beginning of the sequence.

“next” = the sprite has played a subsequent frame that’s -not- one of the above phases.

Here’s a tutorial on sprites, if you haven’t seen it yet:

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,

Brent

Ok, thanx for your quick response!

Hi @EleXX,

This is a rather old library (movieclip), so I’m not familiar with all its functionality. At a quick glance, however, I think you should be able to build in a quick function call in the “next frame” function that senses when the end frame is reached, it calls another function.

Is there a reason you’re using this library specifically, versus a normal animated sprite?

Regards,

Brent

Hi!

I’m using the movieclip library for the simple reason, that it is described and documented on this page:

http://developer.coronalabs.com/content/animation

It seemed an easy and feasible way for what I wanted to do: Just play a small animation clip (without any kind of interaction).

But I will change that to sprites if that is the recommended way. Is there a callback at the end of the animation when using sprites?

Thx

Hi @EleXX,

Yes, sprites have several listeners (callbacks) which is another reason why I suggested using them. These include:

“began” = the sprite has started playing.

“ended” = the sprite has finished playing.

“bounce” = the sprite has bounced from forward to backward while playing.

“loop” = the sprite has looped to the beginning of the sequence.

“next” = the sprite has played a subsequent frame that’s -not- one of the above phases.

Here’s a tutorial on sprites, if you haven’t seen it yet:

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,

Brent

Ok, thanx for your quick response!