Jump to content
Search Community

Tween Random Color from Array

pinkp test
Moderator Tag

Recommended Posts

I wish to tween my Movie Clip to a random color from a selection of 3.

 

I have read many examples of this and spent a long time trying to achieve with out success, could someone please point me in the right direction thanks.

 

So far this works for a random color.

 

import com.greensock.*;
TweenMax.to(MYmc, 4, {tint:0xFFFFFF});

 

Now I need to limit the choice to three colors. But to choose it randomly.

 

Thanks for ur help! :)

Link to comment
Share on other sites

give this a whirl

 

 

import com.greensock.*;
import com.greensock.plugins.*;

TweenPlugin.activate([TintPlugin]);

var randomColor:Number;
var colors:Array = [0xff0000, 0xff6600, 0x00ff66]



randomColor = colors[  randomNumber(0, colors.length-1)   ]
TweenLite.to(MYmc, .5, {tint:randomColor});



//http://www.snorkl.tv/2011/02/use-the-proper-function-for-random-numbers-or-else/
function randomNumber(min:Number, max:Number):Number {
	return Math.floor(Math.random() * (1 + max - min) + min);
}

Link to comment
Share on other sites

THANK YOU!

 

worked like a charm. I had to change from Actionscript 3.0 to 2.0 (publish settings) but that is what I wanted anyway.

 

It just so happens I was watching your car tint video the other day!! thanks for your very fast and helpful reply.

 

:D

Link to comment
Share on other sites

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...