Using the beginGradientFill function

Hello I am new to this forum and also new to programming in actionscript 3. Please pardon me if any of the questions I ask sound very noobiesh because it probably is.

I have a piece of code that attempts to apply a gradient affect onto a shape. the shape is an instance of a movie clip, which was created and saved onto a .swf file.

Inside my code, I grab this shape from the .swf file and pass this object into the function. The function then applies the gradient affect onto the shape object. Here is what my code looks like:

protected function convertToSkinColor(target:MovieClip, skinColor:String){

var fillType:String = GradientType.LINEAR;
var colors:Array;
var alphas:Array;
var ratios:Array;
var gradMatrix:Matrix;
var spreadMethod:String = SpreadMethod.PAD;

colors = [skinColor, 0x00ggdd, 0x00ggfe]
alphas = [100, 100, 100];
ratios = [204, 229, 247];
gradMatrix = new Matrix();
gradMatrix.createGradientBox(target.width, target.height, 0, 0, 0);
target.graphics.clear();

target.graphics.beginGradientFill(fillType, colors, alphas, ratios, gradMatrix, spreadMethod);
target.graphics.drawRect(0,0,target.width,target.h eight);
target.graphics.endFill();
}

target is the shape being passed into the function. When I run the code, the gradient is created but it is not being applied onto the shape. the whole gradient sits underneath the shape object.

So if I modified target.width and target.height to greater size than the shape’s dimensions, I can see edges of the gradient comming off from the edges of the shape. Just picture a smaller circle sitting on top of a larger circle.

How do I get the gradient to be applied onto the shape? The shape has its own colors.