I am having some strange (for me) results when I run my program. Here are some parts of the code:
My DG declaraton. Note ContextMenuSelected. public class TrainReceivingGrid extends destinationGrid { [Bindable] private var cm:ContextMenu; private var lastRollOverIndex:int; public var addToPlan:Boolean = true; public var ContextMenuSelected:Boolean = false; public function TrainReceivingGrid() { super(); var cmi1:ContextMenuItem = new ContextMenuItem ("Add to Train Plan"); cmi1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuHandler); var cmi2:ContextMenuItem = new ContextMenuItem ("Remove from Train Plan"); cmi2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuHandler); cm = new ContextMenu(); cm.hideBuiltInItems(); cm.customItems = [cmi1, cmi2]; cm.addEventListener (ContextMenuEvent.MENU_SELECT, contextMenuSelectHandler); contextMenu = cm; ...... private function contextMenuHandler(e:ContextMenuEvent):void { if (e.currentTarget.caption == "Remove from Train Plan") addToPlan = false; else { addToPlan = true; } ContextMenuSelected = true; var ScrollTrains:HBox = HBox(parent.parent); var train:VBox = new VBox(); for (var y:int=0;y<ScrollTrains.getChildren ().length;y++) { var train = VBox (ScrollTrains.getChildAt(y)); DataGrid(train.getChildAt (3)).selectedIndex = selectedIndex; DataGrid(train.getChildAt (3)).dataProvider[selectedIndex].trainplan = addToPlan; } } In the code above I have set ContextMenuSelected = true. But in here: override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); var grid1:DataGrid = DataGrid(DataGridListData (listData).owner); if (grid1.name.indexOf("TrainReceivingGrid") ! = -1) // && TrainReceivingGrid (grid1).ContextMenuSelected) if (grid1.isItemSelected(data)) { g = graphics; if (data.trainplan == true) { g.clear(); g.beginFill(0xCC0033); g.drawRect(0, 0, unscaledWidth, unscaledHeight + 1); g.endFill(); } else { //if (TrainReceivingGrid(grid1).addToPlan == false) { g.clear(); } } } } ContextMenuSelected is going to be true for one grid only. Or, in another words, for one iteration of the FOR loop in contextMenuHandler function. Any idea, why? Hopefully my sample makes any sence. Thanks for help.