Flash / XML mp3 playlist problem
Question posted by: jiwas78
(Newbie)
on
July 5th, 2008 04:08 AM
Hey there.
I am learning XML and Actionscript.
I have a problem with getting my XML data to load when my SWF is in an HTML page in a browser. When I open the SWF on it's own whether in Flash Player or browser, my playlist of songs comes up. But in the HTML page it's a no go. Here is what my XML looks like:
- <?xml version="1.0" ?>
-
<playlist>
-
<song title="Alliance" artist="Jack Hammer & B Mac" src="../content/music/Alliance.mp3" />
-
<song title="Black Friday" artist="King Gregor" src="../content/music/BlackFriday.mp3" />
-
<song title="A Dangerous Man" artist="Jack Hammer" src="../content/music/DangerousMan.mp3" />
-
</playlist>
And my actionscript, which admittedly I did copy and paste from a tutorial and have little idea of how it all works, I just know that it doesn't:
- XMLNode.prototype.moveBefore = function(beforeNode){
-
if (this == beforeNode) return (0);
-
beforeNode.parentNode.insertBefore( this.cloneNode(true), beforeNode);
-
this.removeNode();
-
}
-
Clamp = function(min, n, max){
-
if (n<min) return min;
-
if (n>max) return max;
-
return n;
-
}
-
-
-
-
var song_spacing = 20;
-
var over_node;
-
GenerateSongListing = function(playlist_xml, target_mc){
-
-
target_mc = target_mc.createEmptyMovieClip("list_mc",1);
-
-
var songs = playlist_xml.firstChild.childNodes;
-
for (var i=0; i<songs.length; i++){
-
var song_mc = target_mc.attachMovie("song", "song"+i, i);
-
song_mc._y = i*song_spacing;
-
-
song_mc.node = songs[i];
-
song_mc.title_txt.text = songs[i].attributes.title;
-
song_mc.moved = false;
-
-
song_mc.select_btn.onPress = function(){
-
this._parent.onMouseMove = function(){
-
if (!this.moved){
-
dragline_mc._visible = true;
-
dragline_mc._y = playlist_mc._y + this._y;
-
highlight_mc._visible = true;
-
highlight_mc._y = playlist_mc._y + this._y;
-
this.moved = true;
-
}
-
}
-
}
-
-
song_mc.select_btn.onDragOver = function(){
-
over_node = this._parent.node;
-
dragline_mc._y = playlist_mc._y + this._parent._y;
-
}
-
-
song_mc.onMouseUp = function(){
-
if (this.onMouseMove){
-
delete this.onMouseMove;
-
dragline_mc._visible = false;
-
highlight_mc._visible = false;
-
if (this.moved){
-
this.node.moveBefore(over_node);
-
GenerateSongListing(playlist_xml, playlist_mc);
-
}
-
}
-
}
-
-
song_mc.select_btn.onRelease = function(){
-
if (!this._parent.moved){
-
SetSong(this._parent.node);
-
}
-
}
-
-
}
-
}
-
-
-
var playlist_xml = new XML();
-
playlist_xml.contentType = "text/xml";
-
playlist_xml.ignoreWhite = true;
-
playlist_xml.onLoad = function(success){
-
if (success){
-
GenerateSongListing(this, playlist_mc);
-
}else trace("Error loading XML file"); // no success? trace error (wont be seen on web)
-
}
-
playlist_xml.load("../xml/playlist.xml");
-
-
dragline_mc._visible = false;
-
highlight_mc._visible = false;
I'm sure it's just a simple issue. Something that I'm not aware of or haven't done properly. I'm a total newbie with XML and Actionscript and have tried most everything I could think of but so far no answers. Can anyone help?
Cheers.
Jack.
 |
Not the answer you were looking for? Post your question . . .
189,283 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).
|
|
|
Latest Articles: Read & Comment
Top Flash / Actionscript Forum Contributors
|