i have an xml document:
var xml:XML = new XML(<rootNode>
<head>
<meta name="template" content="Default" />
</head>
<mainSection>
<itemList>
<item>
<video src={this.videoURL} />
<img src={this.src}></img>
</item>
</itemList>
</mainSection>
</rootNode>);
What i'd like to do, is when certain conditions are me, insert another at the beginning of itemList.
var newNode:XMLList = new XMLList("<item><video src=\"" + _videoSource + "\"></video></item>");
I'm able to generate and trace newNode just fine, but whenever I try to add it using insertChildBefore, it always returns undefined.
var contentNode:XML = new XML(xml.mainSection.itemList.item);
xml.insertChildBefore(contentNode ,newNode)
contentNode always traces fine, but it always fails when trying insertChildBefore or insertChildAfter. the weird thing is, if I make contentNode less specific (like xml.mainSection) then it works as expected.
Thanks for any help, this is driving me insane!