3 Replies Latest reply on Nov 2, 2009 2:06 PM by tofer.curtis

    ComboBox in DataGrid - something VERY wrong

    Zolotoj Level 3

      Here is my custom itemrenderer:


      package modulecode
           import flash.events.Event;
           import flash.events.FocusEvent;
           import mx.collections.*;
           import mx.controls.*;
           import mx.controls.listClasses.*;
           import mx.events.*;
           public class comboItemRendererDataGrid extends ComboBox implements IDropInListItemRenderer 
                private var _selectedValue:String;
              private var bSelectedValueSet:Boolean = false;
              private var bDataProviderSet:Boolean = false;
                public var dataProviderCopy:Object = new Object;
                public var datas:XML;
                public function comboItemRendererDataGrid()
                     addEventListener("change", onDataChange);
               override public function set dataProvider(value:Object):void 
                     super.dataProvider = value;
                   // This may get called before dataProvider is set, so make sure not null and has entries 
                  if (value!=null && value.length)
                     // Got it, set flag 
                     bDataProviderSet = true;                  
                // Override committ, this may be called repeatedly 
              override protected function commitProperties():void
                 // invoke ComboBox version 
                  // If value set and have dataProvider 
                 if (bSelectedValueSet && bDataProviderSet)
                    // Set flag to false so code won't be called until selectedValue is set again 
                    // Loop through dataProvider 
                    for (var i:int=0;i<this.dataProvider.length;i++)
                       // Get this item's data 
                       var item:String = 
                       // Check if is selectedValue 
                       if(item == _selectedValue)
                          // Yes, set selectedIndex 
                          this.selectedIndex = i;
              override public function set data(value:Object):void
                     //super.dataProvider = datas["cover"];
                     super.data = value;          
                     selectedValue = value[DataGrid(listData.owner).columns[listData.columnIndex].dataField];
              // set for selectedValue 
              public function set selectedValue(s:String):void
                 // Set flag 
                 bSelectedValueSet = true;
                // Save value 
                 _selectedValue = s;
                 // Invalidate to force commit
              public function get selectedValue():String
                     return _selectedValue;
              public function onDataChange(event:Event):void
                     // set selected value back to DataGrid
                     DataGrid(listData.owner).selectedItem[DataGrid(listData.owner).columns[listData.columnIndex].dataField] = 


      what's happening, or more accurately, not, is that onDataChange does not fire when I choose an item from the combo using mouse, but if I scroll the combo with an arrow key then I have selectedItem traced. What's wrong in my code? I even think, it used to work fine. I am using FB4 beta 2. Please, help. I am lost.




      what is happening, or more accurately,