<mx:VBoxxmlns:mx="http://www.adobe.com/2006/mxml" width="150" height="80" paddingLeft="10"> <mx:Script> <![CDATA[ import flash.display.*; override publicfunction set data(value:Object):void { if (value is Name) { text1.text = value.firstName; text2.text = value.lastName; var personMenu:ContextMenu = new ContextMenu(); var lookupRecord:ContextMenuItem = new ContextMenuItem("Look Up Record" ); var lookupPicture:ContextMenuItem = new ContextMenuItem("Look Up Picture" ); personMenu.customItems.push(lookupRecord); personMenu.customItems.push(lookupPicture); this.contextMenu = personMenu; } elseif (value is Office) { text1.text = value.officeAddress; text2.text = value.officeName; var officeMenu:ContextMenu = newContextMenu(); var lookupMap:ContextMenuItem =new ContextMenuItem("Look Up Map"); lookupMap.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,showMap); var lookupEmployees:ContextMenuItem =new ContextMenuItem("Look Up Employees"); lookupEmployees.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, showEmployees); officeMenu.customItems.push(lookupEmployees); officeMenu.customItems.push(lookupMap); this.contextMenu = officeMenu; } } privatefunction showMap(event:ContextMenuEvent):void { //do something with the map } privatefunction showEmployees(event:ContextMenuEvent):void { //do something to look up all the employees }