how (AS Q)
- Started
- Last post
- 24 Responses
- yah0
You have to populate a new var
var textfield1:String = "4";
var textfield2:Number = Number(textfield1);
if(textfield2 == 4) {
trace("It's now a number!");
}
- fusionpixel0
hey stewart, what is that IRC channel at? the #lfash channel
- fugged0
>> yeah, parseFloat would be fine too, but i wouldn't use parseInt.
I understand parseInt will provide you with only an integer and not a decimal. But, for this case, I think that's what he'd want.
- stewart0
oi, nice.
- SteveJobs0
it's a conditional operator
if the expression before the question mark is true, then the operand to the left of the colon is evaluation. adversely, if the expression is false, then the operand to the right of the colon is evaluated.
- stewart0
thanks for the shorthand Steve.
but can you please explain the last part
"?0:1"
- SteveJobs0
shorthand:
- stewart0
okay, here it is and it works.
http://pastebin.coconut.se/?id=3…thanks again!
- SteveJobs0
yeah, parseFloat would be fine too, but i wouldn't use parseInt.
- JamesEngage0
parseInt always works for me... especially if yopu're reading from a text file... and there may be a line break after the 4 ?
- stewart0
uh
Steve,when i trace your
Number(this.textfield.text)
it results in 0but it displays "4"
weird.
i only want to be able to change a variable in an external .txt document, to use that variable in an if statement.
- unfittoprint0
parseFloat dat motherfucker!%"#"#
http://www.ourfamilynet.ws/forum…
b.i.a.t.c.h
- SteveJobs0
carefull with parseInt, it will truncate your decimals.
- fugged0
mmm. need more coffee...
in my a/b example I meant to use parseInt. not parseFloat.
sorry.
- Kuz0
shouldn't it be
if (textfield = 4) {
gotoAndPlay(2)
}??
- fugged0
use parseInt()
a = "3"
b = parseFloat(a)+1;
trace(b);output: 4.
>>also with if ( textfield =="4" ) the value of the textfield is set to "4" instead of comparing it...
shouldn't be if you are using == and not =. a single = causes an assignment where == and === are for evaluating an expression.
- CyBrainX0
Try: gotoAndPlay([textfield]);
- stewart0
well Jobs, that's my problem.
also with if ( textfield =="4" ) the value of the textfield is set to "4" instead of comparing it...
- SteveJobs0
should work:
Number(txtFld.text)==Number(4)
or
txtFld.text=="4"
- SteveJobs0
or just check it against =="4" since that's how the textfield is probably evaluating it anyway.