How to create a tween from one color to another


#1

hi all, :slight_smile:
after many hours of my stupidity, i couldn’t make it to tween from one color to another, i’m not successful to find the web about this topic either, can I know how could one tween from one color to another?
let’s say i have one variable color1(of red color), how would I tween it to be of green color in x seconds?
thanks


#2

hi,

make this lib your friend Actuate

Actuate.transform (MySprite, 1).color (0xFF0000, 0.5);


#3

The trick is that you need to tween all of the colors separately, and recombine them again, each step of the animation. I believe that’s what Actuate.transform().color() is doing :slight_smile:

A straight number tween from one full color to another goes through a lot of wild colors inbetween :slight_smile:


#4

thanks for the replies :slight_smile: ,
i couldn’t get this to work :frowning:

public var c1 : RGBA = RGBA.create(255, 255, 0, 1);

public function new() {	
super();	
Actuate.transform(c1, 2).color(0xFF0000, 0.5, 1);
graphics.beginFill(c1, 1);
graphics.drawCircle(150, 150, 50);
}

It just shows the final red color as the circle’s color…i know it is possible to do by transforming the circle but is it possible transform colors and use that transforming color in circle?


#5

I made a small sample that works on Flash, but isn’t working on Neko at the moment. We’ll look into it. In the meantime, tweening the object’s x property fixes the color tween, so tweening from 0 to 0.00001 or something might work as a hack for the moment


#6

thanks ! , even this sample hack would work for me…:slight_smile: