Jump to content
Search Community

Randomly change tint on multiple movie clips

Flickie
Moderator Tag

Recommended Posts

Posted

I have about 22 movie clips, all a solid color with a naming convention of light_mc1, light_mc2, light_mc3 and so on. I currently have all of their transparency values set to about 60%. All of them are currently different colors. I would like them to smoothly transition colors at set intervals (about 1-2 seconds each transition, but 1.5 is ideal). I need them to change in unison. Or if possible, have them all change at slightly different intervals, but keep the 1.5 second transition time. SOrry, but I am unabale to upload an example at this time.

Posted

Are they all transitioning to the same tint?

 

var clips:Array = [light_mc1, light_mc2, light_mc3]; //put all your clips in this array
TweenMax.allTo(clips, 1.5, {tint:0xFF0000}, 0.2);

 

Is that what you're after?

Posted

They all need to become different tints. Different random tints. I can get random with tint:Math.random()*0xFFFFFF, but not a different color for each. Also, I need this to repeat for the duration of the animation unil a specified frame (I am not sure which frame that will be as of yet, so let's just say frame 1000 for now).

 

When I say repeat, I mean if light_mc turns from color x to color y, it needs to turn from color y to color z to another random color the next time and so on for all MCs

 

Edit: I also seem to be hacing trouble with the updateto call.

 

Is it

 

TweenMax.updateto(clips,{tint:Math.random()*0xFFFFFF});

 

OR

 

Clips.updateto({tint"Math.random()*0xFFFFFF});

Posted
They all need to become different tints. Different random tints. I can get random with tint:Math.random()*0xFFFFFF, but not a different color for each. Also, I need this to repeat for the duration of the animation unil a specified frame (I am not sure which frame that will be as of yet, so let's just say frame 1000 for now).

 

When I say repeat, I mean if light_mc turns from color x to color y, it needs to turn from color y to color z to another random color the next time and so on for all MCs

 

What do you mean "but not a different color for each"? Isn't a color the same as a tint in this case?

 

I'd probably do something like:

 

var i:int = myArrayOfClips.length;
while (i--) {
   randomTint(myArrayOfClips[i]);
}

function randomTint(mc:DisplayObject):void {
   TweenMax.to(mc, 1.5, {tint:uint(Math.random() * 0xFFFFFF), onComplete:randomTint, onCompleteParams:[mc], delay:Math.random()});
}

 

And then when you need to stop the tweens, just loop through your myArrayOfClips and use TweenLite.killTweensOf() for each clip.

 

Is it

 

TweenMax.updateto(clips,{tint:Math.random()*0xFFFFFF});

 

OR

 

Clips.updateto({tint"Math.random()*0xFFFFFF});

 

Neither. It's:

 

var myTween:TweenMax = new TweenMax(mc, 1, {tint:0xFF0000});
//then later...
myTween.updateTo({tint:0x0000FF});

Posted

That works perfectly! Thanks. I didn't know about the randomtint function. Is that part of GreenSock, or Flash itself? Also, is there any way to have the tint be random, but exclude a color range? I only ask because these lght_mc* clips are strobe lights like at a dicso. It would be nice to exclude blacks/dark greys if at all possible.

Posted
is there any way to have the tint be random, but exclude a color range? I only ask because these lght_mc* clips are strobe lights like at a dicso. It would be nice to exclude blacks/dark greys if at all possible.

 

Sure, but that's beyond the scope of the stuff I typically address in these forums - you'd need to separate each R/G/B component of the hex value and apply whatever limits you want and then combine them.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...