Hi, I am trying to make a simulation of a blood moving in an artery and I want blood cells to continuously be moving across the stage ( so that there are no gaps in between one loop and the other) when i click the start button.
I thought about doing a setinterval loop but it just overwrites the previous set of generated mcs?
This is the code on my button
on (release) {
var years:Number = 80;
function generatePlatelet (){
var Platelet_no:Number = PlateletStepper.value;
for (var count:Number = 0; count<Platelet_no; count++){
_root.Platelet.duplicateMovieClip (“Platelet” + count, count);
}
}
generatePlatelet();
}
And this is the code in my blood cell(platelet)
onClipEvent (load) {
gravity = 0.01;
xspeed = 10;
}
onClipEvent(load){
Position_y = Math.random () * 125 + 5
Position_x = Math.random () * 755 + 5
_x = Position_x
_y= Position_y
}
onClipEvent (enterFrame) {
xspeed += gravity;
while (_root.terrain.hitTest(_x, _y+_height, true)) {
_x--;
xspeed = 0;
}
if (!_root.terrain.hitTest(_x, _y+_height+1, true)) {
_x -= xspeed;
} else {
xspeed = 0;
}
}