PDA

View Full Version : Menu Problem


ravidon
03-16-2005, 01:02 PM
Hi to all,
I have created a menu by writing the code,I mean menu items are created by using action script. Can I crete the menu items using XML,If so how can I?
please post the fla and xml file.And also how to link after clicking the item.
Please help me.


code: ..................................


var myMenu = mx.controls.Menu.createMenu();
myMenu.setStyle("color","0x167b11");
myMenu.setStyle("fontWeight","bold");
myMenu.setStyle("textRollOverColor","0x167b11");
myMenu.setStyle("backgroundColor","0x9eeb9c");

myMenu.addMenuItem({label: "Quick Demo Overview"});

b1=myMenu.addMenuItem({label: "Company Sign Up" });
b1.addMenuItem({label: "Sign Up-Step1" });
b1.addMenuItem({label: "Sign Up-Step2" });

b2=myMenu.addMenuItem({label: "Payrun Admin Sign In" });
b2.addMenuItem({label: "Payrun Admin Sign In" });
b2.addMenuItem({label: "Retrieve Sign In Id" });
b2.addMenuItem({label: "Retrieve Password" });
b2.addMenuItem({label: "Retrieve Pattern word" });
b2.addMenuItem({label: "Retrieve all Sign in Details"});

b3=myMenu.addMenuItem({label: "Employer/Setup" });
b31=b3.addMenuItem({label: "Chart of Setup" });
b32=b3.addMenuItem({label: "Pension Details" });
b33=b3.addMenuItem({label: "Payrun Admin Internet Details" });

b31.addMenuItem({label: "Pay Period Setup" });
b31.addMenuItem({label: "PayRun Customisation" });
b31.addMenuItem({label: "Payment Setup" });
b31.addMenuItem({label: "Absence Admin & Payment" });
b31.addMenuItem({label: "Deduction Setup" });
b31.addMenuItem({label: "Department Setup" });
b31.addMenuItem({label: "Working Day Pattern Setup" });
b31.addMenuItem({label: "Holiday Scheme Setup" });
b31.addMenuItem({label: "Cost Center Setup" });

b32.addMenuItem({label: "Pension Providers" });
b32.addMenuItem({label: "COMP Pension Scheme" });
b32.addMenuItem({label: "COSR Pension Scheme" });
b32.addMenuItem({label: "FSAVC/GPP/PPP Scheme" });
b32.addMenuItem({label: "Stake Holder Pension" });

b33.addMenuItem({label: "Sign In Log Book" });
b33.addMenuItem({label: "Change E-Mail Address" });
b33.addMenuItem({label: "Change Password" });
b33.addMenuItem({label: "Change Pattern Word" });
b33.addMenuItem({label: "Change Security Question" });


b4=myMenu.addMenuItem({label: "Payrun Process" });
b4.addMenuItem({label: "Payrun" });
b4.addMenuItem({label: "Basic Pay Calculation"});
b41=b4.addMenuItem({label:"Other Pay Admin"});
b42=b4.addMenuItem({label:"Deduction & Pension Admin"});
b4.addMenuItem({label: "VAP Error and Setup" });
b4.addMenuItem({label: "Pay at AnyTime" });

b41.addMenuItem({label: "Holiday Payment" });
b41.addMenuItem({label: "Other Pay Items" });
b41.addMenuItem({label: "Absence Admin & Payment" });
b41.addMenuItem({label: "Tax Credits" });
b41.addMenuItem({label: "SSP Record & Payment" });
b41.addMenuItem({label: "SMP Record & Payment " });
b41.addMenuItem({label: "SAP Record & Payment " });
b41.addMenuItem({label: "SPP Birth Record & Payment " });
b41.addMenuItem({label: "SPP Adoption Record & Payment " });

b42.addMenuItem({label: "Deduction Item " });
b42.addMenuItem({label: "Pension Deduction " });
b42.addMenuItem({label: "Student Loan " });
b42.addMenuItem({label: "Attachment Order" });



b5=myMenu.addMenuItem({label: "Employee Internet A/C" });
b51=b5.addMenuItem({label:"Create EE Payroll Internet A/C"});
b52=b5.addMenuItem({label:"Manage EE Internet A/C"});
b53=b5.addMenuItem({label:"Forgot Sign In Details"});
b54=b5.addMenuItem({label:"EE Internet Access Rights"});
b55=b5.addMenuItem({label:"View/Edit EE Details"});
b56=b5.addMenuItem({label:"Add New Employee"});

b51.addMenuItem({label: "From add new EE" });
b51.addMenuItem({label: "Through View/Edit EE" });
b51.addMenuItem({label: "Through Enable Internet A/C" });
b51.addMenuItem({label: "From EE Internet A/C" });
b51.addMenuItem({label: "From EE Access Rights" });

b52.addMenuItem({label: "Disable EE Internet A/c" });
b52.addMenuItem({label: "Reactivate EE Internet A/c" });
b52.addMenuItem({label: "Edit EE Internet A/c" });
b52.addMenuItem({label: "On Reset EE " });

b53.addMenuItem({label: "Retrieve Sign In Id" });
b53.addMenuItem({label: "Retrieve Password" });
b53.addMenuItem({label: "Retrieve Pattern word" });
b53.addMenuItem({label: "Retrieve all Sign in Details"});

b54.addMenuItem({label: "Self Update Phone & Address" });
b54.addMenuItem({label: "Self Admin P11D" });
b54.addMenuItem({label: "Timesheet Entry" });
b54.addMenuItem({label: "Expense Entry"});

b55.addMenuItem({label: "Personal Details" });
b55.addMenuItem({label: "Internet A/C Details" });
b55.addMenuItem({label: "Other Details" });

b56.addMenuItem({label: "Existing EE-Process Pay" });
b56.addMenuItem({label: "Existing EE-Migrate Data" });
b56.addMenuItem({label: "New Joiner-Form P45" });
b56.addMenuItem({label: "New Joiner-Form P46"});
b56.addMenuItem({label: "Joiner without Form P45-P46"});

b6=myMenu.addMenuItem({label: "Finance/Payment" });
b6.addMenuItem({label: "Pay Example"});
b6.addMenuItem({label: "Payment to IR"});

b7=myMenu.addMenuItem({label: "Auto TAX Code Change" });
b7.addMenuItem({label: "Annual Global Tax Code"});
b7.addMenuItem({label: "In Year Individual Tax Code"});

b8=myMenu.addMenuItem({label: "e-Filing/EOY Process" });
b8.addMenuItem({label: "e-File P45 & P46"});
b8.addMenuItem({label: "e-File p38A"});
b8.addMenuItem({label: "EOY Approval Process"});
b8.addMenuItem({label: "e-File EOY Documents"});


myMenu.show(0,0);

Jotun75
03-16-2005, 01:14 PM
If you lookup menu in the help panel in flash. There is more than enough information for you to figure this out by yourself.

There is even a xml exsample there too, and it also describes how to apply the xml to the menu.

I suggest you start there :)

Xeef
03-16-2005, 01:40 PM
//you need to have a menubar in the library
//you also can place it by hand on the stage
//and let the next 2 lines of code away
//don't forget to give it the proper instance name
import mx.controls.MenuBar;
MENU = createClassObject(MenuBar, "Menu", 1);
xml = new XML();
xml.load("Menu.xml");
xml.ignoreWhite = true;
xml.onLoad = function() {
MENU.dataProvider = this.childNodes[0];
};
listener = new Object();
listener.change = function(evt) {
trace("Menu item chosen: "+evt.menuItem.attributes.label);
};
MENU.addEventListener("change", listener);



<menu>
<menuitem label="FunctionS" Vector="0" >
<menuitem label="RunEr" Vector="0_1" Type="R,CB" List="" Provider="0,LogicObjS" Edit="0,1"/>
<menuitem label="Loop" Vector="0_2" />
<menuitem label="While" Vector="0_3" />
<menuitem label="If" Vector="0_4" />
</menuitem>
<menuitem label="ValueS" Vector="1" >
<menuitem label="V_Hard" Vector="1_1" Type="CB" List="_x,_y,_xscale,_yscale" />
<menuitem label="V_Global" Vector="1_2" Type="CB" List="" Provider="GlobalVar" Edit="2" />
<menuitem label="V_Local" Vector="1_3" />
</menuitem>
</menu>

ravidon
03-17-2005, 04:44 AM
//you need to have a menubar in the library
//you also can place it by hand on the stage
//and let the next 2 lines of code away
//don't forget to give it the proper instance name
import mx.controls.MenuBar;
MENU = createClassObject(MenuBar, "Menu", 1);
xml = new XML();
xml.load("Menu.xml");
xml.ignoreWhite = true;
xml.onLoad = function() {
MENU.dataProvider = this.childNodes[0];
};
listener = new Object();
listener.change = function(evt) {
trace("Menu item chosen: "+evt.menuItem.attributes.label);
};
MENU.addEventListener("change", listener);


Thank you Xeef.


But I want Vertical Menubar Instead of Horizontal.How can I achieve that?

Xeef
03-17-2005, 09:01 AM
Hmmm not sure but i think you will need to write the hole menu your self
the MM components not like if they are rotated in any way

reyco1
03-17-2005, 11:41 AM
that listener dont work...

Xeef
03-17-2005, 12:57 PM
Hmmm i have this infornt of me in flash and it's working fine !

reyco1
03-18-2005, 02:27 AM
can you post the fla? maybe i'm doing something wrong

CyanBlue
03-18-2005, 03:06 AM
I just copied that code and tested it after dragging the menuBar component onto the stage and deleting it... It works for me... :)

reyco1
03-18-2005, 03:18 AM
It gets populated, but does the listener work?
It doesn't for me :(

CyanBlue
03-18-2005, 05:07 AM
I don't know what you've read, but I said it works for me and that means that Xeef's code works perfectly as usual...

I just noticed that this is the crosspost... DO NOT CROSSPOST!!!

Chewie
10-03-2005, 12:17 PM
Hi guys

I have been trying to get this populating a menubar with xml data for the last couple of days now. I have 4 books on actionscript been to several web sites, tried examples but am having the same problem. The menu is constructed no problems but clicking the buttons and nothing - no trace output.

I have just copied and pasted xeef's xml file and actionscript code. I have dragged the menubar to the stage and deleted it so that it is in the library. As far as I can tell I have done everything I am supposed to do. The menu looks great, but the buttons do nothing.

Please help me :o

Chewie
10-03-2005, 01:15 PM
Finally I have it working.

Extract from Flash MX2004 actionscript bible.

Although the documentation says that the menubar component dispatches events, it does not seem to work as described. Instrad, it appears you need to add an event listener to each of the nested menu instances.

Here is the code that works


var xmlMenuData:XML = new XML();
xmlMenuData.onLoad = function() {
cmbMenus.dataProvider = this.firstChild;
setListeners();
};
xmlMenuData.ignoreWhite = true;
xmlMenuData.load("menubar.xml");
//
function setListeners():Void {
var nIndex:Number = 0;
var cmMenu:mx.controls.Menu = cmbMenus.getMenuAt(nIndex);
while (cmMenu != undefined) {
cmMenu.addEventListener("change", oListener);
cmMenu = cmbMenus.getMenuAt(++nIndex);
}
}
//
var oListener:Object = new Object();
oListener.change = function(oEvent:Object) {
trace(oEvent.menuItem);
};

Hope this helps people out as I have spent days on this