2 Replies Latest reply on May 18, 2006 1:05 PM by Nateb

    dynamic pathnames, dot syntax

    Nateb
      I'm using Flash 8, and creating a dynamic XML driven menu.

      I can't for the life of me figure out the syntax to make a 2 dimensional path to a movieclip.

      I can reference a movieclip dynamically with: _root["main"+i].label.text
      but how can I reference a movieclip like this:

      _root.main1.subBut1_1.label.text

      Where "main1" AND "subBut1_1" are dynamically written.

      I've tried _root["main"+i]["subBut"+i+"_"+t] and _root["main"+i].["subBut"+i+"_"+t], no dice. I would think it was pretty common to try and do something like this.
        • 1. Re: dynamic pathnames, dot syntax
          TimSymons Level 1
          I'm fairly certain that I have used the _root["main"+i]["subBut"+i] method to refer to 2 or more dynamically created movieclips. I have been looking through my code but I beleive that it is a work, so I can't verify just yet. However, you might try this:

          var tempMC:MovieClip = _root["main"+i];
          tempMC["subBut"+i+"_"+t].label.text = "Test";

          I know this is an added step but it might get you going.

          Tim
          • 2. Re: dynamic pathnames, dot syntax
            Nateb Level 1
            That works, however here is the solution

            _root["main"+i]["subBut"+i+"_"+t].label.text = "Test";

            I am referencing "subBut", when I clearly named the new instance: "sub"

            _root["main"+i].attachMovie("subBut","sub"+i+"_"+t, this.getNextHighestDepth(),{_x:0, _y:ySub});

            My mistake *blush*