Published in: ActionScript
randomly duplicate a movie clip around a square
staring = false; max_star = 10; current_star_num = 0; star_num = 0; square_w = 400; square_h = 200; alea = 40; this.onEnterFrame = function() { if(!staring || current_star_num >= max_star) return; var n_star = Math.round(Math.random()*1)+1; for(var i=0; i<=n_star; i++) { star_num++; current_star_num++; duplicateMovieClip(star_mc, "star" + star_num, star_num); var new_star = this["star" + star_num]; // position new_star._x = Math.random()*(square_w+alea) - (alea/2); new_star._y = Math.random()*(square_h+alea) - (alea/2); if(Math.random()*2>0.5) new_star._x = (Math.round(Math.random()*2)%2)*square_w + Math.round(Math.random()*alea) - (alea/2); // horiz else new_star._y = (Math.round(Math.random()*2)%2)*square_h + Math.round(Math.random()*alea) - (alea/2); // vert new_star._alpha = 0; new_star._xscale = new_star._yscale = Math.round(Math.random()*50) + 50; new_star.speed = Math.round(Math.random()*10+3); new_star.way = "in"; new_star.onEnterFrame = function () { if (this.way == "in") { this._alpha = Math.min(100, this._alpha+this.speed); speed = speed - Math.max(1,speed*.3); if(this._alpha == 100) this.way = "out"; } else if (this.way == "out") { this._alpha = Math.max(0, this._alpha-this.speed); speed = speed + Math.min(10,speed*1.5); if(this._alpha == 0){ current_star_num--; delete this.onEnterFrame; removeMovieClip(this); } } } } }
You need to login to post a comment.
