all groups > flash actionscript > february 2004 >
You're in the

flash actionscript

group:

how to stop attachMovie() clips gracefully



how to stop attachMovie() clips gracefully Richard's got a problem
2/1/2004 5:15:16 PM
flash actionscript: Here is the code below - kindly supplied by PiXELWiT

My question is that i understand all the instances of this movie are loaded [and it looks like into _level10] but how does one control them once they are loaded - since we are talking not just a couple of instances. What i would like is to have the stars disappear at a certain point on the time-line, or fade.

Of course i looked around and can find references to unloadMovie and the like, but unfortunately not too smart when it comes to getting this to work.

Any thoughts?

R.

var maxY = 450;

function star (){
this.Dot._xscale = this.Dot._yscale = 10;
this._rotation = Math.round(Math.random()*360);
this.scal = .5;
var r = Math.random()
this.scalFact = 1+r/3;
this.Dot._y = maxY-r*maxY;
}
star.prototype = new MovieClip;
sp = star.prototype;
sp.onEnterFrame = function(){
this.scal*=this.scalFact;
this.Dot._xscale = this.Dot._yscale+=this.scal/3;
this.Dot._y+=this.scal;
if(this.Dot._y>300){
this.removeMovieClip();
}
}
Object.registerClass("Star", star);

function makeStar(){
for(i=0; i<5; i++){
++starCount;
attachMovie("Star", "Star"+starCount, starCount, {_x:360, _y:270});
}
}

starGen = setInterval(makeStar, 50);

Re:how to stop attachMovie() clips gracefully Hero Protagonist
2/2/2004 12:12:45 AM
Richard,

I looks like the MakeStar function makes 5 instances named Star"+starCount.

for(i=0; i<5; i++){
++starCount;
attachMovie("Star", "Star"+starCount, starCount, {_x:360, _y:270});
}

So each instance would be referred to as Star0, Star1, Start2 etc.

Hope that helps..

-Ken


Kenneth J. Toley
Senior Technical Support Engineer
AddThis Social Bookmark Button