我被困住了。我正在调用一个外部ASP,提供体育赔率数据(目前编码为NBA),我通过舞台上的动态文本字段显示。我能够得到当天以及“团队与团队”将展示的那一天。在“团队与团队”之下,我希望显示“点数差价”和“积分总数”。我现在很困惑如何从文档调用我想要的两种类型的数据,所以只显示那两个。下面是我的XML,下面是Flash AS3代码。感谢任何帮助,谢谢! (我希望我的解释有帮助)
我无法附加屏幕截图,但基本上,当它运行时,文本字段现在看起来像这样:
12月13日的比赛 团队与团队 团队与团队 团队与团队
我希望它显示的内容:
12月13日的比赛 团队与团队 (积分)(总分) 团队与团队 (积分)(总分) 团队与团队 (点数差价)(总分)
//<<<<<<<<<<<<<≤(XML)
<?xml version="1.0" encoding="UTF-8"?>
<livefeedlines leagues="nba" periods="0" scores="N" popindex="Y" fromminutes="5" begindate="null" enddate="null" store="DEPOSIT">
<paramstr generator="ASP" generated="2012-12-12T15:45:32-08:00">'', '', '''nba''', '', '0', 'Y', 'B', 'N', 'Y', 5, -1, '', null, null, 'date asc', 0, 'DEPOSIT'</paramstr>
<game id="48037935" sporttype="Basketball" league="NBA" gamedate="2012-12-12T16:05:00-08:00" gamedow="4" status="O" team1rotnum="701" team1name="Brooklyn Nets" team1pitcher="" team2rotnum="702" team2name="Toronto Raptors" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T16:10:00-08:00" store="DEPOSIT" favoredteam="Brooklyn Nets">
<spread points="-7" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="185" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="-325" team2line="265" drawline="0" circled="N"/>
<popularity index="5"/>
</line>
</game>
<game id="48037936" sporttype="Basketball" league="NBA" gamedate="2012-12-12T16:05:00-08:00" gamedow="4" status="O" team1rotnum="703" team1name="Atlanta Hawks" team1pitcher="" team2rotnum="704" team2name="Orlando Magic" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T16:10:00-08:00" store="DEPOSIT" favoredteam="Atlanta Hawks">
<spread points="-5" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="189.5" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="-200" team2line="170" drawline="0" circled="N"/>
<popularity index="4"/>
</line>
</game>
<game id="48037937" sporttype="Basketball" league="NBA" gamedate="2012-12-12T16:05:00-08:00" gamedow="4" status="O" team1rotnum="705" team1name="Cleveland Cavaliers" team1pitcher="" team2rotnum="706" team2name="Indiana Pacers" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T16:10:00-08:00" store="DEPOSIT" favoredteam="Indiana Pacers">
<spread points="-7.5" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="189" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="290" team2line="-350" drawline="0" circled="N"/>
<popularity index="6"/>
</line>
</game>
<game id="48037938" sporttype="Basketball" league="NBA" gamedate="2012-12-12T16:35:00-08:00" gamedow="4" status="O" team1rotnum="707" team1name="Chicago Bulls" team1pitcher="" team2rotnum="708" team2name="Philadelphia 76ers" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T16:40:00-08:00" store="DEPOSIT" favoredteam="Philadelphia 76ers">
<spread points="-2" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="180.5" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="113" team2line="-133" drawline="0" circled="N"/>
<popularity index="9"/>
</line>
</game>
<game id="48037939" sporttype="Basketball" league="NBA" gamedate="2012-12-12T16:35:00-08:00" gamedow="4" status="O" team1rotnum="709" team1name="Los Angeles Clippers" team1pitcher="" team2rotnum="710" team2name="Charlotte Bobcats" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T16:40:00-08:00" store="DEPOSIT" favoredteam="Los Angeles Clippers">
<spread points="-8" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="200.5" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="-400" team2line="320" drawline="0" circled="N"/>
<popularity index="3"/>
</line>
</game>
<game id="48037940" sporttype="Basketball" league="NBA" gamedate="2012-12-12T16:35:00-08:00" gamedow="4" status="O" team1rotnum="711" team1name="Golden State Warriors" team1pitcher="" team2rotnum="712" team2name="Miami Heat" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T16:40:00-08:00" store="DEPOSIT" favoredteam="Miami Heat">
<spread points="-8" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="205" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="310" team2line="-380" drawline="0" circled="N"/>
<popularity index="1"/>
</line>
</game>
<game id="48037941" sporttype="Basketball" league="NBA" gamedate="2012-12-12T17:05:00-08:00" gamedow="4" status="O" team1rotnum="713" team1name="Denver Nuggets" team1pitcher="" team2rotnum="714" team2name="Minnesota Timberwolves" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T17:10:00-08:00" store="DEPOSIT" favoredteam="Minnesota Timberwolves">
<spread points="-4" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="200" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="151" team2line="-171" drawline="0" circled="N"/>
<popularity index="12"/>
</line>
</game>
<game id="48037942" sporttype="Basketball" league="NBA" gamedate="2012-12-12T17:05:00-08:00" gamedow="4" status="O" team1rotnum="715" team1name="Sacramento Kings" team1pitcher="" team2rotnum="716" team2name="Milwaukee Bucks" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T17:10:00-08:00" store="DEPOSIT" favoredteam="Milwaukee Bucks">
<spread points="-8" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="198" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="290" team2line="-350" drawline="0" circled="N"/>
<popularity index="13"/>
</line>
</game>
<game id="48037943" sporttype="Basketball" league="NBA" gamedate="2012-12-12T17:05:00-08:00" gamedow="4" status="O" team1rotnum="717" team1name="New Orleans Hornets" team1pitcher="" team2rotnum="718" team2name="Oklahoma City Thunder" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T17:10:00-08:00" store="DEPOSIT" favoredteam="Oklahoma City Thunder">
<spread points="-14.5" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="195.5" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="1400" team2line="-2400" drawline="0" circled="N"/>
<popularity index="8"/>
</line>
</game>
<game id="48037944" sporttype="Basketball" league="NBA" gamedate="2012-12-12T17:05:00-08:00" gamedow="4" status="O" team1rotnum="719" team1name="Dallas Mavericks" team1pitcher="" team2rotnum="720" team2name="Boston Celtics" team2pitcher="" ontv="Y" channel="ESPN" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T17:10:00-08:00" store="DEPOSIT" favoredteam="Boston Celtics">
<spread points="-6" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="197.5" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="200" team2line="-240" drawline="0" circled="N"/>
<teamtotals team1points="94.5" team1adj1="-115" team1adj2="-115" team2points="100.5" team2adj1="-115" team2adj2="-115" circled="N"/>
<popularity index="7"/>
</line>
</game>
<game id="48037945" sporttype="Basketball" league="NBA" gamedate="2012-12-12T17:05:00-08:00" gamedow="4" status="O" team1rotnum="721" team1name="Washington Wizards" team1pitcher="" team2rotnum="722" team2name="Houston Rockets" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T17:10:00-08:00" store="DEPOSIT" favoredteam="Houston Rockets">
<spread points="-10.5" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="206" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="525" team2line="-750" drawline="0" circled="N"/>
<popularity index="11"/>
</line>
</game>
<game id="48037946" sporttype="Basketball" league="NBA" gamedate="2012-12-12T18:05:00-08:00" gamedow="4" status="O" team1rotnum="723" team1name="Memphis Grizzlies" team1pitcher="" team2rotnum="724" team2name="Phoenix Suns" team2pitcher="" ontv="N" channel="" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T18:10:00-08:00" store="DEPOSIT" favoredteam="Memphis Grizzlies">
<spread points="-6.5" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="196" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="-260" team2line="220" drawline="0" circled="N"/>
<popularity index="10"/>
</line>
</game>
<game id="48037947" sporttype="Basketball" league="NBA" gamedate="2012-12-12T19:35:00-08:00" gamedow="4" status="O" team1rotnum="725" team1name="San Antonio Spurs" team1pitcher="" team2rotnum="726" team2name="Utah Jazz" team2pitcher="" ontv="Y" channel="ESPN" order="5">
<line periodnum="0" perioddesc="Game" periodwagercutoff="2012-12-12T19:40:00-08:00" store="DEPOSIT" favoredteam="San Antonio Spurs">
<spread points="-3.5" team1adj="-110" team2adj="-110" puckline="" circled="N"/>
<total points="209.5" team1adj="-110" team2adj="-110" circled="N"/>
<money team1line="-165" team2line="145" drawline="0" circled="N"/>
<teamtotals team1points="106.5" team1adj1="-115" team1adj2="-115" team2points="103" team2adj1="-115" team2adj2="-115" circled="N"/>
<popularity index="2"/>
</line>
</game>
</livefeedlines>
//&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;(FLASH AS3代码)
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
import flash.text.TextFormat;
import flash.text.TextField;
// http://feeds.justbet.cx/xml/getLiveFeedLines.asp?fromminutes=5&periods=0&scores=N&popindex=Y&leagues=nba
var tf:TextFormat = new TextFormat();
//var url:String = "sports.xml";
var url:String = "http://feeds.justbet.cx/xml/getLiveFeedLines.asp?fromminutes=5&periods=0&scores=N&popindex=Y&leagues=nba";
var request:URLRequest = new URLRequest(url);
var urlLoader:URLLoader = new URLLoader();
var xDoc:XMLDocument = new XMLDocument();
var statsArray:Array = new Array();
var team1:Array = new Array();
var team2:Array = new Array();
//statsArrary.length = 0; // removes ALL data from the array
tf.tabStops = [180, 240];
urlLoader.addEventListener(Event.COMPLETE, completeLoader);
urlLoader.load(request);
function completeLoader(e:Event): void {
xDoc.ignoreWhite = true;
var ldr:URLLoader = e.currentTarget as URLLoader;
var xmlDP:XML = new XML(ldr.data);
xDoc.parseXML(xmlDP.toXMLString());
statsArray = xDoc.childNodes[0].childNodes;
// trace("xml= " + xmlDP.game[0].@team1name);
var maxLine:Number = statsArray.length - 1;
for(var i:Number = 0; i < maxLine; i++) {
team1[i] = xmlDP.game[i].@team1name;
team2[i] = xmlDP.game[i].@team2name;
}
bindStats();
}
function bindStats() {
txtGames.tabEnabled = true;
txtGames.defaultTextFormat = tf;
txtGames.text = "Games for Dec. 13\n\n";
for(var i:uint = 0; i < team1.length; i++) {
txtGames.appendText(team1[i] + "\t vs. \t" + team2[i] + "\n"); //Displayed info
}
}
答案 0 :(得分:0)
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
import flash.text.TextFormat;
import flash.text.TextField;
// http://feeds.justbet.cx/xml/getLiveFeedLines.asp?fromminutes=5&periods=0&scores=N&popindex=Y&leagues=nba
var tf:TextFormat = new TextFormat();
var url:String = "sports.xml";
//var url:String = "http://feeds.justbet.cx/xml/getLiveFeedLines.asp?fromminutes=5&periods=0&scores=N&popindex=Y&leagues=nba";
var request:URLRequest = new URLRequest(url);
var urlLoader:URLLoader = new URLLoader();
var xDoc:XMLDocument = new XMLDocument();
var statsArray:Array = new Array();
var allData:Array = new Array();
//statsArrary.length = 0; // removes ALL data from the array
tf.tabStops = [180, 240];
urlLoader.addEventListener(Event.COMPLETE, completeLoader);
urlLoader.load(request);
function completeLoader(e:Event): void {
xDoc.ignoreWhite = true;
var ldr:URLLoader = e.currentTarget as URLLoader;
var xmlDP:XML = new XML(ldr.data);
xDoc.parseXML(xmlDP.toXMLString());
statsArray = xDoc.childNodes[0].childNodes;
// trace("xml= " + xmlDP.game[0].@team1name);
var maxLine:Number = statsArray.length - 1;
for(var i:Number = 0; i < maxLine; i++) {
allData[i] = {
team1_name: xmlDP.game[i].@team1name,
team2_name: xmlDP.game[i].@team2name,
spread: xmlDP.game[i].line.spread.@points,
total: xmlDP.game[i].line.total.@points
}
}
bindStats();
}
function bindStats() {
txtGames.tabEnabled = true;
txtGames.defaultTextFormat = tf;
txtGames.text = "Games for Dec. 13\n\n";
for(var i:uint = 0; i < allData.length; i++) {
txtGames.appendText(allData[i].team1_name
+ "\t vs. \t"
+ allData[i].team2_name
+ " (spread "
+ allData[i].spread
+ ") ( total "
+ allData[i].total
+ ")\n"); //Displayed info
}
}
享受!
许多数组team1
,team2
等合并为一个数组allData
的对象包含一个游戏的完整信息
使用Flash功能(http://www.nbilyk.com/e4x-example)