The construction of your buttons is not correct for this script.
The nested symbol “red button bg” is the likely culprit; events are propagating through the red and green buttons to this symbol and returning its name “instance3”.
Simply build your buttons from shapes nested in movieclips.
If you need different colored buttons, duplicate the button within the library, and rename it.
You can then open this duplicate symbol and change the color of the nested shape without affecting the other button symbols.
BTW, here’s a simple script based on the same techniques for you to experiment with.
The difference is that the entire project is on frame1 of the main timeline.
[LIST=1]
[]Paste the script on frame1 “actions” layer.
[]Nest your buttons “red” and “green” in a new movieclip “buttonGroup” on it’s own layer on frame1.
[*]Place the “redBox” and “greenBox” movieclips on the stage on separate layers in frame1.
[/LIST]
[COLOR=“Blue”]TweenMax[/COLOR] is required for this script to work.
I promise, you will love TweenMax once you understand how to use it effectively.
stop();
import gs.TweenMax;
import fl.motion.easing.*;
buttonGroup.addEventListener(MouseEvent.CLICK, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.MOUSE_OVER, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.MOUSE_OUT, action, false, 0, true);
buttonGroup.mouseEnabled = false;
buttonGroup.buttonMode = true;
var boxArray:Array = [redBox, greenBox];
TweenMax.allTo(boxArray, 0, {autoAlpha:0, rotation:360, scaleX:.05, scaleY:.05, dropShadowFilter:{color:0x000000, alpha:0, blurX:0, blurY:0, angle:45, distance:0}});
var button:String = "";
function action(event:MouseEvent):void {
button = event.target.name;
switch (event.type) {
case MouseEvent.MOUSE_OVER :
TweenMax.to(event.target, .6, {scaleX:1.3, scaleY:1.3, ease:Elastic.easeOut});
break;
case MouseEvent.MOUSE_OUT :
TweenMax.to(event.target, .6, {scaleX:1, scaleY:1, ease:Cubic.easeOut});
break;
case MouseEvent.CLICK :
TweenMax.allTo(boxArray, .6, {autoAlpha:0, rotation:360, scaleX:.05, scaleY:.05, dropShadowFilter:{color:0x000000, alpha:0, blurX:0, blurY:0, angle:45, distance:0}});
TweenMax.to(event.target, .6, {scaleX:1, scaleY:1, ease:Cubic.easeOut});
switch (button) {
case "red" :
TweenMax.to(redBox, 2.4, {delay:.6, autoAlpha:1, rotation:0, scaleX:1, scaleY:1, ease:Elastic.easeOut, dropShadowFilter:{color:0x000000, alpha:0.5, blurX:4, blurY:4, angle:45, distance:8}, overwrite:true});
break;
case "green" :
TweenMax.to(greenBox, 2.4, {delay:.6, autoAlpha:1, rotation:0, scaleX:1, scaleY:1, ease:Elastic.easeOut, dropShadowFilter:{color:0x000000, alpha:0.5, blurX:4, blurY:4, angle:45, distance:8}, overwrite:true});
break;
}
break;
}
}