# Animating Gradient?

**URL:** <https://forum.kirupa.com/t/animating-gradient/217329>\
**Category:** flash\
**Created:** [February 26, 2007, 1:42am UTC](https://forum.kirupa.com/t/animating-gradient/217329 "2007-02-26T01:42:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hunson](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@Hunson](https://forum.kirupa.com/u/Hunson)\
**Post date:** [February 26, 2007, 1:42am UTC](https://forum.kirupa.com/t/animating-gradient/217329/1 "2007-02-26T01:42:47Z")

</div>

here the script i use to generate a gradient as the background:

if (bgcolor == 5) {  
wSize = 1500;  
hSize = 1200;  
fillType = “linear”;  
colors = [0xAEAE00, 0xEEEE00];  
alphas = [100, 100];  
ratios = [0, 255];  
matrix = {matrixType:“box”, x:0, y:0, w:wSize, h:hSize, r:90/180\*Math.PI};  
\_root.lineStyle(1, 0xFFFFFF, 0);  
\_root.beginGradientFill(fillType, colors, alphas, ratios, matrix);  
\_root.lineTo(wSize, 0);  
\_root.lineTo(wSize, hSize);  
\_root.lineTo(0, hSize);  
\_root.lineTo(0, 0);  
\_root.endFill();  
bgcolor = 0;  
}

problem is, if i change the gradient using the “bgcolor” variable, like if bgcolor is a different number, different gradient will appear, the colours just replaced each other.

is there a way to make it animate smoothly?  
example here:  
[http://lab.mathieu-badimon.com/](http://lab.mathieu-badimon.com/)

check out the background, please help!
