I was implementing a filter on a list of values and noticed that when
I scroll down the list and then try and filter an error is thrown.

Here is the error:
TypeError: Error #1010: A term is undefined and has no properties.
        at mx.controls::List/::adjustVerticalScrollPositionDownward()
        at mx.controls::List/mx.controls:List::configureScrollBars()
        at
mx.controls.listClasses::ListBase/mx.controls.listClasses:ListBase::updateDisplayList()
        at mx.controls::List/mx.controls:List::updateDisplayList()
        at mx.core::UIComponent/validateDisplayList()
        at mx.managers::LayoutManager/::validateDisplayList()
        at mx.managers::LayoutManager/::doPhasedInstantiation()
        at Function/http://adobe.com/AS3/2006/builtin::apply()
        at mx.core::UIComponent/::callLaterDispatcher2()
        at mx.core::UIComponent/::callLaterDispatcher()

seems to be an indexing problem based at this line list:
h = rowInfo[rowCount - 1].y + rowInfo[rowCount - 1].height; 

(line 789 in my code base)


Here is the code I used to generate the result.
(This is based on a Ben Forta example. he used 
a datagrid -- the erro does not occure with datagrid just list.)

The code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
            layout="vertical" creationComplete="initApp()">

   <mx:Script>
   <![CDATA[

   // On startup
   public function initApp():void
   {

      // Set filter function       // Be careful to set filterFunction
      // only after ArrayCollection has been       // populated.
      myData.filterFunction=processFilter;
   }
      
   // Filter function
   public function processFilter(item:Object):Boolean
   {
      var result:Boolean=false;

      // If no filter text, or a match, then true
      if (!item.length
         || item.indexOf(txtFilter.text) >= 0)
         result=true;
            
      return result;
   }
   
   private var theSource:Array = ["foo", "bar", "foobar", "flex",
"adobe", "ajax", "java", "drstrange"]
   ]]>
   </mx:Script>

   <!-- Data (use ArrayCollection) -->
   <mx:ArrayCollection id="myData" source="{theSource}">
   
   </mx:ArrayCollection>

   <!-- UI -->
   <mx:HBox width="100%">
      <mx:Label text="Filter:"/>
      <mx:TextInput id="txtFilter" width="100%"
                  change="myData.refresh()"/>
   </mx:HBox>
   <mx:List dataProvider="{myData}"
               width="100%" height="82">
    
   </mx:List>
   
</mx:Application>


Reply via email to