My application creates new tabnavigator tabs using a Repeater driven
by a dynamically updated arrayCollection. I hope there's a simple fix
to this runtime error that's been dogging me for several days.

I'm using this arrayCollection as the data provider:

<mx:ArrayCollection id="repeaterAC">
    <mx:Array id="myRepeaterArray">
        <mx:Object label="0" data="0"/>
    </mx:Array>
</mx:ArrayCollection>

--------------------------------------------------------------
Here's the repeater MXML snippet:

   <mx:Canvas label="Personal Info" width="100%" height="100%">
        <mx:TabNavigator id="tabnavPersonalInfo"
            x="0" y="0" width="100%" height="100%">

      <mx:Repeater id="rptApplicant"
          dataProvider="{repeaterAC}"
          recycleChildren="true">
   
      <mx:Canvas label="New {rptApplicant.currentIndex}"
          width="100%" height="100%"
          id="personalTab"
          horizontalScrollPolicy="off" verticalScrollPolicy="off"    
          
          creationComplete="bringApplicantDataForward()">

<!-- form elements omitted -->

      </mx:Canvas>
      </mx:Repeater>

--------------------------------------------------------------
This function is the click event for a button. It adds an item to the
arrayCollection triggering the 'repeat' and it sets the focus to the
newly created tab:

    private function tabnavPersonalInfo_addTab():void
    {
            var myInt:int = myRepeaterArray.length;
            var myVar:String = myInt.toString();
            repeaterAC.addItemAt({label:myVar, data:myVar}, myInt);
            tabnavPersonalInfo.selectedIndex=myRepeaterArray.length; 
     
   }

--------------------------------------------------------------
This is the run time error thrown by Flash Player 9 when the 'button'
is clicked to run the above function:

RangeError: Error #2006: The supplied index is out of bounds.
    at flash.display::DisplayObjectContainer/setChildIndex()
    at mx.core::Container/setChildIndex()
    at mx.core::Repeater/::recycle()
    at mx.core::Repeater/::execute()
    at mx.core::Repeater/::collectionChangedHandler()
    at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.collections::ListCollectionView/dispatchEvent()
    at mx.collections::ListCollectionView/::addItemsToView()
    at mx.collections::ListCollectionView/::listChangeHandler()
    at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.collections::ArrayList/::internalDispatchEvent()
    at mx.collections::ArrayList/addItemAt()
    at mx.collections::ListCollectionView/addItemAt()
    at Components.flexadmin::flexmod/::tabnavPersonalInfo_addChild()
    at Components.flexadmin::flexmod/___Button7_click()

--------------------------------------------------------------
When I click "Continue" in the error window, all is well (the newly
'repeated' tab is created with all it's visual elements and focus is
set to it). I have tried using a "try{} catch(error:*){}" structure,
but it did not 'catch' this error. I've also tried changing the array
index to different values, but what you see in this code works.

FWIW, nowhere in my code do I ever removeChild()... only add via the
Repeater.

How do I avoid the error or how can I suppress the modal runtime error
window?

Any ideas would certainly be appreciated!

TIA,

Rob Oates
Boise, Idaho, USA



Reply via email to