Line Gradient Test : Gradient « Graphics « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » Graphics » Gradient 
Line Gradient Test
 
package {
     
     import flash.display.GradientType;
     import flash.display.Shape;
     import flash.display.Sprite;
     
     [SWF(width=550, height=400)]
     
     public class Main extends Sprite {
     
          public function Main() {
               // Create and center ellipse shape on stage
               var ellipse:Shape = new Shape();
               addChild(ellipse);
               ellipse.x = stage.stageWidth / 2;
               ellipse.y = stage.stageHeight / 2;
               
               // Set basic line style
               ellipse.graphics.lineStyle(30);
               
               // Set up gradient properties
               var colors:Array = 
                    [
                         0xFF0000,
                         0xFF6600,
                         0xFFFF00,
                         0x00FF00,
                         0x0000FF,
                         0x2E0854,
                         0x8F5E99
                    ];
               var alphas:Array = [1,1,1,1,1,1,1];
               var ratios:Array = [0,42,84,126,168,210,255];
               
               // Set gradient line style
               ellipse.graphics.lineGradientStyle(GradientType.LINEAR, colors, alphas, ratios);
               
               // Draw ellipse
               ellipse.graphics.drawEllipse(-100, -50200100);
          }
     
     }

}

        
Related examples in the same category
1.Create Gradient box
2.Create a Ball by using the Gradient
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.