3 Replies Latest reply on Feb 16, 2007 12:23 PM by yogi bear

    dynamic text variable

    yogi bear Level 1

      I have a dynamic text box call "color.txt" at the root and two Movie clip buttons one called Red and one called Yellow.
      When I press the button the name of the button is passed to the text box. When I press the second button the
      name is not replaced. Do I have to create a seperate function to do this or is there another way?

      Thanks,

      _root.red.onPress = function(){
      _root.colorTxt.text = "Red";
      }


      _root.yellow.onPress = function(){
      _root.colorTxt.text = "Yellow";
      }
        • 1. Re: dynamic text variable
          injpix Level 3
          “I have a dynamic text box call "color.txt"…”

          It looks like you have a textbox called “colorTxt” according to your code. Other then that the code works for me.
          • 2. Re: dynamic text variable
            yogi bear Level 1
            Your right the dynamic text box is "colorTxt" , sorry.

            I just tried it again and it doesn't work. If you have a minute make it and see.
            It needs code to refresh the type variable. I thought that would be automatic like loading a movie.

            hmmmm.
            • 3. Re: dynamic text variable
              yogi bear Level 1
              I got it working like this.

              var colors:Array = ["red", "yellow"];

              var currentColor:Number;

              function changeButton(newColor:Number) {
              currentColor = newColor;
              _root.colorTxt.text = updateText();
              }

              _root.red.onPress = function(){
              changeButton(0);

              }


              _root.yellow.onPress = function(){
              changeButton(1);

              }


              function updateText():String {
              var newText:String;
              newText = colors[currentColor];


              return newText;

              }