【发布时间】:2013-12-26 14:08:07
【问题描述】:
protected function initView(event:ViewNavigatorEvent):void
{
// Api Call
NFLScore.url="http://api.nfldata.apiphany.com/trial/XML/ScoresByWeek/2013REG/14" +
"?key=BDAE4263-4522-45B9-96FF-01F0DFB0F610";
NFLScore.send();
}
protected function NFLScore_resultHandler(event:ResultEvent):void
{
// Alle items en Labels value geven
myData=event.result.ArrayOfScore.Score;
}
protected function NFLScore_faultHandler(event:FaultEvent):void
{
// TODO Auto-generated method stub
printUit.text = "foute zoek opdracht";
}
//////// End ////////
///////////////////////// API CALL /////////////////////////
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="NFLScore" fault="NFLScore_faultHandler(event)"
result="NFLScore_resultHandler(event)" resultFormat="e4x" />
</fx:Declarations>
<s:actionContent>
<s:Button id="Score" icon="assets/Score.png" click="Score_clickHandler(event)" />
</s:actionContent>
<s:Label id="printUit"/>
<s:TextArea height="100%" width="100%" id="txtResult" text="{NFLScore.lastResult.Score.AwayScore}"/>
</s:View>
Result:
<AwayScore xmlns:i="http://www.w3.org/2001/XMLSchema-instance">20</AwayScore>
<AwayScore xmlns:i="http://www.w3.org/2001/XMLSchema-instance">26</AwayScore>
<AwayScore xmlns:i="http://www.w3.org/2001/XMLSchema-instance">21</AwayScore>
想要: 输出: 20 26 21
情况:我正在调用 API,该 API 将结果 (XML) 作为主节点 ArrayOfScore 在我想要的日期之后的分数。但我不断收到错误“TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@c1e1fd1 to mx.collections.ArrayCollection.”
【问题讨论】:
-
myData定义为什么?您的错误是由 TextArea 或NFLScore_resultHandler内部的绑定触发的吗? -
我不认为您能够将 XMLList 转换为 ArrayCollection。您是否尝试过 XMLListCollection?
标签: xml apache-flex