Reusable code AS3

I wrote a simple rectangle gradient. It works fine but i am trying to make it a reusable code. meaning that if i create a traingle or a square or a circle it can use the same code that was created for the rectangle…

package
{
import flash.display.Sprite;
import flash.filters.GlowFilter;
import flash.filters.BevelFilter;
import flash.display.Shape;
import flash.display.GradientType;
import flash.geom.Matrix;

public class Test extends Sprite
{
public function Test()
{
var gf:GlowFilter = new GlowFilter();
gf.alpha = .7;
gf.blurX = 180;
gf.blurY = 180;
gf.color = 0xFFFF00;
gf.inner = true;
gf.quality = 3;
gf.strength = 2;
var gradientType:String = GradientType.RADIAL;
var matrix:Matrix = new Matrix();
matrix.createGradientBox(1280, 1024, 0);
var colors:Array = [0x003299, 0x000000];
var alphas:Array = [1, 1];
var ratios:Array = [0, 255];
var canvas = new Sprite();
canvas.graphics.beginGradientFill(gradientType, colors, alphas, ratios, matrix)
canvas.graphics.drawRect(0, 0, 1280, 1024);
canvas.x = canvas.y = 0;
addChild(canvas);
canvas.filters = [gf];
}
}
}

it should allow you once you create the circle to be able to reuse the same properties but change the gradient color…

Thank you