Misc. ColorTransform tween with BetweenAS3
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.MouseEvent;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.easing.*;
public class Sample extends Sprite
{
public function Sample()
{
(addChild(new TextField()) as TextField).text = 'Click to start';
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function mouseUpHandler(e:MouseEvent):void
{
while (numChildren > 0) {
removeChildAt(0);
}
var box:Box = addNewBox(230);
box.x = 230;
// ColorTransform Tween
BetweenAS3.tween(box,
{
transform: {
colorTransform: {
redOffset: 255
}
}
}, null, 2.0, Cubic.easeOut
).play();
}
private function addNewBox(y:Number):Box
{
var box:Box = new Box();
box.x = 20;
box.y = y;
addChild(box);
return box;
}
}
}
import flash.display.Sprite;
internal class Box extends Sprite
{
public function Box()
{
graphics.beginFill(0);
graphics.drawRect(-10, -10, 20, 20);
graphics.endFill();
}
}