A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Help me with the correct syntax please.

  1. #1
    Senior Member flipsideguy's Avatar
    Join Date
    Dec 2000
    Location
    Sweden
    Posts
    834

    Help me with the correct syntax please.

    Hi,

    I can't get this right. What am I doing wrong? Any help is much appreciated!

    Thanks,

    /Flip

    XML
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <port>
     <set>
      <image piece="imgA1.jpg" />
      <image piece="imgA2.jpg" />
     </set>
    </port>
    <port>
     <set>
      <image piece="imgB1.jpg" />
      <image piece="imgB2.jpg" />
     </set>
    </port>
    AS
    PHP Code:
    xmlParse = function (xmlObj) {
        
    aNode xmlObj.childNodes;
        
    len1 aNode.length;
        for (var 
    0!= len1n++) {
            
    piece[n] = [];
            
    len2 aNode[n].firstChild.childNodes.length;
            for (var 
    0!= len2j++) {
                
    piece[n][j] = aNode[n].firstChild.childNodes[j].attributes.piece;
            }
        }
        
    trace(piece[1][1]); // traces undefined

    Last edited by flipsideguy; 07-01-2008 at 04:43 PM.
    Flipsideguy

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    tests OK here using -
    PHP Code:
    _xml = new XML();
    _xml.ignoreWhite true;
    _xml.load("test.xml");

    piece = [];

    _xml.onLoad = function () { 
        
    aNode this.childNodes
        
    len1 aNode.length
        for (var 
    0!= len1n++) { 
            
    piece[n] = []; 
            
    len2 aNode[n].firstChild.childNodes.length
            for (var 
    0!= len2j++) { 
                
    piece[n][j] = aNode[n].firstChild.childNodes[j].attributes.piece
            } 
        } 
        
    trace(piece[1][1]); // traces imgB2.jpg 


    /* produces this array

    Variable _level0.piece = [object #2, class 'Array'] [
        0:[object #3, class 'Array'] [
          0:"imgA1.jpg",
          1:"imgA2.jpg"
        ],
        1:[object #4, class 'Array'] [
          0:"imgB1.jpg",
          1:"imgB2.jpg"
        ]
      ]

    */ 

  3. #3
    Senior Member flipsideguy's Avatar
    Join Date
    Dec 2000
    Location
    Sweden
    Posts
    834
    Thanks, I had some errors in my XML, as well as elsewhere in my code

    /Flip
    Flipsideguy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center