Create a Ball by using the Gradient : Gradient « Graphics « Flash / Flex / ActionScript






Create a Ball by using the Gradient

 
package {
import flash.display.GradientType;
import flash.display.Sprite;
import flash.geom.Matrix;

     import flash.display.Sprite;
     
     [SWF(width=550, height=400)]
     
     public class Main extends Sprite {
          
          public function Main() {
               var ball:Ball = new Ball();
               addChild(ball);
          }
          
     }

}
class Ball extends flash.display.Sprite {

     public function Ball() {
          var colors:Array = [];
          var pMatrix:flash.geom.Matrix = new flash.geom.Matrix();
          pMatrix.createGradientBox(70, 70, 0, -20, -10);
          graphics.beginGradientFill(flash.display.GradientType.RADIAL, [0xFF0000,0x330000], [1,1], [0,0xFF], pMatrix);
          graphics.drawCircle(25, 25, 25);
          graphics.endFill();
     }

}

        








Related examples in the same category

1.Line Gradient Test
2.Create Gradient box
3.Applying Gradients to Lines
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