package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.ColorTransform;
public class Main extends Sprite {
private var _loader:Loader = new Loader();
private var _current:int;
public function Main () {
_loader.load(new URLRequest("http://www.rntsoft.com/image.jpg"));
addChild(_loader);
_loader.addEventListener(MouseEvent.CLICK, clickHandler);
_loader.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}
private function mouseMoveHandler(event:MouseEvent):void {
var value:Number = _loader.mouseX / _loader.width;
var colorTransform:ColorTransform = _loader.transform.colorTransform;
if(_current == 0) {
colorTransform.redMultiplier = value;
}
else if(_current == 1) {
colorTransform.greenMultiplier = value;
}
else if(_current == 2) {
colorTransform.blueMultiplier = value;
}
else if(_current == 3) {
colorTransform.alphaMultiplier = value;
}
_loader.transform.colorTransform = colorTransform;
}
private function clickHandler(event:MouseEvent):void {
_current++;
if(_current == 4) {
_current = 0;
}
}
}
}