# XML - AS3 Help

**URL:** <https://forum.kirupa.com/t/xml-as3-help/300216>\
**Category:** flash\
**Created:** [November 17, 2009, 7:57pm UTC](https://forum.kirupa.com/t/xml-as3-help/300216 "2009-11-17T19:57:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonstle](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jonstle](https://forum.kirupa.com/u/jonstle)\
**Post date:** [November 17, 2009, 7:57pm UTC](https://forum.kirupa.com/t/xml-as3-help/300216/1 "2009-11-17T19:57:02Z")

</div>

I am trying to create an audio that only uses the first entry in an xml file. I have most of the things working but I keep getting an error related to the audio file.

TypeError: Error #1034: Type Coercion failed: cannot convert “[http://rivervalleychurch.net/sermonaudio/Podcast/06\_Jesus\_Save\_Your\_Church\_First\_Love.mp3](http://rivervalleychurch.net/sermonaudio/Podcast/06_Jesus_Save_Your_Church_First_Love.mp3)” to flash.net.URLRequest.  
at latestMessage\_fla::MainTimeline/frame1()

I inserted the url for the file into error message so you can see if there is s problem with that. I was initially trying to use a variable to hold the url for me, because this xml file gets updated every week and I only want to access the most recent entry.

This is my first attempt at making an audio player in flash, so I am sure I have made a simple mistake, but for the life of me I cannot figure out what it is.

Here is the code I have so far: (Please Try not to Laugh, at least not out loud)

[INDENT]//Load the podcast.xml File  
var xmlLoader:URLLoader = new URLLoader();  
var xmlData:XML = new XML();  
var audioFile:String;  
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);  
xmlLoader.load(new URLRequest(“[http://www.rivervalleychurch.net/sermonaudio/Podcast/podcast.xml](http://www.rivervalleychurch.net/sermonaudio/Podcast/podcast.xml)”));  
function LoadXML(e:Event):void {

```
xmlData = new XML(e.target.data);
ParseBooks(xmlData);

```

}

//Load text into text fields  
function ParseBooks(podcastInput:XML):void {

```
description_txt.text = (podcastInput.channel.item.description.text()[0]);    
title_txt.text = (podcastInput.channel.item.title.text()[0]);
publish_txt.text = (podcastInput.channel.item.pubDate.text()[0]);
audioFile = (podcastInput.channel.item.link.text()[0]);

//trace (audioFile);

```

}

//Audio Player Controls and Stuff  
var req:URLRequest = URLRequest(“audioFile”);  
var sound:Sound = new Sound();  
var controller:SoundChannel;

function soundLoaded(event:Event):void  
{  
controller = sound.play();  
controller.stop();  
play\_btn.addEventListener(MouseEvent.CLICK, playSound);  
pause\_btn.addEventListener(MouseEvent.CLICK, stopSound);

}

function playSound(event:MouseEvent):void  
{  
controller = sound.play();  
}

function stopSound(event:MouseEvent):void  
{  
controller.stop();  
}

sound.addEventListener(Event.COMPLETE, soundLoaded);  
sound.load(req);

//Event Listeners For buttons  
itunes\_btn.addEventListener(MouseEvent.CLICK, goItunes);  
archives\_btn.addEventListener(MouseEvent.CLICK, goArchives);  
rss\_btn.addEventListener(MouseEvent.CLICK, goRss);

//Functions For Buttons  
function goItunes(e:MouseEvent):void{  
navigateToURL(new URLRequest(“[http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=262248424](http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=262248424)”));  
}  
function goArchives(e:MouseEvent):void{  
navigateToURL(new URLRequest(“[http://www.rivervalleychurch.net/index.php?option=com\_content&view=category&layout=blog&id=37&Itemid=91](http://www.rivervalleychurch.net/index.php?option=com_content&view=category&layout=blog&id=37&Itemid=91)”));  
}  
function goRss(e:MouseEvent):void{  
navigateToURL(new URLRequest(“[http://www.rivervalleychurch.net/sermonaudio/Podcast/podcast.xml](http://www.rivervalleychurch.net/sermonaudio/Podcast/podcast.xml)”));  
}

[/INDENT]  
One last question is in regards to using id3 tags versus xml tags to fill dynamic text fields in the player. Currently I am using the xml file to do this, are there any advantages one way or the other for this. The only reason I ask is that I am hoping to display an “album art” image from the id3 tag in the player. Would it be better to grab all of the information from the mp3 file?
