3 Replies Latest reply on Jul 22, 2010 7:17 AM by kglad

    Displaying text based on variable

    k.mathis

      I have a variable defined as brushSize.  Depending on the value of brushSize, I want to display text in a dynamic text field that relates to its value.

       

      For brushSize values of 3, 13, 23, 33, and 43 I'd like to  display 1, 2, 3, 4, and 5 respectively.  I'm not really sure where to begin here, but I have tried and failed with something like this:

       

      if( brushSize == 3) {
          brushSizeDisplay("1")
      }
      

       

      Any suggestions?

        • 1. Re: Displaying text based on variable
          kglad Adobe Community Professional & MVP

          if your textfield has instance name tf use:

           


           

          if( brushSize == 3) {
              tf.text=1;
          }

           

           

          • 2. Re: Displaying text based on variable
            k.mathis Level 1

            When I open up a new flash document and start from scratch, it works fine.  But when I try to apply it to my existing project it isn't translating.  Here is the code for the variable that I wish to determine what specific text to display:

             

            var brushSize:Number = 23;
            var brushSizeMax:Number = 43;
            var brushSizeMin:Number = 3;
            function changeValue(pHow:Number){
                brushSize += pHow;
                if(brushSize > brushSizeMax){
                    brushSize = brushSizeMax;
                }
                if(brushSize < brushSizeMin){
                    brushSize = brushSizeMin;
                }
                brushSizeText.text = brushSize;
            }
            
            brushUp.onPress = function(){
                changeValue(10);
            }
            brushDown.onPress = function(){
                changeValue(-10);
            }  
            

             

            when I try

            if( brushSize == 3) {

                 brushSizeDisp.text=1;

            }

             

            I get no results.  brushSize is my variable, and brushSizeDisp is the instance name of a dynamic text field that I placed on the stage.

            • 3. Re: Displaying text based on variable
              kglad Adobe Community Professional & MVP

              use the trace() function to see find your error.