PDA

View Full Version : Working with PopUpButton + Menu


stangluverj
10-02-2007, 08:52 PM
Hey guys im new here.. lotta smart fellas on here :)

Need assistance with the sample code provided by adobelive.



private function initMenu():void {
myMenu = new Menu();
var dp:Object = [{label: "Administrators",data: "1"}, {label: "Everyone",data: "2"}, {label: "TEST",data: "6"}];
myMenu.dataProvider = dp;
myMenu.selectedIndex = 0;
myMenu.addEventListener("itemClick", itemClickHandler);
popB.popUp = myMenu;
popB.label = "Put in: " + myMenu.dataProvider[myMenu.selectedIndex].label;
}


<mx:PopUpButton id="popB" label="Edit" creationComplete="initMenu();" width="135" />




This code works great, but I want the menu to come from an xml document, not from a manually created array/object.

Please assist me in exactly what the dataProvider property of myMenu:Menu is expecting...

I was hoping to do something like this..



var testgo:XML = <menuitem label="test"/>;
myMenu.dataProvider = testgo;





Let me know what im missing here..

box86rowh
10-03-2007, 04:17 PM
Hey guys im new here.. lotta smart fellas on here :)

Need assistance with the sample code provided by adobelive.



private function initMenu():void {
myMenu = new Menu();
var dp:Object = [{label: "Administrators",data: "1"}, {label: "Everyone",data: "2"}, {label: "TEST",data: "6"}];
myMenu.dataProvider = dp;
myMenu.selectedIndex = 0;
myMenu.addEventListener("itemClick", itemClickHandler);
popB.popUp = myMenu;
popB.label = "Put in: " + myMenu.dataProvider[myMenu.selectedIndex].label;
}


<mx:PopUpButton id="popB" label="Edit" creationComplete="initMenu();" width="135" />




This code works great, but I want the menu to come from an xml document, not from a manually created array/object.

Please assist me in exactly what the dataProvider property of myMenu:Menu is expecting...

I was hoping to do something like this..



var testgo:XML = <menuitem label="test"/>;
myMenu.dataProvider = testgo;





Let me know what im missing here..

I think the dataprovider should be an xmlListCollection, not a plain xml object

stangluverj
10-03-2007, 04:23 PM
Thanks for the reply.

I ended up using a combobox to do this... Made more sense.