PDA

View Full Version : MenuBar hell!!


colfaxrev
05-29-2006, 11:54 PM
my problem is that the menu stops working after any attachMovie() has run.

here's the code I used to make my menu


import mx.controls.Menu;
import mx.controls.MenuBar;

var my_mb:MenuBar;

var my_menu:Menu = my_mb.addMenu("File");
my_menu.addMenuItem({label:"New", instanceName:"newInstance"});
my_menu.addMenuItem({label:"Open", instanceName:"openInstance"});
my_menu.addMenuItem({label:"Close", instanceName:"closeInstance"});
my_menu.addMenuItem({label:"Save", instanceName:"saveInstance"});

var mbListener:Object = new Object();
mbListener.change = function(evt_obj:Object)
{
var menuItem_obj:Object = evt_obj.menuItem;
switch (menuItem_obj.attributes.instanceName)
{
case "newInstance":
var windowProps:Object = {};
windowProps._x = (Stage.width / 2) - 109 - 85;
windowProps._y = (Stage.height / 2) - 100;
_root.attachMovie("window_newLevel", "window_newLevel", 100, windowProps);
break;

case "openInstance":
trace("Open menu item");
break;

case "closeInstance":
trace("Close menu item");
break;

case "saveInstance":
var windowProps:Object = {};
windowProps._x = (Stage.width / 2) - 170 - 85;
windowProps._y = (Stage.height / 2) - 195;
windowProps.myLevelStr = gameMap.saveGrid();
_root.attachMovie("window_save", "window_save", 100, windowProps);
break;
}
//trace(menuItem_obj);
}
//Add listener.
my_menu.addEventListener("change", mbListener);


after those attachMovie things, the pop down menus don't show up!. How do i fix this?!?

colfaxrev
05-30-2006, 12:02 AM
im not trying to bump my post, but this problem is the only thing stopping me from completing my project!

I NEED to be able to use attachMovie, so there MUST be a workaround!

I had a weird problem like this before, and I had to put an instance of a comboBox off the stage to fix the problem.

so maybe there's a weird fix for this problem like that? or maybe im just doing something wrong...

please help! :eek:

colfaxrev
05-30-2006, 12:05 AM
I got it! I just had to dynamically attach the menu as well...

thanks anyway!