A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How to reference clips with more than one variable in name?

  1. #1
    I Am
    Join Date
    Nov 2000
    Posts
    68

    How to reference clips with more than one variable in name?

    Hi, I have a script with mutilpe loops and I need to be able to access an object that's created dynamically with more than one variable... is this possible?

    For example, say I have a clip on the root like this: _root.clip1.clip2

    I need to access that with variables, like this:

    root[var1][var2]

    but that's not working for me.


    Any ideas?
    -Miz

  2. #2
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    code:

    var first="clip1";
    var second="clip2";
    _root[first][second].gotoAndPlay(2);



    K.

  3. #3
    I Am
    Join Date
    Nov 2000
    Posts
    68
    Thanks for the speedy reply.... your suggestion works, but I think I was too vague with my problem. Here is my actual situation:

    1.
    I load an XML file that looks like this:

    Code:
    <root>
       <listing>
          <listingItem1> Data </listingItem1>
       </listing>
       <listing>
          <listingItem1> Data </listingItem1>
       </listing>
    </root>
    2.
    I need to parse this data into an object called "listingData" in the form of:
    listingData.l1.listingItem1
    listingData.l2.listingItem1
    etc.

    Since all of the <listing> tags are the same I'm creating names for them during the parse:

    Code:
    for (i=1; i<=numListings; i++) {
    		for (j=0; j<listingNode.childNodes.length; j++) {
    			listingData["l"+i][listingNode.firstChild.nodeName] = listingNode.firstChild.nodeValue;
                            listingNode = listingNode.firstChild.nextSibling;
    		}
                    listingNode = listingNode.nextSibling;
    }
    But it's not working and I think it has to do with this:

    Code:
    listingData["l"+i][listingNode.firstChild.nodeName] = listingNode.firstChild.nodeValue;
    What do you think?
    -Miz

  4. #4
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    What is listingData? And where do you create it?

    K.

  5. #5
    I Am
    Join Date
    Nov 2000
    Posts
    68
    Thanks for the help but I've changed everything around and am doing it with multiple objects.

    Hopefully it'll work better!
    -Miz

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