this.createEmptyMovieClip("holder",
this.getNextHighestDepth());
This
code creates and empty movieclip on stage
holder.maxbubbles=50;
var upspeed=80;
This
part starts variables to be used in the script here maxbubbles
gives the maximum no of clips to be attached and upspeed represents
the speed of the bubbles
//Part
1 attaching the clips with loop
for(i=0;i<holder.maxbubbles;i++){
holder.attachMovie("circleclip","bubble"+i,i+5);
focusedbubble=holder["bubble"+i]
focusedbubble._x=random(Stage.width);
focusedbubble._y=random(Stage.height);
focusedbubble._yscale=focusedbubble._xscale=random(100);
focusedbubble._alpha=focusedbubble._yscale;
}
this
is the loop to attach movieclip "circleclip" that we
have exported for actionscript.Now clips named bubble1 bubble2
bubble3 etc will be attached to the empty movieclip "holder"
according to the value of i.
In
each loop the variable name "focusedbubble" is given
to the i th movieclip and its properties like _xscale xposition
etc are set.Now for alpha I have linked it with the scaling of
clips so that big bubbles that are nearer will have high alpha
and others away will have low alpha.Thus part 1 of the code is
completed now we have to make movement to the clip.For that we
should make an interval to repeat a function in a certain time,
so that the y position and x position of each clip can be changed
to create movement