hi everyone. im new to the forum, and flash/actionscript 2, so let me know if im doing something wrong. anyway heres my question. im creating a card game. i have a seperate timeline for the menu bar. ive placed this code on the first cell of the timeline:
ActionScript Code:
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 Game", instanceName:"newInstance"});
my_menu.addMenuItem({label:"Reset Cards", instanceName:"openInstance"});
my_menu.addMenuItem({label:"Close", instanceName:"closeInstance"});
my_menu.addMenuItem({label:"Deal New Row", instanceName:"newRow"});
//Create listener object.
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":
_root.gotoAndStop(10);
break;
case "openInstance":
ResetCards();
break;
case "closeInstance":
break;
case "newRow":
dealNewRow();
break;
}
};
my_menu.addEventListener("change", mbListener);
the problem i get is that when the user selects "new game" it should restart the game. when it does this the toolbar is not reset. instead a new menu item is added (without removing the old one. so evertime the user hits new game, a new "file" menu is added). how do i make sure there is only 1 "File" menu?