You want to draw a shape and fill it with a gradient at runtime.
Use the beginGradientFill() and endFill() methods to initiate and close a shape drawn at runtime.
A gradient fill is one in which there is a graded change in colors. Flash supports linear gradients, in which one color fades into the next from left to right. (If you want the gradient to change vertically then you can simply rotate the gradient using the matrix transform discussed in this recipe.) Flash also supports radial gradients, in which the colors radiate out from a center point. You can initiate a gradient-filled shape by using beginGradientFill() in the same way that you can initiate a solid-filled shape with beginFill(). The difference is that the call to beginGradientFill() requires a more complex set of parameters:
One of the constants from the flash.display.GradientType class. The
An array of RGB values for the colors to use in the gradient. They are displayed in the gradient from left to right in a linear gradient, or from the center outward in a radial gradient.
An array of alpha values that correspond to the colors in the colors parameter array.
An array whose elements are numbers corresponding to the colors and alphas elements. The values in the ratios array indicate the point within the gradient at which each color is pure. The range of values for the ratios should be from 0 (left-most point ...