I have this gradient backgroun where it goes from 0-100-0 of alpha.
When I rollover a button, I add in the bg, and when i rollout of the bg, i remove it.
The problem now is when I rollover the button the 2nd time,
it seems like the bg added already have a previous added gradient bg, and it added a new 1 on top.
so each time I rollover the button the alpha of the gradient will go higher
exp:
1st time rollover:0-100-0
2nd time rollover:10-100-10
3rd time rollover:20-100-20
etc.
what could be the problem here?
private function bgGlow(event:Object):void {
square.visible=true;
//Disable menu below
event.parent.button.visible=false;
// Glowing Background
var type:String=GradientType.LINEAR;
var colors:Array=[0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF];
var alphas:Array=[0,1,1,1,0];
var ratios:Array=[0,50,155,180,255];
var spreadMethod:String=SpreadMethod.PAD;
var interp:String=InterpolationMethod.LINEAR_RGB;
var focalPtRatio:Number=0;
var matrix:Matrix = new Matrix();
var boxWidth:Number=145;
var boxHeight:Number=500;
var boxRotation:Number=Math.PI/2;// 90¡ã
var tx:Number=0;
var ty:Number=0;
matrix.createGradientBox(boxWidth, boxHeight, boxRotation, tx, ty);
square.graphics.beginGradientFill(type,
colors,
alphas,
ratios,
matrix,
spreadMethod,
interp,
focalPtRatio);
square.graphics.drawRect(0, 0, 145, 600);
square.x=event.parent.x;
square.y=-320;
addChild(square);
this.buttonMode=true;
this.addEventListener(MouseEvent.ROLL_OUT,btnOut);
}
private function btnOut(event:MouseEvent):void {
//Enable menu button
event.target.menuArray[0].button.visible=true;
event.target.menuArray[1].button.visible=true;
event.target.menuArray[2].button.visible=true;
event.target.menuArray[3].button.visible=true;
event.target.menuArray[4].button.visible=true;
removeChild(square);
removeEventListener(Event.ENTER_FRAME,bgGlow);
}
I also tried remove the whole function but it doesnt seems to work too.
And how do I combine the array functions?