# Yet another newb question! (random motion)

Hey there,

I have a movie clip of my company’s logo in an animation that will serve as a nav bsr for my company’s site, and i want the logo to ‘sparkle’ at random places and intervals.

I’ve created a separate movie clip for the sparkle itself, and i was wondering what kind of code would be needed to make the sparkle clip appear at random spots on the logo.

I’ve tried adding the sparkle to different points on the logo and jumping to their corresponding frames using a random number, but that doesn’t seem to work (its also not as random as i’d like).

can anyone let me know what script needs to be attached to what in order to get this affect?

Greatly appreciated,
Mars

So, you don’t want random motion, necessarily. You want random placement? If the logo doesn’t move and you have a min/max _x and _y coor; you can tell the movieClip to appear in a certain area.
[AS]
_x=20+Math.random()*80;
_y=10+Math.random()*50;
[/AS]
For example, these formulas will put the _x coor somewhere inbetween 20 and 100; the _y between 10 and 60. The range is the first number (in the equation) to the sum of both numbers.

I hope this helps. This confused me when I first encountered it, but now I use it all the time.
(-:

i’m thinking something like this may work if attached to a frame, and i’d also only want one to show at a time.

http://www.macromedia.com/support/flash/ts/documents/random_movie_clip.htm#Product

also, when i use this script, does the ‘var’ value need to be set to an arbitrary value before the rest of the script runs?

edit:let me first try freddy thunder’s suggestion i guess?

Here, I’m trying to avoid doing any actual ‘work’ (taxes) today, so I put together a little something to help explain. I would of used action script for the spinning, size, and alpha of the spark, but I figured I’d just use a tween.

I’m still kinda new at this stuff, but I hope this helps.

heck yeah it helped!

thanks a bunch, worked perfectly. i chose not to use the duplicate script because it seemed to create multiple sparkles on mine where it didn’t on yours, not so sure why.

in any event, i am in your debt kind sir. probly won’t get to my taxes today either;)

:beam:
That’s wierd about the dup thing. I did it that way so there wouldn’t be more than one at a time. Wierd. You know, though, if you do want a ton of MC (future ref), you could move that script to the MC’s AS:
[AS]