  | |  | MenuBar on change cannot be trigerred | MenuBar on change cannot be trigerred 2004-03-13 - By Sajid Saiyed
Back Hey Doug, You are great :)
Perfect solution.
thanks sajid
-- --Original Message-- -- From: Doug Coning [mailto:DougC@(protected)] Sent: Saturday, March 13, 2004 4:03 AM To: flashcoders@(protected) Subject: RE: [Flashcoders] MenuBar on change cannot be trigerred
I too wasn't able to get it to work. However the following does work for me, create a new docoument and add the following:
1) Add a menuBar called myMenuBar.
2) Add this script to the main timeline:
SCRIPT: import mx.controls.Menu; import mx.controls.MenuBar; var myMenuBar:MenuBar; var menuBar_xml:XML = new XML(); menuBar_xml.load("Menu.xml"); menuBar_xml.ignoreWhite = true; menuBar_xml.onLoad = function(success) { if (success) { myMenuNodes = menuBar_xml.firstChild; numChildren = myMenuNodes.childNodes.length; myMenuBar.dataProvider = myMenuNodes; for(var i = 0; i<numChildren;i++){ set("menu_" + i, myMenuBar.getMenuAt(i)); eval("menu_" + i).addEventListener("change", fileListener); if(i>3000){ trace("B R E A K : menuBar_xml"); break; } } } else { trace("error in loading menuBar_xml"); } }; var fileListener:Object = new Object(); fileListener.change = function(eventObj : Object) : Void { trace("Menu item chosen: "+eventObj.menuItem.attributes.instanceName); }
3) Create this XML: <?xml version="1.0" encoding="iso-8859-1"?> <root> <menu label = "File"> <menuItem label = "New" instanceName = "newInstance"/> <menuItem label = "Open" instanceName = "openInstance"/> <menuItem label = "Open Recent"> <openItem label = "CSAUTO" instanceName = "recent1Instance"/> <openItem label = "LOAN" instanceName = "recent2Instance"/> <openItem label = "JOINT" instanceName = "recent3Instance"/> <openItem label = "PERSONAL" instanceName = "recent4Instance"/> </menuItem> <menuItem label = "Close" instanceName = "closeInstance"/> <menuItem type = "separator"/> <menuItem label = "Save" instanceName = "saveInstance"/> <menuItem label = "SaveAs" instanceName = "saveAsInstance"/> <menuItem type = "separator"/> <menuItem label = "Print" instanceName = "printInstance"/> <menuItem type = "separator"/> <menuItem label = "Exit" instanceName = "exitInstance"/> </menu> <menu label = "Edit"> <menuItem label = "Undo" enabled = "false" instanceName = "undoInstance"/> <menuItem type = "separator"/> <menuItem label = "Preferences" instanceName = "preferencesInstance"/> </menu> </root>
-- ---- ---- ------
Hope this works for you!
Doug Coning Software Developer FORUM Solutions, LLC
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Supported by Fig Leaf Software =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Be sure to check the archives and the wiki: http://chattyfig.figleaf.com/ =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106818 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Supported by Fig Leaf Software =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Be sure to check the archives and the wiki: http://chattyfig.figleaf.com/ =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106827 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |