Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

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:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" ?>
  2. <playlist>
  3.     <song title="Alliance" artist="Jack Hammer & B Mac" src="../content/music/Alliance.mp3" />
  4.     <song title="Black Friday" artist="King Gregor" src="../content/music/BlackFriday.mp3" />
  5.     <song title="A Dangerous Man" artist="Jack Hammer" src="../content/music/DangerousMan.mp3" />
  6. </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:

Expand|Select|Wrap|Line Numbers
  1. XMLNode.prototype.moveBefore = function(beforeNode){
  2.     if (this == beforeNode) return (0);
  3.     beforeNode.parentNode.insertBefore( this.cloneNode(true), beforeNode);
  4.     this.removeNode();
  5. }
  6. Clamp = function(min, n, max){
  7.     if (n<min) return min;
  8.     if (n>max) return max;
  9.     return n;
  10. }
  11.  
  12.  
  13.  
  14. var song_spacing = 20;
  15. var over_node;
  16. GenerateSongListing = function(playlist_xml, target_mc){
  17.  
  18.     target_mc = target_mc.createEmptyMovieClip("list_mc",1);
  19.  
  20.     var songs = playlist_xml.firstChild.childNodes;
  21.     for (var i=0; i<songs.length; i++){
  22.         var song_mc = target_mc.attachMovie("song", "song"+i, i);
  23.         song_mc._y = i*song_spacing;
  24.  
  25.         song_mc.node = songs[i];
  26.         song_mc.title_txt.text = songs[i].attributes.title;
  27.         song_mc.moved = false;
  28.  
  29.         song_mc.select_btn.onPress = function(){
  30.             this._parent.onMouseMove = function(){
  31.                 if (!this.moved){
  32.                     dragline_mc._visible = true;
  33.                     dragline_mc._y = playlist_mc._y + this._y;
  34.                     highlight_mc._visible = true;
  35.                     highlight_mc._y = playlist_mc._y + this._y;
  36.                     this.moved = true;
  37.                 }
  38.             }
  39.         }
  40.  
  41.         song_mc.select_btn.onDragOver = function(){
  42.             over_node = this._parent.node;
  43.             dragline_mc._y = playlist_mc._y + this._parent._y;
  44.         }
  45.  
  46.         song_mc.onMouseUp = function(){
  47.             if (this.onMouseMove){
  48.                 delete this.onMouseMove;
  49.                 dragline_mc._visible = false;
  50.                 highlight_mc._visible = false;
  51.                 if (this.moved){
  52.                     this.node.moveBefore(over_node);
  53.                     GenerateSongListing(playlist_xml, playlist_mc);
  54.                 }
  55.             }
  56.         }
  57.  
  58.         song_mc.select_btn.onRelease = function(){
  59.             if (!this._parent.moved){
  60.                 SetSong(this._parent.node);
  61.             }
  62.         }
  63.  
  64.     }
  65. }
  66.  
  67.  
  68. var playlist_xml = new XML();
  69. playlist_xml.contentType = "text/xml";
  70. playlist_xml.ignoreWhite = true;
  71. playlist_xml.onLoad = function(success){
  72.     if (success){
  73.         GenerateSongListing(this, playlist_mc);
  74.     }else trace("Error loading XML file"); // no success?  trace error (wont be seen on web)
  75. }
  76. playlist_xml.load("../xml/playlist.xml");
  77.  
  78. dragline_mc._visible = false;
  79. 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.
Reply
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