1 Reply Latest reply on May 9, 2007 2:40 AM by ggshow

    static text | variable | static text

    NickTheNameless
      i'm thinking i need a simple actionscript to do this but i'm not exactly sure. i have a dynamic text field that is loading a variable named count. however i would like to place static text on either side of the value of the variable. since the variable is an integer that will only increase, it's horizontal width will also increase as well. i can't very well place two strings of static text on either side of a variable that will grow in width over time. does that make sense?

      essentially, i want to have a dynamic text box display a string of text, then the value of a variable (that will change in length), then another string of text, but i would like it to all be seamless, looking as if i just typed the whole sentence in a word processor. thanks for your time!
        • 1. Re: static text | variable | static text
          ggshow Level 2
          let say you have a dynamic text field with instance name my_txt
          when you want to increase the value, you run my_txt.text++;
          when you want to decrease the value, you run my_txt.text--;

          now, convert the dynamic text field to a movieclip symbol,
          set the instance name my_mc

          now, to set the value of text, we should use
          my_mc.my_txt.text++;

          but we are not going to set the value in this way.
          now, go into my_mc movieclip, select the 1st frame, attach script:


          var actualValue:Number = Number(this.my_txt.text);
          var displayValue:String = "";
          function setValue(d) {
          actualValue += d;
          displayValue = "something"+actualValue+"something";
          my_txt.text = displayValue;
          }
          setValue(0);


          go back to your maim timeline. and now,
          when you want to increase the value, use my_mc.setValue(1);
          when you want to increase the value, use my_mc.setValue(-1);