Skip to main content
Participant
March 8, 2010
Answered

Randomly change movie clip colors at set intervals.

  • March 8, 2010
  • 1 reply
  • 1973 views

I have this movie clip that's a solid color with 60% transparency. I have 24 copies of this, all with instance names of light_mc1, light_mc2 and so on. What I'm trying to do is have them transition their colors not only randomly and constantly, but in unison. The transition has to be smooth, it can't just instantly show red in one frame, then green in the next. I have to be able to see it smoothly change to green, or whichever color is randomly selected.

I hear that math()*0xFFFFFF can help select the random values, but other than that, I'm lost.

Thanks for the help.

This topic has been closed for replies.
Correct answer RossRitchey

Straight from the FAQ on the TweenMax page:

"Can I set up a sequence of tweens so that they occur one after the other?

Of course! That's precisely what TweenLite and TweenMax are for. But if file size is a big concern and you don't need all the fancy extras those tools offer, you could just use the delay property in TweenMax. Here's an example where we tint a MovieClip red over the course of 2 seconds, and then move it to a y coordinate of 300 over the course of 1 second:

Actionscript:
  1. import com.greensock.TweenMax;
  2. TweenMax.to(mc, 2, {tint:0xFF0000});
  3. TweenMax.to(mc, 1, {y:300, delay:2});"

1 reply

RossRitchey
Inspiring
March 8, 2010

Take a look at some 3rd party Tweening classes.

TweenLite is a good one that works in both AS2 and AS3: http://www.greensock.com/tweenlite/

MattGHAuthor
Participant
March 8, 2010

That helps a bit, but doesn't help with my lack of knowledge on AS3. I ended up getting TweenMax because it seemed to at least simplify the code I will need to use. IS it possible to have these MCs change their tint at slightly different times (I'm talking a change of maybe a quarter to half a second, randomly) But still have the transition itself be the same amount of time.

Foe example:

light_mc1 is currently orange (doesn't really matter what it currently is). At the start of the animation, it starts to transition to a random color. THe transition should last about a quarter or half a second (this will be a set transition time).

anywhere between a quarter to half a second later, light_mc2 will transition its tint (again, the transition itself will take a quarter or half a second, I haven't decided yet).

It is OK if some of them transition at the same exact time, but I'm looking for slightly different transition starts with the transitions themselves being a set time.

RossRitchey
RossRitcheyCorrect answer
Inspiring
March 8, 2010

Straight from the FAQ on the TweenMax page:

"Can I set up a sequence of tweens so that they occur one after the other?

Of course! That's precisely what TweenLite and TweenMax are for. But if file size is a big concern and you don't need all the fancy extras those tools offer, you could just use the delay property in TweenMax. Here's an example where we tint a MovieClip red over the course of 2 seconds, and then move it to a y coordinate of 300 over the course of 1 second:

Actionscript:
  1. import com.greensock.TweenMax;
  2. TweenMax.to(mc, 2, {tint:0xFF0000});
  3. TweenMax.to(mc, 1, {y:300, delay:2});"