Skip to main content
January 24, 2014
Answered

How to make a button that controls the value of a dynamic text box

  • January 24, 2014
  • 1 reply
  • 441 views

Hey fellas

I wanted to make a bill maker .. sort of for myself . I have a few products lets say and I would like to click on them and by clicking on those buttons I would to see numbers add up in a dynamic text box and so I could keep track of the value inside the box.

Lets say we have 2 buttons . by clicking the 1st and 2nd I want to get 12 in my text box and by clicking 2nd and 1st I would like to get 21 in my box .

Is this atall possible with AS2 ?

please guide me through

Thanks.

This topic has been closed for replies.
Correct answer kglad

sure:

tf.text=""; //tf is your textfield that displays the results of your movieclip button clicks

for(var i:Number=0;i<9;i++){

this["btn_"+i].ivar=i;  // use movieclip buttons btn_1, btn_2,..,btn_9

this["btn_"+i].onRelease=btnF;

}

function btnF():Void{

tf.text+=this.ivar;

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 24, 2014

sure:

tf.text=""; //tf is your textfield that displays the results of your movieclip button clicks

for(var i:Number=0;i<9;i++){

this["btn_"+i].ivar=i;  // use movieclip buttons btn_1, btn_2,..,btn_9

this["btn_"+i].onRelease=btnF;

}

function btnF():Void{

tf.text+=this.ivar;

}