Reputation: 10668
i go through the code several times but can not figure out the problem help required here is the code;
menuItems = [{label:"60 Minutes View" , type:"radio", toggled:"true"},{label:"30 Minutes View" , type:"radio"},{label:"20 Minutes View" , type:"radio"},{label:"15 Minutes View" , type:"radio"},{label:"10 Minutes View" , type:"radio"},{label:"6 Minutes View" , type:"radio"},{label:"5 Minutes View" , type:"radio"}];
menu = Menu.createMenu( parentInstance, menuItems, false );
menu.addEventListener(MenuEvent.ITEM_CLICK,menuClick);
protected function menuClick(evt:MenuEvent):void
{
Alert.show("here is " + evt.item + " 23");
switch (evt.label)
{
case "60 Minutes View":
this.ChangeLayout(60);
break;
case "30 Minutes View":
this.ChangeLayout(30);
break;
case "20 Minutes View":
this.ChangeLayout(30);
break;
case "15 Minutes View":
this.ChangeLayout(15);
break;
case "10 Minutes View":
this.ChangeLayout(10);
break;
case "6 Minutes View":
this.ChangeLayout(6);
break;
case "5 Minutes View":
this.ChangeLayout(5);
break;
default:
break;
}//end switch
}//end function
but is doesn't even capture the item click event .
Upvotes: 0
Views: 702
Reputation: 17237
try changing evt.item
/ evt.label
to evt.currentTarget.item
/ evt.currentTarget.label
or evt.target.item
/ evt.target.label
also, just a suggestion, if you create constants for your string objects your code will be easier to debug as nothing will be caused by spelling mistakes and the compiler will pick up on a mistyped constant in addition to allowing you to edit your string only once.
so instead of:
menuItems = [{label:"60 Minutes View" , type:"radio", toggled:"true"}];
switch (evt.currentTarget.label)
{
case "60 Minutes View":...
you could create a constant:
private static const 60_MIN_VIEW:String = "60 Minutes View";
menuItems = [{label:60_MIN_VIEW , type:"radio", toggled:"true"}];
switch (evt.currentTarget.label)
{
case 60_MIN_VIEW:...
Upvotes: 2