PDA

View Full Version : Another AS problem



Psykloak1
May 14th, 2002, 06:01 PM
Ok, I have two text boxes, one has a number in it (10) and the other one has -3. When i try to add the two together, i get 10-3, not 7. How do I fix this?

Iammontoya
May 14th, 2002, 08:43 PM
I'm guessing you have two input boxes, or two dynamic boxes. I named the instances of mine inputa and inputb respectively. In one, I entered 10 (inputa) and in the other I entered 3 (guessing that's what you wanted).

Now.. you say you wanted to substract, as in 10-3?

trace(inputa.text-inputb.text);

However, the correct way, I believe, will be to use the number fuction..

trace(Number(inputa.text-inputb.text);

both of these will yield 7

Hope it helps.

"My name is Inigo Montoya. You killed my father. Prepare to die!"

Psykloak1
May 15th, 2002, 03:59 AM
thats not what I needed but it helped enough for me to figure it out.

What I wanted to do was add two dynamic boxes, one was 10 and the other, -3 so it whould be 10+(-3) I wanted to add a negative number. The problem was it was treating the two numbers as strings instead of integers, but the Number thing worked, thanks. ;)

Psykloak1
May 15th, 2002, 07:17 PM
ok, heres my next problem.

((x is a dynamic text feild))



&nbsp &nbsp &nbsp &nbsp if (_parent.x="circle") {

&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp gotoAndPlay (32);

&nbsp &nbsp &nbsp &nbsp } else {

&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp gotoAndPlay (33);

&nbsp &nbsp &nbsp &nbsp }



For some reason, when it runs this code, it sets x to "circle" instead of w/e else it was.

I did some tests to make sure and it is deffinatly the "if (_parent.x="circle") {" that changes it.

Any ideas why?

Iammontoya
May 15th, 2002, 07:37 PM
change variable names. In other words, dont use x... use something else. I have to check, but x may be reserved.

Also, if you're trying to check if a statement is true, use ==
instead of =

Psykloak1
May 15th, 2002, 07:55 PM
yup, it was that second = that messed my up, I'm used to the Basic style of syntax and we dont use 2 ='s