actionscript - loop through instances of movieclips flash -
i have bunch of movie clips on layer named s1, s2, s3, .. s16.
i need add them array can select random number play.
something like:
var sparkle:array = new array(); var i:int = new int; for(i=0;i=16;i++) { sparkle[i] = 's'+i; }
if know total number of movieclips, don't need store them in array.
get random number first
var random:int = math.round( math.random() * totalnumber );
then can use function return mc want
private function getmovieclip(value:int ):movieclip { var mc:movieclip; for( var i:int ; < totalnumber ; ++i ) { if( this.getchildat(i).name == "s"+ random.tostring() ) { mc = this.getchildat( ) movieclip; break; } } return mc; }
Comments
Post a Comment