I was following a tutorial on the Adobe developer network that is a video playlist being populated by an XML file. I’m new to using XML and I’m kind of stumped and I was hoping someone would help me. I would like to add another element or attribute to the XML file but how do I call it in the Action Script?
AS3>>>There is a class constructor and a method which loads the XML data which in turn loads another method (‘initMediaPlayer’) below which is what is going through the XML nodes :
public function initMediaPlayer(event:Event):void {
var myXML:XML = new XML(xmlLoader.data);
var item:XML;
for each (item in myXML.vid) {
// populate playlist.
// Get thumbnail value and assign to cellrenderer.
var thumbnail:String;
if (item.hasOwnProperty("@thumbnail")>0) {
thumbnail = item.@thumbnail;
}
// Send data to tileList.
tileList.addItem({label:item.attribute("description").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumbnail});
}
XML file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<playlist id="My Video Player" >
<vid description="Lorem ipsum dolor sit amet"
src="movies/myMovie.flv"
thumbnail="thumbnails/smallPic.jpg" />
</playlist>
So now I would like to add another element
<?xml version="1.0" encoding="UTF-8"?>
<playlist id="My Video Player" >
<vid description="Lorem ipsum dolor sit amet"
**details="consectetuer adipiscing elit. Maecenas quis nunc"**
src="movies/myMovie.flv"
thumbnail="thumbnails/smallPic.jpg" />
</playlist>
How do I modify the method to get another element …or does anyone know of a tutorial out there. Thanks.