Link to home
Start Free TrialLog in
Avatar of petersego
petersego

asked on

how do I randomly multiply movieclip-function

I have a small movieclip that I move from one place to another with the tween class. But I want the movieclip-function - see code below -  to multiply into a flow, that follow each other constantly. Like bloodcells. Preferably randomnly, but still along the same line.

import mx.transitions.Tween;
import mx.transitions.easing.Regular;
attachMovie("bloodcell","bloodcell_mc",10);
moveBlood = function(){
	new mx.transitions.Tween(bloodcell_mc, "_x", Regular.easeIn, 30, 500, 1, true);
	new mx.transitions.Tween(bloodcell_mc, "_y", Regular.easeIn, 30, 200, 1, true);
	}

Open in new window

Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

here is a sample code, which may lead you to get the required reason..
just replace your existing code with the following:


import mx.transitions.Tween;
import mx.transitions.easing.Regular;
 
 
 
var total = 20;
for (var i = 0; i<total; i++) {
	var mc = this.attachMovie("bloodcell", "bloodcell_mc"+i, i);
	mc._x = 30*Math.random();
	mc._y = 30*Math.random();
	var duration = 2*Math.random();
	var x = 500+mc._x;
	var y = 200+mc._y;
	moveBloodCell(mc,x,y,duration);
}
 
 
 
 
function moveBloodCell(mc, x, y, duration) {
	new mx.transitions.Tween(mc, "_x", Regular.easeIn, mc._x, x, duration, true);
	new mx.transitions.Tween(mc, "_y", Regular.easeIn, mc._y, y, duration, true);
}

Open in new window

Avatar of petersego
petersego

ASKER

Thanks, excellent.
But is there a way to make the flow continue endlessly. So it doesnt look as if it ends before it restarts.
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much, simply perfect.