A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: CS3 - Load Jpg from XML

  1. #1
    -=The Holy Step-Father=-
    Join Date
    Jun 2000
    Location
    Coast to Coast
    Posts
    85

    CS3 - Load Jpg from XML

    Round 3... hehe

    Im coding a streaming radio - and passing some variables to the player - via an xml file.

    the file streams correctly, the text (artist, title, album) passes ok - but i (once again) cant get the image of the cd art to appear.

    here is the code im using -

    Code:
    stop();
    playlist = new XML();
    playlist.ignoreWhite = true;
    playlist.onLoad = function(success) {
    	if (success) {
    		_global.songname = [];
    		_global.songband = [];
    		_global.songalbum = [];
    		_global.songfile = [];
    		_global.songimage = [];
    		for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
    			_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
    			_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
    			_global.songalbum[i] = playlist.firstChild.childNodes[i].attributes.album;
    			_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
    			_global.songimage[i] = playlist.firstChild.childNodes[i].attributes.image;
    			trace(songname[i]+"  "+songfile[i]);
    		}
    	}
    	_root.createEmptyMovieClip("sound_mc", 1);
    	_root.sound_mc.sound_obj = new Sound();
    	_global.song_nr = random(songfile.length);
    	_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songalbum[song_nr], songimage[song_nr]);
    };
    MovieClip.prototype.songStarter = function(file, name, band, album, image) {
    	this.sound_obj.loadSound(file, true);
    	this.onEnterFrame = function() {
    		if (this.sound_obj.position>0) {
    			delete this.onEnterFrame;
    			this._parent.display_txt.text = name;
    			this._parent.display_txt2.text = band;
    			this._parent.display_txt3.text = album;
    			this._parent.picload.content = image;
    		} else {
    			this._parent.display_txt.text = "loading...";
    		}
    	};
    	this.sound_obj.onSoundComplete = function() {
    		(song_nr == songfiles.length-1) ? _global.song_nr=0 : _global.song_nr++;
    		_root.sound_mc.songStarter(songfiles[song_nr], songname[song_nr], songband[song_nr], songalbum[song_nr], songimage[song_nr]);
    	};
    };
    btn_play.onRelease = function() {
    	this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songalbum[song_nr], songimage[song_nr]);
    };
    btn_stop.onRelease = function() {
    	this._parent.sound_mc.sound_obj.stop();
    	
    };
    btn_fw.onRelease = function() {
    	(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
    	_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songalbum[song_nr], songimage[song_nr]);
    };
    btn_rev.onRelease = function() {
    	(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
    	_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songalbum[song_nr], songimage[song_nr]);
    };
    playlist.load("playlist.xml");
    the movie clip it should lod into is named picload

    i can post theFLA if necessary...

    XML code is as follows

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <songs>
    <song name ="Do's and Dont's" band="Omerta Verse" album="Demo 2006" image="omv.jpg" file="overse.mp3"  />
    <song name ="Be My Baby Tonight" band="Someday Providence" album="The Hidden Vibe" image="sp.jpg" file="bbt.mp3" />
    <song name ="Taffy (Acoustic Mix)" band="Taffy" album="All Tied Up" image="taff.jpg" file="taffy.mp3" />
    <song name ="To A Better Day" band="A Turn of Phrase" album="Demo 2007" image="atop.jpg" file="better.mp3" />
    <song name ="Wide Awake" band="Someday Providence" album="The Hidden Vibe" image="sp.jpg" file="wideawake.mp3" />
    <song name ="Raise Up" band="Scripture" album="Demo 2007" image="scrip.jpg" file="raiseup.mp3" />
    
    </songs>
    Any help is appreciated!!!
    working on it

  2. #2
    Member
    Join Date
    Nov 2006
    Posts
    63
    you need to use loadMovie, or the MovieClipLoader.

    instead of

    this._parent.picload.content = image;

    try

    this._parent.picload.loadMovie(image);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center