Mouse_OUT and a pop-up menu
Mongo345678 Aug 3, 2011 1:47 PMHey I'm building a basic popup menu from scratch.
I have an MC on my stage (button2) which has certain properties.
What I want is to hover over the button and get a bunch of child buttons appear above the button. This works fine, except I cannot get the mouse_out to work properly on the child buttons. I want to be able to move my cursor across the various child buttons, but when I actually move the cursor outside the container of the child buttons that is when I want them to disappear. Right now what's happening is if I mouse_out from ANY child button, they disappear.
In frame 1, I have the following script:
import flash.display.MovieClip;
stop();
var posY;
var label_num_string:String;
var label_num_first:String;
var label_num_sub:String;
// sets up array to hold sub-menu MC's
var submenus_array:Array = [];
button2.addEventListener(MouseEvent.CLICK, mouseClickHandler);
button2.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
//button2.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
button2.buttonMode = true;
button2.useHandCursor = true;
button2.buttonText.text = "parent button"
button2.buttonText.mouseEnabled = false;
if (button2.submenu == true) {
var submenu:MovieClip = new MovieClip();
submenus_array[2] = submenu;
submenus_array[2].y = button2.y - button2.height;
submenus_array[2].name = "submenu" + i;
posY = 0;
for(var i:uint=1; i<4; i++) {
var bt:MovieClip = new MenuButton();
bt.y = posY;
posY -= bt.button_bg.height;
bt.x = button2.x;
bt.buttonText.text = "child button";
bt.mouseChildren = false;
bt.buttonMode = true;
bt.addEventListener(MouseEvent.CLICK,mouseClickHandler);
//bt.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOver);
//bt.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
submenus_array[2].addChild(bt);
}
}
function mouseClickHandler(e:MouseEvent):void {
//blah
}
function mouseOutHandler(e:MouseEvent):void {
if(stage.contains(submenus_array[2])) {
stage.removeChild(submenus_array[2]);
}
}
function mouseOverHandler(e:MouseEvent):void {
if(stage.contains(submenus_array[2])) {
} else {
stage.addChild(submenus_array[2]);
submenus_array[2].addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
}
}



