2012-12-13 31 views
1

我卡住了。我打电话给外部提供运动赔率数据(目前为NBA编码)的ASP,我通过舞台上的动态文本字段显示。我能够获得当天的成绩,以及“团队vs团队”将要展示的内容。在“团队vs团队”下方,我希望显示“点差”和“总点数”。我现在很困惑如何从文档中调用我想要的两种数据类型,以便这两种显示。下面是我的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> 

// < < < < < < < < < < < < < < < < < <(FLASH AS3 CODE)

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][email protected]); 
    var maxLine:Number = statsArray.length - 1; 
    for(var i:Number = 0; i < maxLine; i++) { 
     team1[i] = xmlDP.game[i][email protected]; 
     team2[i] = xmlDP.game[i][email protected]; 
    } 

    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
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][email protected]); 
    var maxLine:Number = statsArray.length - 1; 
    for(var i:Number = 0; i < maxLine; i++) { 
     allData[i] = { 
      team1_name: xmlDP.game[i][email protected], 
      team2_name: xmlDP.game[i][email protected], 
      spread: xmlDP.game[i][email protected], 
      total: xmlDP.game[i][email protected]   
     } 
    } 

    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 
    } 

} 

享受!

  1. 许多阵列,team1team2等组合成一个阵列对象allData包含在一个游戏的完整信息

  2. 充分利用XML数据与Flash能力(http://www.nbilyk.com/e4x-example