SubMenus for Menubar

  • amsteve83
  • Newbie
  • Newbie
  • amsteve83
  • Posts: 9

Post 3+ Months Ago

I have started on my first menubar in Flash.
I have not been able to find the correct code
to make a submenu from a dropdown menu item.
An example is: in my code below in the section titled
products I want to have an arrow and another menu
off of Manufacturer. Can someone please let me in on
the code that does this. I have spend days searching
with no results. And if you would be kind enough,
please check to make sure I have done the listenerObject right.

Code: [ Select ]
var myMenuBar:mx.controls.MenuBar;
var myMenu:mx.controls.Menu;

myMenuBar = this.attachMovie("MenuBar", "menubar_mc", this.getNextHighestDep
th());
myMenuBar._x = 0;
myMenuBar._y = 0;
myMenuBar.setSize(825, 22)

_global.styles.MenuBar = new mx.styles.CSSStyleDeclaration();
_global.styles.MenuBar.setStyle("themeColor","haloOrange");
_global.styles.MenuBar.setStyle("font","arial");

ProdMenu = myMenuBar.addMenu("Products");
ProdMenu.addMenuItem({label:"Manufacturer", instanceName:"manufacturer"});
[b]//right here I want a submenu for manufacturers[/b]
ProdMenu.addMenuItem({label:"Catagories", instanceName:"catagories"});
ProdMenu.addMenuItem({label:"Used Equipment", instanceName:"usedequip"});

ngaMenu = myMenuBar.addMenu("North Georgia Dispatch");
ngaMenu.addMenuItem({label:"Products", instanceName:"ngaproducts"});
ngaMenu.addMenuItem({label:"Coverage Maps", instanceName:"coveragemaps"});
ngaMenu.addMenuItem({label:"Voice & Fleet Dispatch", instanceName:"voiceflee
t"});
ngaMenu.addMenuItem({label:"Vehicle Tracking & Data", instanceName:"tracking
data"});
ngaMenu.addMenuItem({label:"How LTR Works", instanceName:"LTRworks"});


listenerObject = new Object();
listenerObject.change = function(eventObject)
{
switch(eventObject.menuItem.attributes.instanceName)
{
case("manufacturer"):
getURL("/products/manufacturer.aspx", "_blank")
break;
case("catagories"):
getURL("/products/catagories.aspx", "_blank")
break;
case("usedequip"):
getURL("/products/usedequip.aspx", "_blank")
break;
case("coveragemaps"):
getURL("/ngadispatch/coveragemaps.aspx", "_blank")
break;
case("voicefleet"):
getURL("/ngadispatch/voicefleet.aspx", "_blank")
break;
case("trackingdata"):
getURL("/ngadispatch/vehicletrackingdata.aspx", "_blank")
break;
case("ngaproducts"):
getURL("/ngadispatch/ngaproducts.aspx", "_blank")
break;
case("LTRworks"):
getURL("/ngadispatch/ngaLTR.aspx", "_blank")

}
}
this.onResize = function()
{
   myMenuBar.setSize(Stage.width, myMenuBar._height);
};

Stage.scaleMode = "noScale";
Stage.showMenu = false;
Stage.align = "TL";
Stage.addListener(this);

this.onResize();
  1. var myMenuBar:mx.controls.MenuBar;
  2. var myMenu:mx.controls.Menu;
  3. myMenuBar = this.attachMovie("MenuBar", "menubar_mc", this.getNextHighestDep
  4. th());
  5. myMenuBar._x = 0;
  6. myMenuBar._y = 0;
  7. myMenuBar.setSize(825, 22)
  8. _global.styles.MenuBar = new mx.styles.CSSStyleDeclaration();
  9. _global.styles.MenuBar.setStyle("themeColor","haloOrange");
  10. _global.styles.MenuBar.setStyle("font","arial");
  11. ProdMenu = myMenuBar.addMenu("Products");
  12. ProdMenu.addMenuItem({label:"Manufacturer", instanceName:"manufacturer"});
  13. [b]//right here I want a submenu for manufacturers[/b]
  14. ProdMenu.addMenuItem({label:"Catagories", instanceName:"catagories"});
  15. ProdMenu.addMenuItem({label:"Used Equipment", instanceName:"usedequip"});
  16. ngaMenu = myMenuBar.addMenu("North Georgia Dispatch");
  17. ngaMenu.addMenuItem({label:"Products", instanceName:"ngaproducts"});
  18. ngaMenu.addMenuItem({label:"Coverage Maps", instanceName:"coveragemaps"});
  19. ngaMenu.addMenuItem({label:"Voice & Fleet Dispatch", instanceName:"voiceflee
  20. t"});
  21. ngaMenu.addMenuItem({label:"Vehicle Tracking & Data", instanceName:"tracking
  22. data"});
  23. ngaMenu.addMenuItem({label:"How LTR Works", instanceName:"LTRworks"});
  24. listenerObject = new Object();
  25. listenerObject.change = function(eventObject)
  26. {
  27. switch(eventObject.menuItem.attributes.instanceName)
  28. {
  29. case("manufacturer"):
  30. getURL("/products/manufacturer.aspx", "_blank")
  31. break;
  32. case("catagories"):
  33. getURL("/products/catagories.aspx", "_blank")
  34. break;
  35. case("usedequip"):
  36. getURL("/products/usedequip.aspx", "_blank")
  37. break;
  38. case("coveragemaps"):
  39. getURL("/ngadispatch/coveragemaps.aspx", "_blank")
  40. break;
  41. case("voicefleet"):
  42. getURL("/ngadispatch/voicefleet.aspx", "_blank")
  43. break;
  44. case("trackingdata"):
  45. getURL("/ngadispatch/vehicletrackingdata.aspx", "_blank")
  46. break;
  47. case("ngaproducts"):
  48. getURL("/ngadispatch/ngaproducts.aspx", "_blank")
  49. break;
  50. case("LTRworks"):
  51. getURL("/ngadispatch/ngaLTR.aspx", "_blank")
  52. }
  53. }
  54. this.onResize = function()
  55. {
  56.    myMenuBar.setSize(Stage.width, myMenuBar._height);
  57. };
  58. Stage.scaleMode = "noScale";
  59. Stage.showMenu = false;
  60. Stage.align = "TL";
  61. Stage.addListener(this);
  62. this.onResize();

Any help is appreciated.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

This might help you

http://www.actionscript.org/tutorials/intermediate/Dynamic_menu_with_submenus/index.shtml
  • amsteve83
  • Newbie
  • Newbie
  • amsteve83
  • Posts: 9

Post 3+ Months Ago

Thank you for the link, and I will use this style of menu later, but I have a horizontal menubar. I have used the menubar component provided by flash. Is there no code such as
myMenu.addSubMenu({"manufacturer ",instanceName:"manufacturer "})
This is the first time I have used this component but I find it hard to believe it is really that difficult to make a submenu.

Any other suggestions are welcome.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

I don't know of any prebuilt code/classes like that but you could always create your own. :) That tutorial should work for what you want to do you'll just have to move the locations of the sub menus to suit your own layout.
  • amsteve83
  • Newbie
  • Newbie
  • amsteve83
  • Posts: 9

Post 3+ Months Ago

Technically I am trying to make a submenu of a submenu, but thank you for your help.

One last thing, does my Listener object look like it is correct?

Do I have to have an individual listener for every menu item?

Thank you for your suggestions.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 3 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.