1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
import flash.geom.Transform;
import flash.geom.ColorTransform;
// The listener object.
var listener:Object = new Object();
// When a new color is selected, call the function that changes the color of
// target clip.
listener.onColorSelected = function(evtObj:Object):Void {
changeColor(dessin, evtObj.newColor);
}
sampleMC.addEventListener("onColorSelected", listener);
// Changes the color of the target clip.
function changeColor(targetClip:MovieClip, newColor:Number):Void {
// Create a new ColorTransform object and set it to the
// desired color.
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.rgb = newColor;
// Create a new Transform object that applies transformations
// on the target clip.
var newTrans:Transform = new Transform(targetClip);
newTrans.colorTransform = colorTrans;
} |
Partager