PDA

View Full Version : Random Motion on many Movie Clips


Ingenieurs
02-17-2008, 01:25 PM
Hi all.

first off, this is my first post so I'll say hello. I've been using Flash seriously now for ooh, 5 hours 22 minutes!

I'm liking it, and finding it frustrating, but I'm well up for learning.

So, I have this code:

import caurina.transitions.*;

function grassMover()
{
Tweener.addTween(grass, {rotation:Math.random()*45,
time:5, onComplete:grassMover,
transition:"easeOutElastic"});

Tweener.addTween(grass1, {rotation:Math.random()*45,
time:5, onComplete:grassMover,
transition:"easeOutElastic"});

Tweener.addTween(grass2, {rotation:Math.random()*45,
time:5, onComplete:grassMover,
transition:"easeOutElastic"});

Tweener.addTween(grass3, {rotation:Math.random()*65,
time:5, onComplete:grassMover,
transition:"easeOutElastic"});

Tweener.addTween(grass4, {rotation:Math.random()*25,
time:5, onComplete:grassMover,
transition:"easeOutElastic"});

Tweener.addTween(grass5, {rotation:Math.random()*45,
time:5, onComplete:grassMover,
transition:"easeOutElastic"});


}

grassMover();

---

Which gives random motion for some blades of grass, each blade is a symbol with an instance name of grass, grass1, grass 2 etc.

Now, I know it must be possible to clean this up a hell of a lot. Can I use the function once, for all of the grass blades, and still have each one hand a unique random rotation?

Or, and probably better, can I have one symbol which I can duplicate randomly around along x and have the code apply scale attributes within a given range, then add the motion?

Sorry if this is asking a ton.

Regards, A.

weaksauce
03-03-2008, 07:18 PM
try using a for loop

for(var i:int = 1; i > 10; i++)
{
<insert function body here>
}

for ten blades of grass