Applying Gradients to Lines : Gradient « Graphics « Flash / Flex / ActionScript






Applying Gradients to Lines

 
package
{
    import flash.display.*;
    import flash.geom.Matrix;
    public class Main extends Sprite
    {
        public function Main ()
        {
            var shape:Sprite = new Sprite();
            shape.x = 100;
            shape.y = 100;
    
            var mxBox:Matrix = new Matrix();
            mxBox.createGradientBox(200, 200);
    
            shape.graphics.lineStyle(25);
    
            shape.graphics.lineGradientStyle(GradientType.LINEAR,[0xFFFF00, 0x00FFFF], [100, 100], [0x00, 0xFF], mxBox);
            shape.graphics.curveTo(200, -100, 400, 0);
            shape.graphics.lineTo(400, 200);
            shape.graphics.lineTo(0, 200);
            shape.graphics.lineTo(0, 0);
            shape.graphics.endFill();
            addChild(shape);
        }
    }
}

        








Related examples in the same category

1.Line Gradient Test
2.Create Gradient box
3.Create a Ball by using the Gradient
4.Set line gradient style with Matrix
5.lineGradientStyle("linear", [0xFFFF00, 0x00FFFF], [100, 100], [0x00, 0xFF], mxBox, "reflect", "linearRGB")
6.lineGradientStyle("radial", [0xFFFF00, 0x00FFFF], [100, 100], [0x00, 0xFF], mxBox, "pad", "linearRGB")
7.lineGradientStyle("radial", [0xFFFF00, 0x00FFFF], [100, 100], [0x00, 0xFF], mxBox, "pad", "linearRGB", 1)
8.Applying Gradient Fills
9.A shape with evenly rounded corners
10.Rotating Objects with Filters