开发者

Error parsing XML data to Multi dimensional array

i'm still transitioning from as2 to as3, i'm having trouble with parsing XML data to Multi dimensional array, below is the onComplete handler which is succesfully tracing 'event.target.data' but outputs 'A term is undefined and has no properties' when tracing _vein_data[0][0].xPos . I'm guessing there is a easier way to approach it than this attempt

private function on_xml_completed(event:Event):void {
   var XMLPoints:XML = new XML(event.target.data);

   for ( var i:int = 0; i < XMLPoints.shape.length(); i++ )
    {
     var shapeArray:Array = new Array();
 _vein_data.push(shapeArray);

    for ( var j:int = 0; j < 4; i++ )
    {
  _vein_data[i].push({'xPos':XMLPoints.shape[i].point[j].@xPos,
          'yPos':XMLPoints.shape[i].point[j].@yP开发者_如何学Goos});
 }
}


 trace(_vein_data[0][0].xPos)
   loadAsset();
  }

here's a portion of my XML;

<items>
 <shape>
  <point xPos="60" yPos="23" />
  <point xPos="65" yPos="23" />
  <point xPos="93" yPos="85" />
  <point xPos="88" yPos="87" />
 </shape>
 <shape>
  <point xPos="88" yPos="87" />
  <point xPos="92" yPos="83" />
  <point xPos="145" yPos="174" />
  <point xPos="138" yPos="175" />
 </shape>
 <shape>
  <point xPos="138" yPos="175" />
  <point xPos="143" yPos="171" />
  <point xPos="147" yPos="211" />
  <point xPos="141" yPos="212" />
 </shape>
</items>  

thank you in advance for any guidance on this Cam


ok resolved, the problem was the incremented i on the nested for loop, instead of j++;

my bad.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜