Ciao ragazzi, avevo del codice per fare un'animazione per cambiare colore con ColorMatrixFilter.
Mi funziona bene, ma io ho provato a farne una funzione e non mi funziona, dove sbaglio??
Mi potete aiutare??
codice originale funzionante
Qui ho provato a metterlo in una funzione... dove sbaglio???Codice PHP:import flash.filters.*;
import mx.transitions.Tween;
import mx.transitions.easing.Regular;
var matrix:Array = [1, 0, 0, 0, 255, 0, 1, 0, 0, 255, 0, 0, 1, 0, 255, 0, 0, 0, 1, 0];
mc.filters = [new ColorMatrixFilter(matrix)];
var tw:Tween = new Tween(matrix, "4", Regular.easeIn, 255, 0, 1, true);
tw.addListener(this);
function onMotionChanged(t:Tween) {
matrix[9] = matrix[4];
matrix[14] = matrix[4];
mc.filters = [new ColorMatrixFilter(matrix)];
}
Codice PHP:import flash.filters.*;
import mx.transitions.Tween;
import mx.transitions.easing.Regular;
MovieClip.prototype.grigio = function() {
var matrix:Array = [1, 0, 0, 0, 255, 0, 1, 0, 0, 255, 0, 0, 1, 0, 255, 0, 0, 0, 1, 0];
this.filters = [new ColorMatrixFilter(matrix)];
var tw:Tween = new Tween(matrix, "4", Regular.easeIn, 255, 0, 1, true);
tw.addListener(this);
function onMotionChanged(t:Tween) {
matrix[9] = matrix[4];
matrix[14] = matrix[4];
this.filters = [new ColorMatrixFilter(matrix)];
}
}
mc.grigio();

Rispondi quotando