--- In flexcoders@yahoogroups.com, "lehaianh1986" <lehaianh1...@...> wrote: > > I have an event for my right click mouse on AdvancedDataGrid. I want to > collect row item data so my code is > > public function menuItemSelect(evt:ContextMenuEvent):void > { > var searchString:String; > var inObj:InteractiveObject; > inObj = evt.mouseTarget; > if (inObj.hasOwnProperty("data")) > { > var obj:Object = inObj.data; > if (obj.hasOwnProperty("Index")) > searchString = obj.Index; > else > searchString = ""; > } > else > searchString = ""; > ... > } > > The error is "Access of possibly undefined property data through a reference > with static type > flash.display:InteractiveObject" in line > > var obj:Object = inObj.data; > > but I see in debug mode > > inObj = inObj = > (mx.controls.advancedDataGridClasses.AdvancedDataGridItemRenderer) > mx.controls.advancedDataGridClasses.AdvancedDataGridItemRenderer (@9385479) > > > inObj.data = inObj.data = (Object) Object (@699b629) > Index = "1" : String > mx_internal_uid = "AC2A10E1-8A14-7CDD-FF42-A40DE4F2CDA2" : String > .... > > So why the code false? How to solve it?
It fails because InteractiveObject, unlike, say, UIComponent, doesn't have a data property. So instead of casting it to an object that doesn't have a data property, try casting it to one that does. HTH; Amy