Problem parsing XML data to Multi dimensional array

Posted by Cam on Stack Overflow See other posts from Stack Overflow or by Cam
Published on 2010-03-16T23:55:25Z Indexed on 2010/03/17 0:01 UTC
Read the original article Hit count: 248

Filed under:
|
|
|
|

Hi there,

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].@yPos});
 }
}

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

© Stack Overflow or respective owner

Related posts about as3

Related posts about flash-cs3