문제

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?

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top