1 Reply Latest reply on Apr 14, 2009 10:27 AM by Handycam

    Why is a drop target not counting the first dropped item?

    Handycam Level 1

      I have 2 data grids, set up for drag and drop.


      The right-hand one, the drop target, has event handlers:


      <mx:DataGrid id="chosenList" dragDrop="dragDropChosen(event)" >


      My event handler is supposed to count how many items were dropped in here, and if too many (set by a variable) fire an alert.



      private function dragDropChosen(e:DragEvent):void {

      this.dispatchEvent(new Event("ITEM_CHOSEN", true));




      This checkAmounts() function checks the length of the dataprovider of that grid against the variables "min" and "max" to see if the correct amount has been dropped yet. I am trying to do this by counting the length of the dataProvider in the drop destination grid:


      var numChoices:uint = chosenList.dataProvider.length;


      My problem is, it does not count the first item.  I see it in the list, the drop is successful but chosenList.dataProvider.length = "null". After I drag and drop a second item, the length is "1". This is no good, I need to tell if there are 0,1,2,etc items in that datagrid.


      What am I missing there?  I would think upon a successful drop of one item there would be a length of 1 and there would we no "null" error.