Hi fxeOneSixTwo,
in your code below you do not wait for the URLLoader to load the data.
You have to add an Event.COMPLETE listener and then handle the xml data.
I took your code and reworked it a bit. here's what i came up with:
import mx.rpc.soap.LoadEvent;
public function loadData():void
{
var loader:URLLoader = new URLLoader(new
URLRequest("file://c:/flex/test/playlist.xml"));
loader.addEventListener(Event.COMPLETE, onLoad);
}
public function init():void
{
loadData();
}
private function onLoad(event:Event):void
{
var loader:URLLoader = event.target as URLLoader;
var myXML:XML = new XML(loader.data);
trace("data? " + loader.data);
for (var i:int = 0; i < myXML.children().children().length(); i++)
{
var location:String = String(myXML.trackList.track[i].location);
var title:String = String(myXML.trackList.track[i].title);
//tempPlayingList.addItem({file_name:location,title:title})
trace("Loc, Title: " + location + ", " + title);
}
}
The trace on that last line looks like this:
Loc, Title: /songs/Led Zeppelin II/The Lemon Song.mp3, The Lemon Song
Loc, Title: /songs/Led Zeppelin II/Whole Lotta Love.mp3, Whole Lotta Love
good luck.
/r
http://labs.searchcoders.com/dashboard/demo/
http://www.laflex.org/
fxe162 wrote:
> I have an external xml named scratch.xspf :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <playlist>
> <trackList>
> <track>
> <location>/songs/Led Zeppelin II/The Lemon Song.mp3</location>
> <creator>Led Zeppelin</creator>
> <album>Led Zeppelin II</album>
> <title>The Lemon Song</title>
> <image>/covers/Led Zeppelin II.jpg</image>
> </track>
> <track>
> <location>/songs/Led Zeppelin II/Whole Lotta Love.mp3</location>
> <creator>Led Zeppelin</creator>
> <album>Led Zeppelin II</album>
> <title>Whole Lotta Love</title>
> <image>/covers/Led Zeppelin II.jpg</image>
> </track>
> </trackList>
> </playlist>
>
>
> And I am trying to use it as such:
>
> public function openList():void {
>
> var loader:URLLoader = new URLLoader(new
> URLRequest("/playlists/scratch.xspf"));
> var myXML:XML = new XML(loader.data);
>
> for (var i:int = 0; i < myXML.children().children().length(); i++){
> var location:String = String(playlist.trackList.track[i].location);
> var title:String = String(playlist.trackList.track[i].title);
> tempPlayingList.addItem({file_name:location,title:title})
>
> }
> }
>
> This does not work. However if I copy the actual xml from the file
> replacing "loader.data" it does work.
> I cant't for the life of me figure out what is wrong.
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>