0
votes

I am trying to get this result:

You can type a number in a TLF textfield

var a:int

a=100

totalScore.text = String (typedNumber-=a)

Say you typed 40. The result would be 60.

I tried this:

var inzet_blackjack:Number = 0;
var inzet_blackjack:TextField = eval("myInput"+inzet_blackjack);
totalScore.text = String (inzet_blackjack-=a) //inzet_blackjack = typedNumber

so basically I am trying to save the number in the textfield as an Integer

this is the error I am getting:

Scene 1, Layer 'Layer 1', Frame 6, Line 138 1151: A conflict exists with definition inzetBlackjack in namespace internal.

EDIT: I see that I am also using Action Script 2.0 again. But Its supposed to be in ActionScript 3.0.. ^^

1
post full example you are hard to follow I don't even see where you are doing your calculations. - The_asMan

1 Answers

0
votes

You are getting that error because you have two variables with the same name. inzet_blackjack is used for your number and your textfield. Give them different names to fix that error.

To treat a value from a text field as a number you need to cast it as such. Here is an example:

var a:Number = 100;
var inputTextField:TextField; // assuming this holds a value
a -= Number(inputTextField.text);
totalScore.text = a.toString();

Also note that AS3 has no eval function.