Hey folks, I'm trying to build a class that creates a rounded rectangle with a linear gradient fill (vertical). I think I'm close, but the cigar won't come. Here is the code so far. I'm not sure where I tell flash that I want a rounded rectangle.
I'm hoping someone can help me out here. Here is the code so far:
CODE
package org.keelworks.utils
{
/**
* ...
* @author Thomas Garrod
*/
public class GRecGradient extends Sprite
{
import flash.display.Sprite;
import flash.geom.Matrix;
public var gRecWidth:uint;
public var gRecHeight:uint;
public var xPos:Number;
public var yPos:Number;
public function GRecGradient (grRecWidth:uint, gRecHeight:uint, xPos:Number, yPos:Number)
{
Box();
}
public function Box ()
{
var matrix:Matrix = new Matrix();
trace(matrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0)
matrix.createGradientBox(gRecWidth:uint, gRecHeight:uint, 0, xPos, yPos);
trace(matrix.toString()); // (a=0.1220703125, b=0, c=0, d=0.1220703125, tx=150, ty=150)
var colors:Array = [0xFF0000, 0x0000FF];
var alphas:Array = [100, 100];
var ratios:Array = [25, 255];
var gBox:Sprite = new Sprite;
gBox.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, myMatrix);
addChild(gBox);
}
}
}