# True/False

Just a very simple question:\rWhat does the “something” = true\ror\r"something" = false\rmean?\rAnd what do true and false stand for.\r\rDon Albino

true and false are booleans. true and false can be replaced with 1 and 0 (respectively) in a mathematical equasion.\rexample:\rmyVariable = “hello”==“hello”\rtrace(myVariable);\rmyVariable++;\rtrace(myVariable);\rwill return:\rtrue\r2\r\rbooleans can be used in conditionals like switches with only an on or off state.\rlight = true;\rif(light){\rtrace (“the light is on”);\r} else {\rtrace (“the light is off”);\r}\rwill trace:\rthe light is on\rbecause the variable ‘light’ is set to ‘true’.\rhope that helps!\r:) \rjeremy

OK\rYou totally lost me, since I don’t have a clue, what “++” means, what the trace is, what a boolean is ( I have English as a second language and nobody could tell me what a boolean is) and the will return part and all that stuff.\rTry to explain it in an easier example. (the second one was better, but still too weird)\r\rThanks for your help anyway.\r(it is the thought that counts)\r\rDon Albino

Well, booleans are… true and false. Basically, a boolean has these 2 values only. Well, in terms of numbers, 1 is equivalent to true, and 0 to false.

example:\rmyVariable = “hello”==“hello”\r// myVariable is the result of the test : Is the string “hello” equal \r// to the string “hello”, which will give true if it’s a boolean and 1\r//if it’s a number\r\rtrace(myVariable);\r//This displays the value of myVariable in the output window\r\rmyVariable++;\r//This increments myVariable by 1. It’s equivalent to \r//myVariable = myVariable + 1. ie 2.\r//2 is not 0 so it will be true. Hence :\r\rtrace(myVariable);\rwill return:\rtrue\r2\r\rbooleans can be used in conditionals like switches with only an on or off state.\rlight = true;\rif(light){ //equivalent to if light==true or light!=0\rtrace (“the light is on” );\r} else {\rtrace (“the light is off” );\r}\rwill trace:\rthe light is on\rbecause the variable ‘light’ is set to ‘true’.
I hope it’s clearer now.\r\rpom 0]

actually, in terms of numbers ‘0’ (zero) is false, and any other number is true. however ‘true’ only has a numeric value of ‘1’.\r:) \rjeremy

So basically you want to say, that false is “0” and true is the rest.\rBut why would you use true/false then if oyu could just write a number instead of it.\r\rSo if want something to happen when hello == hello, then I would write it like that?:\r\r\rif (“hello” == “hello” == true) {\r trace (“Hello”);\r}\r\r\rI hope that is just kind of close. Though I didn’t completely understand it yet I thank you for the help.\r\rDon Albino

Not exactly.\ryOu wrote :\rSo if want something to happen when hello == hello, then I would write it like that?:\r\rif (“hello” == “hello” == true) {\rtrace (“Hello”);\r}\r\rif (“hello” == “hello”) {\rtrace (“hello”) ;\r}\ris correct. The meaning of == is : is this equal ? So “hello”==“hello” will return “true”, or “1”, while “hello”==“sausage” will return “false” or “0”.\rYou have to understand that in if (something) …, the “== true” you put is implied. the “something” has to be true for the if to execute the code. I have the horrible feeling that I’m not clear at all.\r\rpom 0]

Well…\r\rI think I got it now.\rBut the trace is not necessary, is it?\rI could as well use a gotoAndPlay, or any other action, right?\rThe thing is, that I already used this in things like:\r\rx = “2”;\r\r(now the button)\r\ron (release) {\r&nbsp &nbsp &nbsp &nbsp if (x == 2) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp gotoAndStop (2);\r&nbsp &nbsp &nbsp &nbsp }\r}\r\r\rthat basically is true or false, is it not?\r\rI think I got the true or flase part now, but why would you write “true” or “false” instead of just “0” or “1”?\r\rDon Albino\r\r(i think I am stupid)

i write out true and false when the variable is only being used as a boolean. sometimes i will check a variable as if it were a boolean when it’s not a boolean. like if i need to know if a variable has a numeric value or not (strings evaluate to false).\r:) \rjeremy

And what are strings?

x=2 : number\rx=“2” : string.\rpom 0]

And where is the difference in Flash?\rWhen would you use a string and when number?

paste this into a new blank movie and test it:\r// here’s the difference:\r// a number as a number…\rnTwo = 2;\r// a number as a string…\rsTwo = “2”;\r// adding the numbers together…\rnAdd = nTwo+nTwo;\r// adding the strings together…\rsAdd = sTwo+sTwo;\r// output the variables…\rtrace ("the number = “+nAdd+”
the string = "+sAdd);\r// the value of ‘nAdd’ is 4, the value of ‘sAdd’ is “22”.\r\rwhen you add the number 2 to the number 2 you get 4.\rwhen you add the string 2 to the string 2 you get 22.\r:) \rjeremy

Thanks again. That made it clear.\rFor what would I use a string then?

I’m not sure if you got the basics:\r\rTrue and False are same as Yes and No:\rTrue = Yes\rFalse = No\r\rNumbers can be used in mathematical scripts.\rStrings are basicly words. These can be used for text-related actions.\r\rnum1 = 2\rnum2 = 4\rword1 = “This is”\rword2 = " a String"\r\rsum = num1 + num2\rsentence = word1 + word2\r\rsum will show: 6\rsentence will show: This is a String