Filling a Shape with a Gradient : Shape « Graphics « Flash / Flex / ActionScript






Filling a Shape with a Gradient

 

package{
  import flash.display.*;
  import flash.ui.*;
  import flash.geom.*;
  public class Main extends Sprite{
    public function Main(){
        var sampleSprite:Sprite = new Sprite();
        var matrix:Matrix = new Matrix(  );
        matrix.createGradientBox(100, 100, 0, 50, 50);
        var colors:Array = [0xFF0000, 0x0000FF];
        var alphas:Array = [100, 100];
        var ratios:Array = [0x00, 0xFF];
        sampleSprite.graphics.lineStyle(  );
  //      sampleSprite.graphics.beginGradientFill(GradientType.GRADIENT, colors, alphas, ratios, matrix);
        sampleSprite.graphics.drawCircle(100, 100, 50);
        sampleSprite.graphics.endFill(  );
        addChild(sampleSprite);
    }
  }
}

        








Related examples in the same category

1.Shape Demo
2.Filling Shapes
3.Custom Graphical Classes
4.Filling a Shape with a Solid or Translucent Color