Post edited 1:15 pm – May 15, 2009 by smonte
Post edited 1:16 pm – May 15, 2009 by smonte
Hey Kemipso,
You could also do the whole thing with e.target. I personally think the code is easier to read with variable names that make sense. That's why I usually save the target to a local variable. But either way works, so do what's best for you! And code Kemipso is talking about:
//This function is called when the mouse is over a button
function mouseOverButton(e:Event):void {
//Assign the button to a local variable
var button:MovieClip = (MovieClip)(e.target);
//Calculate the new target width and height for the buttonBackground
var targetWidth:Number = button.width + 10;
var targetHeight:Number = button.height + 10;
//Tween the buttonBackground's position, size and color (color is random)
TweenMax.to(buttonBackground, 0.5, {x: button.x, y: button.y,
width:targetWidth, height:targetHeight, tint: Math.random() * 0xffffff});
}