2007年12月25日 星期二

Dynamic Magic Rings

Create Magic Rings in Flash

用 ActionScript 自動產出 random rings







Demo : http://annwongfresh.googlepages.com/duplicateRing.html
(soucecode : duplicateRing.fla)

ActionScript:
frame 1 :
var i:Number =0; // start number for looping
var max:Number =30; // dupliate maximum number
ring0._visible =0; // hidden the 1st ring


frame 2 :
duplicateMovieClip("ring0","ring" +i,900-i);
// duplicateMovieClip( target , newname , depth )

this["ring" +i]._x = Math.random()*400; // 400 is the stage width
this["ring" +i]._y = Math.random()*300;
this["ring" +i]._xscale = i*5; // enlarge 5 times
this["ring" +i]._yscale = i*5;
this["ring" +i]._alpha = Math.random()*100; //random 0 <= n < 1 , 0-100% Alpha
i = i+1;


frame 3:
if(i<=max){
gotoAndPlay(_currentframe -1);
}



1 Comment:

匿名 said...

Your teaching is quite good! I like it.