Skip to main content
Participant
May 8, 2011
Question

Actions depending on input text values.

  • May 8, 2011
  • 1 reply
  • 1382 views

Hi again.

I have started to use input texts and passing them to outputs etc.

I was wondering, is there a way in AS2, to, for example

if someone enters a value that's between 150 and 200. Accepts it, and the code somehow recognizes the range

if value from 150 to 200, perform a function (for example setProperty on something to visible true)

a different function would apply if someone enters a value between 100 to 150.

thanks

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 9, 2011

sure.  just convert the input to a number (by default, it's a string):

submit_btn.onRelease=function(){

var n:Number=Number(yourinputtextfield.text);

if(n>=150&&n<=200){

//do something

} else {

//do something else

}

}

aneelbakshi
Inspiring
May 12, 2011

Yes

input_txt.onChanged=function(){

     if(Number(this.text)>150 &&  Number(this.text)<200){

          dosometing

     }

else if(Number(this.text)>100 &&  Number(this.text)<150){

          dosometing

     }

else{

          dosometing

     }

}

Try this

kglad
Community Expert
Community Expert
May 14, 2011

i'm sure you're trying to be helpful but that's not helpful.