[sourcecode language="actionscript3"]
var gradientScaling:Number = 1 ; // use this for easy scaling of the gradient
var gradientMatrixWidth:Number = 50 * gradientScaling ;
var gradientMatrixHeight:Number = 50 * gradientScaling ;
var gradientMatrixRotation:Number = 0.00 ;
var gradientTx:Number = 0 * gradientScaling ;
var gradientTy:Number = 0 * gradientScaling ;
var gradientDrawWidth:Number = 50 * gradientScaling ;
var gradientDrawHeight:Number = 50 * gradientScaling ;
var gradientOffsetX:Number = 0 ; // use this to move the gradient horizontally
var gradientOffsetY:Number = 0 ; // use this to move the gradient vertically
var gradientMatrix:Matrix = new Matrix ( ) ;
gradientMatrix.createGradientBox ( gradientMatrixWidth, gradientMatrixHeight, gradientMatrixRotation, gradientTx + gradientOffsetX, gradientTy + gradientOffsetY) ;
var gradientType:String = GradientType.LINEAR ;
var gradientColors:Array = [0xff0000, 0xff]
var gradientAlphas:Array = [1, 1]
var gradientRatios:Array = [0, 255]
var gradientSpreadMethod:String = SpreadMethod.PAD ;
var gradientInterpolationMethod:String = InterpolationMethod.RGB ;
var gradientFocalPoint:Number = 0 ;
var gradientGraphics:Graphics = this.graphics; // replace 'this' with the object you want to apply the gradient to
gradientGraphics.beginGradientFill ( gradientType, gradientColors, gradientAlphas, gradientRatios, gradientMatrix, gradientSpreadMethod, gradientInterpolationMethod, gradientFocalPoint ) ;
gradientGraphics.drawRect ( gradientOffsetX, gradientOffsetY, gradientDrawWidth ,gradientDrawHeight ) ;
gradientGraphics.endFill ( ) ;
/*######################
* REMEMBER THESE IMPORTS
* ######################
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.InterpolationMethod;
import flash.display.SpreadMethod;
import flash.geom.Matrix;
*/
[/sourcecode]