King of Rainbow Diamonds

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Animated color transition of the King of Diamonds playing card using actionscript 3 ColorMatrixFilter class.

import flash.display.Sprite;
import fl.motion.AdjustColor;
import flash.filters.ColorMatrixFilter;
import fl.events.SliderEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;

var colour:AdjustColor = new AdjustColor();
var cc:int = 0;
var filter:ColorMatrixFilter;

colour.brightness = 0;
colour.contrast = 0;
colour.hue = 0;
colour.saturation = 0;

//hue_slider.addEventListener(SliderEvent.CHANGE, changeHue);

var timer:Timer = new Timer(1);
timer.addEventListener(TimerEvent.TIMER, shiftHue);
timer.start();

function shiftHue(e:TimerEvent):void{
	
	if(cc >= 179){
		cc = -179;
	}else{
		cc += 3;
	}
	
	colour.hue = cc;
	updateIMG();
}

function changeHue(e:SliderEvent):void{
	colour.hue = e.target.value;
	updateIMG();
	trace(e.target.value);
}

function updateIMG():void{
	filter = new ColorMatrixFilter(colour.CalculateFinalFlatArray());
	Kd_mc.filters = [filter];
}