View Full Version : Storing clicked menuItem from a V2 menuBar
mrmastermind
April 1st, 2005, 09:05 AM
Is there a way to store the clicked menuItem index of a clicked menuItem on a menuBar component?
I need to be able to create a previous and next button that relates to the currently clicked menuItem of a menuBar. My menuBar dataprovider is an XML file. So I'm thinking it should be possible to show the nextSibling or previousSibling according to the clicked menuItem of a menuBar
Shimi
April 1st, 2005, 10:57 AM
well i found a way to access the class generated XML
and maybe a little trick to store an Index number (because some why their is no index number........)
ok here is my test code:
mn - a menuBar dragged to the stage.
var tmpMn:mx.controls.Menu;
tmpMn = mn.addMenu("Menu1");
tmpMn.addMenuItem({label:"But1",instanceName:"But1",index:1})
tmpMn.addMenuItem({label:"But2",instanceName:"But2",index:2})
tmpMn.addMenuItem({label:"But3",instanceName:"But3",index:3})
var listn:Object = new Object();
listn.change = function(e) {
trace(e.menuItem.attributes.index)
}
tmpMn.addEventListener("change", listn);
first i created a menu with 3 items
if you noticed i added my own attribute called index this is the index we will use to get back when its clicked.
the change event shots when u select an item
so i created the event which gets an attribute i named e
and after the study of it i found out the way to the index attribute we added at first.
thats all i found till now..
mrmastermind
April 5th, 2005, 06:28 AM
Thanks a lot, this might work. I need to add an index to the menu anyway for the folderstructure, so I'll use that.
Strange how one can get stuck on a problem and doesn't find a new way to solve the problem! I was looking at the menuBar and Menu classes to solve it, but this is much easier!
Thanks again!
mrmastermind
April 5th, 2005, 08:11 AM
Hmm, I'm stuck again. Now I've "id-ed" all my menu items like:
<menu-item id="4.0" label="test">
<menu-item id="4.1" label="test1"></menu-item>
<menu-item id="4.2" label="test2"></menu-item>
<menu-item id="4.3" label="test3"></menu-item>
</menu-item>
But now I need to figure out a way to be able to go to the previous or next childNode, depending on the current id attribute. So if the current id was 4.2 How would I tell the button that the previous childNode is the one having id 4.1 and the next childNode is the one having id 4.3 as an attribute?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.