Hi guys,
After installing Release of Flex 3 I have received a lot of surprises. So,
first of them is the
exception:
RangeError: Error #2006: The supplied index is out of bounds.
at flash.display::DisplayObjectContainer/setChildIndex()
at mx.core::UIComponent/setChildIndex()
at mx.core::Container/setChildIndex()
at mx.core::Repeater/recycle()
at mx.core::Repeater/execute()
at mx.core::Repeater/collectionChangedHandler()
...
in such example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:states>
<mx:State
name="repeaterVisible">
<mx:AddChild
relativeTo="{repeaterVBox}">
<mx:Repeater
id="labelRepeater"
dataProvider="{dataProvider}"
recycleChildren="true">
<mx:Label
text="{labelRepeater.currentItem.text}" />
</mx:Repeater>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:ArrayCollection
id="dataProvider" />
<mx:Button
label="show repeater"
click="currentState = 'repeaterVisible'" />
<mx:Button
label="add"
click="dataProvider.addItem({text : 'item' +
dataProvider.length})" />
<mx:VBox
id="repeaterVBox" />
</mx:Application>
As I see the problem rises then I'm trying to add a new item to dataProvider of
Repeater
which locates in AddChild in states. Could anybody help me?