Within a child, I have an XML element with the following structure:
<position>
<startOffset>*NUMBER*</startOffset>
<numDays>*NUMBER*</numDays>
<role>*String*</role>
<student>*String*</student>
<conflict>*BOOLEAN*</conflict>
</position>
I then use a repeater to list each out onto the screen. There’s a button I have created that is used to create a position. So, once the user clicks this button, I call the following function:
private function addPosition(index:Number):void
{
var tempObject:XML = XML("<position><startOffset>0</startOffset><numDays>3</numDays><role>1C</role><student> </student><conflict>false</conflict></position>");
projectPositions.appendChild(tempObject);
projectHeight += 35;
parentApplication.checkOverlap();
}
The above function creates a new XML object, puts some default values in, and appends it to the list of project positions. After appending the new information, I made the height of the project larger and then check to make sure the new project height isn’t overlapping any other projects… but that information is irrelevant to this post.
My problem is this – once i append a new child to the XML variable, it doesn’t appear on the screen. Is there a “refresh” or “re-render” option i can do to the repeater in order to make the new child show?
EDIT – additional information
Here’s the variable declaration (information is coming from the parent):
[Bindable] public var projectPositions:XML;
Here’s the repeater (which actually calls another child):
<mx:Repeater id="indPositions" dataProvider="{projectPositions.children()}" startingIndex="0">
<components:block height="38" alpha=".75"
id="thisBlock" visible="true" horizontalScrollPolicy="off"
width="{projectWidth}"
oneDay="{Number(oneDay)}"
position="{indPositions.currentItem.role}"
offSet="{indPositions.currentItem.startOffset}"
numDays="{indPositions.currentItem.numDays}"
sName="{indPositions.currentItem.student}"
isConflict="{indPositions.currentItem.conflict}"
projectName="{projectTitle}"
totalSpan="{returnSpan()}"
projectsHttp="{projectsHttp}"
allStudents="{allStudents}"
thisBlockID="{indPositions.currentIndex}"
/>
</mx:Repeater>
Then, once the user clicks on the “Add position” button, the following function is called:
private function addPosition(index:Number):void
{
var tempObject:XML = XML("<position><startOffset>0</startOffset><numDays>3</numDays><role>" + possiblePositions[index] + "</role><student> </student><conflict>false</conflict></position>");
positionsList.addItem(tempObject);
projectHeight += 35;
parentApplication.checkOverlap();
}
That is what I tried doing first (when i made this post)… then i changed some stuff up after your responses and ended up with this:
Declarations:
[Bindable] public var projectPositions:XML;
[Bindable] public var projectXMLList:XMLList = XMLList(projectPositions);
[Bindable] public var projectPositionsXLC:XMLListCollection = XMLListCollection(projectXMLList);
Repeater:
<mx:Repeater id="indPositions" dataProvider="{projectPositionsXLC}" startingIndex="0">
addPosition Function:
private function addPosition(index:Number):void
{
var tempObject:XML = XML("<position><startOffset>0</startOffset><numDays>3</numDays><role>" + possiblePositions[index] + "</role><student> </student><conflict>false</conflict></position>");
projectPositionsXLC.addItem(tempObject);
projectHeight += 35;
parentApplication.checkOverlap();
}
Once i make the changes, and use the XMLListCollection as the dataprovider in the repeater, the information no longer loads on the screen 🙁
Pure
XMLListcan’t be a valid source of data binding handling list changes. To have rid of proper data binding useXMLListCollectioninstead.