alright… this is assuming that you know how to attach code to movie clips, and how to create functions (thought technicaly you don’t need to know how to do it, it will help you to understand what is going on.)
you may wish to create these circles dynamicaly, and randomly place their start location. This is the method I’m going to explain, but I’ll try to set up the script to do either that or a repeating pattern.
This also assumes that the circle clip is using it’s center as it’s registration poiint.
create a movie clip and inside of it place your circle movie clip.
give the circle an “Instance” name of “circle”
give the movie clip that contains the circle clip an Instance name of “circleClipContainer”.
attach this script to the outside of the “circleClipContainer”
onClipEvent(load){
//Set initial variables
//this assumes that you’re clips are moving right to left. set this
//number equal to the height of your stage.
circRad=this.circle._width/2;
//stage size
stageHeight=300;
stageWidth=500;
//this makes 30 circles
totalClips=30;
//loop to create more circles and place them.
for(i=0; i < totalClips; i++){
//take the circle clip and make many of them.
duplicateMovieClip(this.circle,“circle”+i,i);
this[“circle”+i]._y=(Math.random()*stageHeight+1)+circRad;
this[“circle”+i]._x=stageWidth+(Math.random()*stageWidth+1);
this[“circle”+i].startPos=this[“circle”+i]._x;
//the velocity is the speed the clip will travel at. if you would
//prefer that it not be random, simply change it to a number
this[“circle”+i].velocity=Math.random()*6+1;
}
}
onClipEvent(enterFrame){
for(i=0;i < totalClips;i++){
this[“circle”+i]._x-=this[“circle”+i].velocity;
if(this[“circle”+i]._x <= 0-circRad){
//uncomment this line if you want start pos to be random
//after each pass
//this[“circle”+i].startPos=stageWidth+(Math.random()*stageWidth+1);
this[“circle”+i]._x=this[“circle”+i].startPos;
//uncomment this line if you want velocity to change after
//each pass
//this[“circle”+i].velocity=Math.random()*6+1;
}
}
}
you might need to tweek this to get it to work correctly.
I’ve set it up so that 30 circles are spawned, each on apears for the first time randomly, off stage to the right. Each one has a random movement of 1 - 6 assigned to it.
The below example of the onClipEvent MAY work better. Try it out as well and see what kind of results you get on speed from each.
onClipEvent(load){
//Set initial variables
//this assumes that you’re clips are moving right to left. set this
//number equal to the height of your stage.
circRad=this.circle._width/2;
//stage size
stageHeight=300;
stageWidth=500;
//this makes 30 circles
totalClips=30;
//loop to create more circles and place them.
for(i=0;i < totalClips;i++){
//take the circle clip and make many of them.
duplicateMovieClip(this.circle,“circle”+i,i);
}
for(var property in this){
if(typeof this[property] ==“movieclip”){
this[property]._y=(Math.random()*stageHeight+1)+circRad;
this[property]._x=stageWidth+(Math.random()*stageWidth+1);
this[property].startPos=this[property]._x;
//the velocity is the speed the clip will travel at. if you would
//prefer that it not be random, simply change it to a number
this[property].velocity=Math.random()*6+1;
}
}
}
onClipEvent(enterFrame){
for(var property in this){
if(typeof this[property] ==“movieclip”){
this[property]._x-=this[property] .velocity;
if(this[property]._x <= 0-circRad){
//uncomment this line if you want start pos to be random
//after each pass
//this[property].startPos=stageWidth+(Math.random()*stageWidth+1);
this[property] ._x=this[property].startPos;
//uncomment this line if you want velocity to change after
//each pass
//this[property].velocity=Math.random()*6+1;
}
}
}
}
Mind you… I didn’t test either one of these. If they don’t work, write back and I’ll see what I might have done wrong.
enjoy