ColorMatrixFilter
import flash.filters.ColorMatrixFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
System.security.allowDomain("http://www.helpexamples.com");
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip):Void {
// center movie clip instance on Stage
target_mc._x = (Stage.width - target_mc._width) / 2;
target_mc._y = (Stage.height - target_mc._height) / 2;
target_mc.watch("brightness", brightnessWatcher, target_mc);
// animate the target_mc movie clip between -100 and +100 brightness
var myTween:Tween = new Tween(target_mc, "brightness", Elastic.easeOut, 100, -100, 3, true);
myTween.onMotionFinished = function() {
this.yoyo();
};
};
this.createEmptyMovieClip("img_mc", 10);
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mclListener);
img_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", img_mc);
function brightnessWatcher(prop:String, oldVal:Number, newVal:Number, target_mc:MovieClip):Number {
var brightness_array:Array = [1, 0, 0, 0, newVal,
0, 1, 0, 0, newVal,
0, 0, 1, 0, newVal,
0, 0, 0, 1, 0];
target_mc.filters = [new ColorMatrixFilter(brightness_array)];
return newVal;
};
import mx.transitions.Tween;
import mx.transitions.easing.*;
System.security.allowDomain("http://www.helpexamples.com");
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip):Void {
// center movie clip instance on Stage
target_mc._x = (Stage.width - target_mc._width) / 2;
target_mc._y = (Stage.height - target_mc._height) / 2;
target_mc.watch("brightness", brightnessWatcher, target_mc);
// animate the target_mc movie clip between -100 and +100 brightness
var myTween:Tween = new Tween(target_mc, "brightness", Elastic.easeOut, 100, -100, 3, true);
myTween.onMotionFinished = function() {
this.yoyo();
};
};
this.createEmptyMovieClip("img_mc", 10);
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mclListener);
img_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", img_mc);
function brightnessWatcher(prop:String, oldVal:Number, newVal:Number, target_mc:MovieClip):Number {
var brightness_array:Array = [1, 0, 0, 0, newVal,
0, 1, 0, 0, newVal,
0, 0, 1, 0, newVal,
0, 0, 0, 1, 0];
target_mc.filters = [new ColorMatrixFilter(brightness_array)];
return newVal;
};
댓글