Brian Chia
       
 
categories
actionscript
actionscript 1.0
actionscript 2.0
misc
 
processing
 
links
brian chia
kelvin zhao
ronald leong
 
 
ColorMatrixFilter v01
 
I use the 4 x 5 matrix (ColorMatrixFilter) (ba) to modify the brightness of the movieclip.

1 0 0 0 nV
0 1 0 0 nV
0 0 1 0 nV
0 0 0 1 0 (where nV is between -255 and 255)

In this example, i use the Object.watch() method registers an event handler (brightness) to be invoked when a specified property (xV) of an object changes.



import flash.filters.ColorMatrixFilter;

//function to be invoked if the yV changes
var brightness:Function=function(p:String,oV:Number,nV:Number,mc:MovieClip):Number {

var ba:Array=new Array();

//animate movieclip brightness (nV) between 0 to 255
ba=[1, 0, 0, 0, nV,
        0, 1, 0, 0, nV,
        0, 0, 1, 0, nV,
        0, 0, 0, 1, 0];

//apply ColorMatrixFilter
mc.filters=[new ColorMatrixFilter(ba)];
return nV;

}

with(drag_mc){

//add property to be watched
xV=_x-line_mc._x;
//Object.watch() method register the event handler and property to watch
watch("xV", brightness, img_mc);

}



suggestion

 
 
 
         
  © copyright 2007 THINKLUNATIC.    
Brian Chia Jonathan Ng