Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Senior Member zionlocke's Avatar
    Join Date
    Jan 2003
    Location
    .: l33t Basement :.
    Posts
    736
    Member #
    483
    Liked
    3 times
    I'm having a little trouble finding the xml data.

    Code:
    stopLoad=0;
    if(stopLoad == 0){
    	doc = new XML();
    	doc.load("score.xml");
    	stopLoad++;
    }
    
    _root.time = doc.childNodes[0].childNodes[0].childNodes[0];
    _root.date = "Jan 15";
    _root.sport = "Basketball";
    _root.team1 = "Team1";
    _root.team2 = "Team2";
    _root.score1 = "120";
    _root.score2 = "15";
    The XML file

    Code:
    <?xml version="1.0" ?>
    <NewDataSet>
    	<SCHEDULE> 
    		<SCH_TIME>7:00 pm</SCH_TIME>
    		<SCH_DATE>Jan 15</SCH_DATE>
    		<SCH_SPORT>Basketball</SCH_SPORT>
    		<SCH_TEAM1>Team1</SCH_TEAM1>
    		<SCH_TEAM2>Team2</SCH_TEAM2> 
    		<SCH_SCORE1>120</SCH_SCORE1>
    		<SCH_SCORE2>15</SCH_SCORE2>
    	</SCHEDULE>
    </NewDataSet>
    Cheers, zionlocke :chinese:
    Links: Zion Creation | Blog

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Okie dokie... well in flash, you can't access element nodes as properties like that, only attributes. For that actionScript, your XML would have to look like this:

    Code:
    <schedule
      time="7:00 pm" date="Jan 15"
      sport="Basketball
      team1="Team1" team2="Team2" 
      score1="120" score2="15" />
    Although really, you should reconsider your xml design altogether... unless this is just an experiment.

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    PS, try using trace("Hello World"); on your data to test everything out.

  5. #4
    Senior Member zionlocke's Avatar
    Join Date
    Jan 2003
    Location
    .: l33t Basement :.
    Posts
    736
    Member #
    483
    Liked
    3 times
    Well, I did what you suggested. The reason why my xml is weird is because it is pulled out of an oracle db. I'm still havgin problems reading the xml file. I'll post an update on my code, and I will get back to work on it.

    nm, I have solved the problem
    Cheers, zionlocke :chinese:
    Links: Zion Creation | Blog

  6. #5
    Senior Member zionlocke's Avatar
    Join Date
    Jan 2003
    Location
    .: l33t Basement :.
    Posts
    736
    Member #
    483
    Liked
    3 times
    how do I convert the attributes to Strings?

    what I mean is, how do I get stuff from xml into dynamic textfields, nothing is showing.

    nm, again. I see the answer. As reference to everyone else, you MUST pull variables from xml in the onload function.
    Cheers, zionlocke :chinese:
    Links: Zion Creation | Blog

  7. #6
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Ok, I got it workin for ya. Try this:
    Code:
    doc = new XML();
    doc.ignoreWhite = true;
    doc.load("scores.xml");
    doc.onLoad = function () {
    	parseScores(doc);
    }
    stop();
    
    // Parses a scores XML document
    function parseScores(doc) {
    	if (doc.hasChildNodes()) {
    		for (var i = 0; i < doc.childNodes.length; i++) {
    			var item = doc.childNodes[i];
    			if (item.nodeName.toLowerCase() == "schedule") {
    				trace(item);
    				trace(item.attributes['SCH_TIME']);
    				trace(item.attributes['SCH_DATE']);
    				trace(item.attributes['SCH_SPORT']);
    				trace(item.attributes['SCH_TEAM1']);
    				trace(item.attributes['SCH_TEAM2']);
    				trace(item.attributes['SCH_SCORE1']);
    				trace(item.attributes['SCH_SCORE2']);
    			} else {
    				parseScores(item);
    			}
    		}
    	}
    }

  8. #7
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Ugh... I wish you had solved it before I started workin on it !!! :-P

  9. #8
    Senior Member zionlocke's Avatar
    Join Date
    Jan 2003
    Location
    .: l33t Basement :.
    Posts
    736
    Member #
    483
    Liked
    3 times
    Thank you very much transio for all of your help! I'm sorry I figured it out already. It's cool that you have learned a lot about flash.

    Size Stats:
    3kb scoreboard.fla
    1kb scores.xml

    Ok, I'll show you my final code, with the final xml version

    scoreboard.fla *Frame 1*
    Code:
    stop();
    
    	timeArray = new Array();
    	dateArray = new Array();
    	sportArray = new Array();
    	team1Array = new Array();
    	team2Array = new Array();
    	score1Array = new Array();
    	score2Array = new Array();
    	linkArray = new Array();
    	
    	var loopVar = 0;
    	var maxVar;
    
    	doc = new XML();
    	doc.onLoad = newStats;
    	doc.ignoreWhite = true;
    	doc.load("scores.xml");
    
    //function to get to the root node and the childnodes
    function newStats() {
    	//trace("YOU ROCK!!!");
    	maxVar = this.childNodes[0].childNodes.length;
    	//loop going through the xml file whereby childNodes.length is the number of child nodes
    	for (var count01=0; count01<=this.childNodes.length; count01++) {
    		for(var count02=0; count02<=this.childNodes[0].childNodes.length; count02++){
    			timeArray.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_TIME);
    			dateArray.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_DATE);
    			sportArray.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_SPORT);
    			team1Array.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_TEAM1);
    			team2Array.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_TEAM2);
    			score1Array.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_SCORE1);
    			score2Array.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_SCORE2);
    			linkArray.push(doc.childNodes[count01].childNodes[count02].attributes.SCH_LINK);
    		}
    	}
    	_root.gotoAndPlay(2);
    }
    scoreboard.fla *Frame 2*
    Code:
    _root.linkButton.onRelease = function() {
    	trace(loopVar);
    	getURL(linkArray[loopVar-1]);
    }
    
    if(loopVar == maxVar){
    	loopVar = 0;
    }
    
    	_root.time = timeArray[loopVar];
    	_root.date = dateArray[loopVar];
    	_root.sport = sportArray[loopVar];
    	_root.team1 = team1Array[loopVar];
    	_root.team2 = team2Array[loopVar];
    	_root.score1 = score1Array[loopVar];
    	_root.score2 = score2Array[loopVar];
    
    if(loopVar!= maxVar){
    	loopVar += 1;
    }
    scoreboard.fla *Frame 60*
    Code:
    stop();
    _root.gotoAndPlay(2);
    scores.xml
    Code:
    <?xml version="1.0" ?>
    <NewDataSet>
    	<SCHEDULE SCH_TIME="7:00 pm" SCH_DATE="Jan 15" SCH_SPORT="Basketball" SCH_TEAM1="Team1" SCH_TEAM2="Team2" SCH_SCORE1="120" SCH_SCORE2="15" SCH_LINK="http://www.google.com" />
    	
    	<SCHEDULE SCH_TIME="9:00 pm" SCH_DATE="Jan 20" SCH_SPORT="Basketball" SCH_TEAM1="Team1" SCH_TEAM2="Team2" SCH_SCORE1="110" SCH_SCORE2="30" SCH_LINK="http://www.zioncreation.com" />
    	
    	<SCHEDULE SCH_TIME="6:30 pm" SCH_DATE="Feb 2" SCH_SPORT="Basketball" SCH_TEAM1="Team1" SCH_TEAM2="Team2" SCH_SCORE1="125" SCH_SCORE2="2" SCH_LINK="http://www.webdesignforums.net" />
    </NewDataSet>
    All of this code is fully functional
    Cheers, zionlocke :chinese:
    Links: Zion Creation | Blog


Remove Ads

Posting Permissions

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

Search tags for this page

flash xml chinese

,

flash xml problems

Click on a term to search for related topics.
All times are GMT -6. The time now is 11:44 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com