I just went through this. Here's my code. It's a function that accesses
a stylesheet, so it's got a little more than you need, but I hope it
will help:


function initDrawBg(theTarg)
{
    var gradient_color_1 =
convertColor(_root.defaultStyleSheet.getStyle('.gradient_color_1').color);
    var gradient_color_2 =
convertColor(_root.defaultStyleSheet.getStyle('.gradient_color_2').color);
    var gradient_color_3 =
convertColor(_root.defaultStyleSheet.getStyle('.gradient_color_3').color);

    theTarg.beginGradientFill(
        // gradient type, radial or linear
        "linear",

        // colors, hex
        //[0xff0000,0x00ff00,0x0000ff],
        [gradient_color_1,gradient_color_2,gradient_color_3],

        // alphas (0-100 100 == opaque)
        [100,100,100],

        // ratios (location from 0 to 255, in hex
        [0x00,0x80,0xff],

        // matrix controlling gradient location, size, and rotation (in
radians)
        { matrixType:"box", x:-50, y:0, w:750, h:575, r: 1.9 }
    );

    // draw the bounding box
    theTarg.moveTo(0,0);
    theTarg.lineTo(750,0);
    theTarg.lineTo(750,575);
    theTarg.lineTo(0,575);
    theTarg.lineTo(0,0);
}

// take a string like #ffcc00
// convert it to hex  0xffcc00
function convertColor(color)
{
    return Number("0x" + color.substring(1));
}


Hope this helps,

-steve

On Wed, 2006-01-11 at 00:41, rishi wrote:
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Sumeet
> Kumar
> Sent: Tuesday, January 10, 2006 6:35 PM
> To: Flashcoders mailing list
> Subject: [Flashcoders] Multi Color Gradient
> 
> Hi All,
> 
>  
> 
> I want to create a multicolored gradient dynamically where I can specify
> ratios for each color in my gradient fill.
> 
> Any suggestion will be great help to me 
> 
>  
> 
> 
> 
> Regards
> 
> Sumeet Kumar
> 
>  
> 
> 
> 
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to