TwelvestoneFlash

limiting _x range (duplicateMovie)


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
dave_boo
 
2008-12-09

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();

Storm
 
2008-12-09

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.

dave_boo
 
2008-12-09

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

Storm
 
2008-12-09

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?

DontBogartMe
 
2008-12-09

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.

dave_boo
 
2008-12-09

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)

lithium
 
2008-12-09

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();

dave_boo
 
2008-12-09

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?

Storm
 
2008-12-09

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

dave_boo
 
2008-12-09

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 k

dave_boo
 
2008-12-10

While I'm at it -

Any way to mask the duplicated mcs?

Think snow in a snow globe

Just askin'

JLM
 
2008-12-10

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?

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

limiting _x range (duplicateMovie)