Gradient fill problem

Hi
Can I use a gradient fill as a color.

I want to have a dynamic text box with a gradient fill as the background color. Anybody have any ideas as to how I can do this? If its possible I would imagine I have to use backgroundcolor property.

You will have to create a rectangle in the layer below it. That rectangle will have to have the gradient fill.

I don’t know of a way to make the background of the textbox itself a gradient.

Although be care, a lot of times, text is hard to read on a gradient, so choose your colors wisely.

use Flash’s drawing API
assuming “dt” is the instance name of your dynamic text field (or input for that matter)


matrix = {matrixType:"box", x:dt._x, y:dt._y, w:dt._width, h:dt._height, r:Math.PI/2}; 
beginGradientFill("linear", [0x444444,0xeeeeee], [100,100], [0,255], matrix);
moveto(dt._x,dt._y);
lineto(dt._x+dt._width, dt._y);
lineto(dt._x+dt._width, dt._y+dt._height);
lineto(dt._x, dt._y+dt._height);
lineto(dt._x, dt._y);
endFill();

will make a grey to grey gradient down the height of the text field. The colors are specified in [0x888888,0xeeeeee], which you can easily change, and if you want the gradient direction, change r: in the matrix which is the angle in radians. Now its at Pi/2 which is 90 degrees or down, if you want it across, you can make it 0.

So basically what this does is draws a box to match the dimensions of the textfield and gives the box a gradient fill. Its not the ‘actual’ background of the textfield which you could set to any given solid color with TextField.backgroundColor, but rather its a dynamically drawn box behind the text field to match it and act as a backdrop

Many thanks…just what i was looking for.