hi i am designing a portfolio website and i have multiple objects that are positioned on top of each other and on CLICK events there alpha rises to be visible but i also want to arrange them to be the object at the very FRONT of the other objects on the stage so that the mouse overs for them function correctly. and i wondered if there was a way to change the arrangement of an item on stage to bring it to the FRONT via actionscript? thanks in advance for the help.
i think it might have sommit to do with switching the depths of the items but im not sure how to do that in actionscript 3 lol!
This script sets the event.target as the top-most object.
The relevant code is in the MOUSE_OVER function:
[COLOR=“Blue”]buttonGroup.setChildIndex(event.target as MovieClip, buttonGroup.numChildren-1);[/COLOR]
[QUOTE=anix;2343230]i think it might have sommit to do with switching the depths of the items but im not sure how to do that in actionscript 3 lol![/QUOTE]
stop();
import gs.TweenMax;
import fl.motion.easing.*;
buttonGroup.addEventListener(MouseEvent.MOUSE_OVER, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.MOUSE_OUT, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.CLICK, action, false, 0, true);
buttonGroup.mouseEnabled = false;
var button:String = "";
function action(event:MouseEvent):void {
button = event.target.name;
switch (event.type) {
case MouseEvent.MOUSE_OVER :
buttonGroup.setChildIndex(event.target as MovieClip, buttonGroup.numChildren-1);
TweenMax.to(event.target, 2, {scaleX:1.5, scaleY:1.5, ease:Elastic.easeOut});
break;
case MouseEvent.MOUSE_OUT :
TweenMax.to(event.target, 2, {scaleX:1, scaleY:1, ease:Elastic.easeOut});
break;
case MouseEvent.CLICK :
TweenMax.to(event.target, .5, {scaleX:1, scaleY:1, ease:Cubic.easeOut});
break;
}
}