Frage

Let's say I have a complex shaped MovieClip with a gradient color (A -> B) on the stage and I want to change the begin and end colors of the gradient at run-time.

Is it possible?

War es hilfreich?

Lösung

If you drew this MovieClip with your mouse it is not possible. If you want to do so, you could have your gradient in a rectangle MovieClip with a mask over it. The mask will have the shape of your current gradient. Then in AS3 you could redraw the gradient in the MovieClip (called gradientZone in the example below).

var matr:Matrix = new Matrix();
matr.createGradientBox(gradientZone.width, gradientZone.height, 0, 0, 0);
gradientZone.graphics.clear();
gradientZone.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x0000FF], [1, 1], [0x00, 0xFF], matr);        
gradientZone.graphics.drawRect(0,0,gradientZone.width, gradientZone.height);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top