Search In
• More options...
Find results that contain...
Find results in...

# Coed for repeating/looping a tween

## Recommended Posts

I realise the AS command to repeat a tween action is

repeat : number of repeats

But where does this go in my code:

import com.greensock.*;

TweenLite.to(test, 2, {x:198, y:250, rotation:30});

TweenLite.to(test2, 2, {x:300, y:250, rotation:60});

Sorry for the simple question but I am fairly new to tween classes...

##### Share on other sites

Hi Trixiemay,

Welcome to the GreenSock forums.

repeat is a special property of TweenLite's big brother TweenMax

Your code should look like this:

```import com.greensock.*;

TweenMax.to(test, 2, {x:198, y:250, rotation:30, repeat:5}); // will repeat 5 times```

also, see what yoyo does:

`TweenMax.to(test, 2, {x:198, y:250, rotation:30, repeat:5, yoyo:true}); //tween will play back and forth`

Take a look at more features of TweenMax here:

http://www.greensock.com/tweenmax

let us know if you have any other questions

Happy Tweening!

##### Share on other sites

Thanks Carl. That's great!

My other question was regarding a particle system. I have a diagram of some particles flowing through different chambers. But I am looking at having the particles flow continuously. I presume that using TweenMax will have a definite start and end.

So can it be used for a constant flow? I don't really want to use a particle stream as there a number of particles that have to be different sizes and colours.

thanks

##### Share on other sites

perhaps i need to understand better what you mean by a constant flow, but I'm sure you can generate enough repeating particles at the right timing interval to simulate a constant flow.

I would suggest looking into the LinePath2D tools: http://www.greensock.com/as/docs/tween/com/greensock/motionPaths/LinePath2D.html

copy and paste the code from the docs into a blank fla. cool stuff!