A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Xml content into Flash??

  1. #1
    Member
    Join Date
    Apr 2002
    Posts
    32
    I am BIG newbie to flash and would love for some smart brains here to help me out

    Problem :

    I need some external XML data loaded into a textbox in my
    flashmovie. And i need it to be refreshed about every 30 seconds.

    Here is the link to the XML page my shoutcast server generates :
    http://cosmo.adsl.dk:8001/admin.cgi?...viewxml&page=1

    I need the content of the SONGTITLE tag


    Someone please help me out...

    Kind regards

    Jimmy Jensen
    cosmo@codes.dk
    [Edited by cosmodk on 04-12-2002 at 05:50 AM]

  2. #2
    Member
    Join Date
    Apr 2002
    Posts
    32

    no ideas?

    I find it hard to believe that the best flash forum in the world cant help me you guys are the gods!!

    Jimmy jensen

  3. #3
    Senior Member
    Join Date
    Mar 2002
    Posts
    141
    I'd help you out, but the link you gave is a dea link. Email me the xml or post a good link.

  4. #4
    The Flash Wolf deltawolf's Avatar
    Join Date
    Jan 2001
    Posts
    834
    yeah, link is dead, anyways isnt there an XML input in actionscript 6? if thats true u can make a small little blank MC running doing a new import every 30 seconds and having the AS at the end every time it recycles
    *edit*
    i checked and there is XML stuff and a bunch of it

  5. #5
    Member
    Join Date
    Apr 2002
    Posts
    32
    Well here is the link to the XML i need to extract from...

    Hope this helps.. i am a total newbie to action scripts, and i need guidance..

    http://cosmo.adsl.dk:8001/admin.cgi?...viewxml&page=1

    Jimmy Jensen

  6. #6
    Senior Member
    Join Date
    Mar 2002
    Posts
    298
    I'm no guru on XML, but this code should retrieve the object and put it in flash, it's then just a case of experimenting with it a bit to get your particular field

    objXML = new XML()
    objXML.onLoad = XMLReceived
    objXML.load("http://cosmo.adsl.dk:8001/admin.cgi?pass=megamixers&mode=viewxml&page=1")

    function XMLReceived()
    {

    //Code to pick out the song title
    }

  7. #7
    Senior Member
    Join Date
    Mar 2002
    Posts
    141
    I still get a dead link bud --

    let me give you an example of an XML parser function -- simple and easy.

    Code:
    //xmlobject and data container creation 
    function loadPlaylist(playList) {
    	//creating data holding array
    	musicDataArray = new Array();
    	musicDataIndex = 0;
    	//creating xml object
    	playListXML = new XML();
    	playListXML.load(playList);
    	//creating load function
    	playListXML.onLoad = function() {
    		playlist = this.firstChild;
    		//entering master loop
    		//initializing breakcheck
    		breakMaster=0;
    		while (playList != null) {
    			//checking for playlist rootnode name
    			if (playList.nodeName.toUpperCase() == 'HMDJPLAYLIST') {
    				song = playList.firstChild;
    				//entering into song loop
    				//initializing breakcheck
    				breakList=0;
    				while (song != null) {
    					//checking for song name node
    					//creating a temporary associative array -- later this will be fed into an element of the master array
    					tempArray = new Array();
    					if (song.nodeName.toUpperCase() == "SONG") {
    						//putting attrib data to the array
    						//this of course would be variable dependant apun the structure of
    						//you xml doc --
    						tempArray['SONGID'] = song.attributes.id;
    						songProperties = song.firstChild;
    						breakSong=0;
    						//entering song data loop
    						while (songProperties != null) {
    							if (songProperties.nodeName.toUpperCase() == 'FILENAME') {
    								//populating array - 
    								tempArray['FILENAME'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'TIMESTAMP') {
    								tempArray['TIMESTAMP'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'ARTIST') {
    								tempArray['ARTIST'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'ALBUM') {
    								tempArray['ALBUM'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'TITLE') {
    								tempArray['TITLE'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'GENRE') {
    								tempArray['GENRE'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'TRACK') {
    								tempArray['TRACK'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'DURATION') {
    								tempArray['DURATION'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'BITRATE') {
    								tempArray['BITRATE'] = songProperties.firstChild;
    							}
    							if (songProperties.nodeName.toUpperCase() == 'ISVBR') {
    								tempArray['ISVBR'] = songProperties.firstChild;
    							}
    							//moving on to next element
    							songProperties = songProperties.nextSibling;
    							//this next part is optional -- but I add it to protect against infinit loops due
    							//to malformed xml documents
    							breakSong++;
    							if(breakSong>=_root.breakLimit){
    								break;
    								trace('breakSong')
    							}
    						}
    					}
    					musicDataArray[musicDataIndex]=tempArray;
    					musicDataIndex++;
    					delete tempArray
    					song = song.nextSibling;
    					//this next part is optional -- but I add it to protect against infinit loops due
    					//to malformed xml documents
    					breakList++;
    					if(breakList>=_root.breakLimit){
    						break;
    						trace('breakList')
    					}
    				}
    			}
    			playList = playList.nextSibling;
    			breakMaster++;
    			//this next part is optional -- but I add it to protect against infinit loops due
    			//to malformed xml documents
    			if(breakMaster>=_root.breakLimit){
    				break;
    				trace('breakMaster')
    			}
    		}
    		//creating a song index array -- for song history and random playlist
    		//playing default sound
    		songIndexArray = new Array(musicDataArray.length)
    		songIndex=Math.floor(Math.random()*songIndexArray.length)
    		playSong(songIndex)
    	}
    }

  8. #8
    Senior Member
    Join Date
    Mar 2002
    Posts
    141
    to play a song from the playlist

    Code:
    //creating Sound load and play functions
    function playSong(index){
    	//getting song information from the musicDataArray
    	if(_root.musicDataArray.length!=null){
    		//creating temporary data container
    		tmpArray = new Array();
    		tmpArray = _root.musicDataArray[index];
    		//extracting data
    		songID=tmpArray['SONGID'].toString();
    		fileName=tmpArray['FILENAME'].toString();
    		timeStamp=tmpArray['TIMESTAMP'].toString();
    		artist=tmpArray['ARTIST'].toString();
    		album=tmpArray['ALBUM'].toString();
    		title=tmpArray['TITLE'].toString();
    		genre=tmpArray['GENRE'].toString();
    		track=tmpArray['TRACK'].toString();
    		duration=tmpArray['DURATION'].toString();
    		bitrate=tmpArray['BITRATE'].toString();
    		isvbr=tmpArray['ISVBR'].toString();
    		//destroying container
    		delete tmpArray;
    	}
    	//adding sound object
    	mp3Sound =new Sound(this);
    	mp3Sound.loadSound(fileName,true)
    	mp3PauseSound = new Sound();
    	mp3PauseSound = mp3Sound;
    	mp3Sound.onSoundComplete=function(){
    		songIndex++;
    		if(songIndex<songIndexArray.length){
    			playSong(songIndex);
    		}else{
    			songIndex = 0;
    			playSong(songIndex)
    		}
    	}
    }

  9. #9
    Senior Member
    Join Date
    Mar 2002
    Posts
    141
    this forum seems to crap out on some characters

    in the last if of the playsong function the compared value should be
    <songIndexArray.length){

  10. #10
    Senior Member
    Join Date
    Mar 2002
    Posts
    141
    wow -- it won't let me type less than

    'less than 'songIndexArray.length){

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