Skip to main content
Participating Frequently
July 20, 2010
Question

Displaying text based on variable

  • July 20, 2010
  • 1 reply
  • 457 views

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?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 20, 2010

if your textfield has instance name tf use:


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

k_mathisAuthor
Participating Frequently
July 22, 2010

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.

kglad
Community Expert
Community Expert
July 22, 2010

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