varPBR:Tasty
04-10-2008, 03:16 PM
Hello,
I've created a number of buttons and pushed them into an array, then to each element I've added a set of parameters, including a MOUSE_OVER listener. The function called by the MOUSE_OVER listener includes a MOUSE_OUT listener, to call another function, but I can't get it to operate the way I want it to (the do...while is not working)—instead of fading out, the alpha just drops to zero.
I suspect this is because I am referencing the target object, but when the mouse rolls out, there essentially is no longer a target object.
Could anyone look at this and give me a hint as to how I can program an OUT listener for elements pushed into an array such as this?
var buttonArray:Array = [frontB, aboveB, sideB, closeB, homeB, productsB, contactB];
for each(var navButton:MovieClip in buttonArray){
navButton.scaleY = 16;
navButton.buttonMode = true;
navButton.addEventListener(MouseEvent.MOUSE_OVER, buttonHighlight);
navButton.alpha = 0;
addChild(navButton);
}
//navigation button functions
function buttonHighlight(e:MouseEvent):void{
e.target.alpha = .25;
e.target.addEventListener(MouseEvent.MOUSE_OUT, fadeHighlight);
}
function fadeHighlight(e:MouseEvent):void{
do{
e.target.alpha -=.2;
} while(e.target.alpha >0);
}
Thanks!
varPBR
I've created a number of buttons and pushed them into an array, then to each element I've added a set of parameters, including a MOUSE_OVER listener. The function called by the MOUSE_OVER listener includes a MOUSE_OUT listener, to call another function, but I can't get it to operate the way I want it to (the do...while is not working)—instead of fading out, the alpha just drops to zero.
I suspect this is because I am referencing the target object, but when the mouse rolls out, there essentially is no longer a target object.
Could anyone look at this and give me a hint as to how I can program an OUT listener for elements pushed into an array such as this?
var buttonArray:Array = [frontB, aboveB, sideB, closeB, homeB, productsB, contactB];
for each(var navButton:MovieClip in buttonArray){
navButton.scaleY = 16;
navButton.buttonMode = true;
navButton.addEventListener(MouseEvent.MOUSE_OVER, buttonHighlight);
navButton.alpha = 0;
addChild(navButton);
}
//navigation button functions
function buttonHighlight(e:MouseEvent):void{
e.target.alpha = .25;
e.target.addEventListener(MouseEvent.MOUSE_OUT, fadeHighlight);
}
function fadeHighlight(e:MouseEvent):void{
do{
e.target.alpha -=.2;
} while(e.target.alpha >0);
}
Thanks!
varPBR