4 Replies Latest reply on May 3, 2007 12:35 AM by MurMeeKeer

    adding a variable an instance name

    NickTheNameless Level 1
      i have a variable that is my flash movie is retreiving (well, hopefully....i'm having troubles with the loadVariables)....anyweezer, the variable is named "id". i would like to add the value of this variable to then end of a text string and then use it as reference to an instance name.

      for example, i have movie clip with an instance name of TTMO110333. if the ID variable had a value of 110333, how could i use that in actionscript to allow me to refer to the latter part of the instance name with the variable?

      something to the effect of....

      on(rollOver) {
      this."TTMO"+id._visible = true;
      }
        • 1. Re: adding a variable an instance name
          MurMeeKeer Level 1
          You could use the eval function.

          eval("TTMO"+id.toString())._visible=true
          • 2. Re: adding a variable an instance name
            Devdoc
            Or try this:

            this["TTMO"+id]._visible = true;
            • 3. Re: adding a variable an instance name
              NickTheNameless Level 1
              thanks for your help, but neither solution is working for me. i think it may be because i'm using this in a function for a movie clip, to make it act as a button. i am also having problems getting getURL() to open a blank page inside a function for a movie clip like this as well. is there something i need to do differently if i'm trying to apply this to a movie clip? here's my AS....

              this.loadVariables("linkCCdisplay.php","POST"); //this gets 3 variables: url1, title1, and id1

              TTbutton1.onRelease = function() {
              TTbutton1.getURL(url1, _blank);
              }; //the "blank in this doesn't work, it goes to the url, just not in a new window

              TTMO110333._visible = false; //this refers to a movie clip that is on the same stage with an instance name of TTMO110333

              myInterval = setInterval (TTMO,15);

              function TTMO () {
              TTMO110333._x -= (TTMO110333._x - _xmouse)/10;
              TTMO110333._y -= (TTMO110333._y - _ymouse)/10-2;
              }

              TTbutton1.onRollOver = function() {
              this["TTMO"+id1]._visible = true;
              } //this refers to a movie clip with an instance name of TTbutton1, i would like to make the clip visible only while the mouse is over the movie clip i'm trying to get to act as a button

              any ideas on how to solve these problems? thanks again for your time.

              • 4. Re: adding a variable an instance name
                MurMeeKeer Level 1
                Hi, use this.

                TTbutton1.onRollOver = function() {
                eval("TTMO"+id1)._visible = true;
                }