1

I have a single clip on the stage with an instance name of testShape. In frame 1 I have the following code:

createjs.Tween.get(this.testShape, {loop:true}).to({y:240}, 1000);

When I run this it loops infinitely as expected but what I want is for it to loop three time then stop and fire a complete event. The docs say that the loop param...

Indicates the number of times to loop. If set to -1, the tween will loop continuously.

Which suggests I should be able to set {loop: 3} to achieve my desired result but any number value other than 0 just causes it to loop endlessly.

Can anyone advise on what I'm doing wrong or how to make a Tween loop n times before completing?

Cheers all

popClingwrap
  • 3,919
  • 5
  • 26
  • 44
  • What version of createjs are you using? Here is a quick fiddle with 1.0: https://jsfiddle.net/tg7oumdb/ – Lanny May 09 '18 at 20:02
  • I don't know. Whatever version comes bundled with Adobe Animate CC 15.2. I got it working in the end by making each tween set up the next as it completes. It's a bit hacky, but I'm on a deadline and it seems to work. – popClingwrap May 10 '18 at 13:17

1 Answers1

1

It looks like TweenJS 0.6.2 and earlier used a Boolean value for loops, so while you can set it to true or false, you can not put it as a number of loops. If you set it to a number, it will be converted to true.

createjs.Tween.get(obj, {loop:true}).to(…).to(…);

This behaviour was updated in version 1.0.0 of TweenJS, in September, 2017.

createjs.Tween.get(obj, {loop:3}).to(…).to(…);

I am glad you found a solution:

I got it working in the end by making each tween set up the next as it completes.

Lanny
  • 11,244
  • 1
  • 22
  • 30