How do you use simple statements like IF, THEN, =, in flash? Also how do you use variables.
for example how would I do this in flash: IF A = 5 THEN...
How do you use simple statements like IF, THEN, =, in flash? Also how do you use variables.
for example how would I do this in flash: IF A = 5 THEN...
Hi,
Flash uses an "if/else" method instead of if/then. The format looks like this...
adding an else statement .....Code:if(some condition == true){ do something; }
So, Your demo would look like...Code:if(some condition == true){ do something; }else if(some other condition== true){ do something else; }
Now, without going too deeply into methods without confusion, I will simply mention that there is also a shorthand for if/else statements, known as "nested conditionals". Basically shorthand for the code samples posted above...Code:if(A==5){ execute code here; }else{ execute some other code; }
condition ? statement : alternative statement;
A==5 ? trace("A is 5") : trace("A is not 5");
Hope it helps
Regards
NTD
Can you have an if statement within an if statement?
e.g. if (condition) {if (another condition) {do something} }
the point is to have two conditions. Is there and AND statement?
e.g. IF A=1 AND B=5 or if (a = 1) and (b = 2) {do something}
Hi,
Yes, you can nest if statements within other if statements. One problem I notice is how your using the = sign. A single equals sign(=) assigns a value. A double equal sign(==) compares a value.
The above requires both conditions to be true before firing the code.Code:if(a==1 && b==5){ do something; }
The above is a nested if statement. The first condition must be true or the second if statement wont fire.Code:if(a==1){ if(b==2){ do something; } }
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks