having trouble figuring out how to limit _x & _y range using duplicateMovieclip ...
any suggestions?
thanks
dupMovie = function () { for (i=0; i<100; i++) { particle_mc.duplicateMovieClip("particle"+i, i, {_x:Math.random()*300, _y:Math.random()*200, _alpha:Math.random()*50}); with (eval("particle"+i)) { _xscale = _yscale=Math.random()*300; } } }; dupMovie();
calculate your random numbers in a seperate function with max and min values if randomX > maxValueX make it maxValueX kind of thing and return those values to this function.
I don't really get eval because I've never used it, so I could approach the random calculation as a separate function.
thanks!
created a var for the _x range (which worked) but ultimately settled on _x:Math.floor(Math.random() * (290 - 255) + 255)
and now for something completely different:
suppose i want something to be in the foreground of all these duplicated movie clips - as it is currently, it seems like it defaults to level_0
AS3
setChildIndex(shape, index + 1);
AS2
particle_mc.duplicateMovieClip("particle"+i, i, {_x:Math.random()*300, _y:Math.random()*200, _alpha:Math.random()*50}, getNextHighestDepth());
or do you mean swapDepths?
I'm not exactly sure what you're trying to do. Just add them to the front when you duplicate them?
Originally posted by: Storm calculate your random numbers in a seperate function with max and min values if randomX > maxValueX make it maxValueX kind of thing and return those values to this function.
don't do that or you'll get a lot of the particles grouped in a line where that max value is.
say if you want a random number between 100 and 500, you can use:
100 + (Math.random() * 400)
That'll keep the spread even.
thanks for all your help storm ...
basically just want to have an mc that is 'above' (obscures) the mcs generated by the duplicateMovieclip script
i've been toying with swapDepth but it no worky
seems like its problematic that one mc is an 'on-stage' clip and the others (mcs) are being generated by code (duplicateMovieclip)
Originally posted by: dave_boo
dupMovie = function () { for (i=0; i<100; i++) { particle_mc.duplicateMovieClip("particle"+i, getNextHighestDepth(), {_x:Math.random()*300, _y:Math.random()*200, _alpha:Math.random()*50}); with (eval("particle"+i)) { _xscale = _yscale=Math.random()*300; } } }; dupMovie();
lith:
no such luck ...
and wouldnt that bring the duplicated clips to the foreground instead of to the background?
or have i been staring at this for way too long?
the MC you want at the front is NOT one of the duplicated ones right?
do your dupMC
and then
move the MC to the next highest Depth after the looping function
mctogotothefront.swapDepths(getNextHighestDepth()); *** wait, I better try this first *** I will return *** *** yup, all good ***
That'll keep the spread even.
yup, I've seen the error of my ways
son.of.a.bitch
i've used swapDepths before by referencing each clip - like: (mc1.swapDepths(mc2)
and its always worked fine ...
but the code you sent works fine if placed after the dupMovie(); close
thanks a million - again 
While I'm at it -
Any way to mask the duplicated mcs?
Think snow in a snow globe
Just askin'
just scope all the code and the duplicatable movie in a masked movie.
OR.. If you want to produce duplicates only in a sphere then place clips with polar coordinates...
var r: Number = ( Math.random()*radius ); var theta: Number = ( Math.random()*2*Math.PI ); _mc.x = r*Math.sin( theta ) + centreX; _mc.y = r*Math.cos( theta ) + centerY;
Ofcourse if your scaling them then you need to take that into account and this approach will make the center more dense ( uneven spread ) but it may be desirable if a 'globe' effect is required?