Forum Topic: AS: Symbolic Operators

(1,947 views • 7 replies)

This topic is 1 page long.

<< < > >>
None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/20/05 06:43 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

AS: Main
Ok, in this tutorial you will be learning about some symbolic operators used in flash. I will cover these symbolic operators: !, >, <, ||, and &&. I will not cover the math symbols becuase they were already done in T-H's maths tutorial. So, I will explain the easy one first, the ! symbol.
-------------
!
Ok, in general, this operator is used to check if something is NOT a ceartain value. I will explain it to you by using this example:

Lets say one day you are at a baseball game and you break a lot of rules. The ump comes up to you and you say what rule did I break? The ump replies which rule didn't you break?

Im sorry if that isnt clear but I hope you get the picture.
-------------
In a code, the ! statement would look like this:

if(!something=something else){
//actions
}

What that does it flash will only do the actions if a variable does not equal a certain value. I hope you know not to use that exact code for anything cos it was a sample. You can easily combine it with your codes to make it work. Now, I will teach you the < and > statements.
-------------
< >
Ok, what this does is flash will check whether a value is greater than something if using the > symbol, or if a value is less than something if using the < symbol. You would want to use this becuase Instead of checking for every value greater than something which would take ages, you could use this one simple command to help you out.
-------------
In a code, it would look like this:

if(variable1>value){
//actions
}

of course you can replace > with <.
-------------
||
Ok, in flash, if you wanna action to run if one thing or another is happeneing, use || (or) statements. The code works by like I said, if one of 2 or whatever events is happening, the actions run.
-------------
In a code, it would look like this:

if(Key.isDown(Key.SPACE)||Key.isDown(Key.U
P)){
//actions
}
-------------
&&
You use this statement if you wanna check if multiple events are happening at the same time. Use it for if you want the user to have to press 2 keys for example, for an action to happen.
-------------
In a code, it would look like this:

if(Key.isDown(Key.SPACE)&&Key.isDown(Key.U
P)){
//actions
}
-------------
Well, thats it! If I missed any symbols, tell me!

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

backup

Reply To Post Reply & Quote

Posted at: 9/20/05 07:17 PM

backup NEUTRAL LEVEL 02

Sign-Up: 08/20/05

Posts: 103

Good job, very helpful for the n00bs!


None

Denvish

Reply To Post Reply & Quote

Posted at: 9/20/05 07:24 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

At 9/20/05 06:43 PM, SpamBurger wrote: In a code, the ! statement would look like this:

if(!something=something else){
//actions
}

Actually, the ! is generally used in conjunction with ==, rather than =. For the code you used, I'd normally use
if(something !== something else)

Also, if you're just checking the boolean value of a variable (ie, whether it's true or false (1 or 0)), you can just use
if(something){...} to check if it's true, and
if(!something){...} to check if it's false

- - Flash - Music - Images - -

BBS Signature

None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 9/20/05 07:25 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,050

what about >=, <=, !=

Plus grouping

if(a==b==c && !(a>d || a<=e || (c==f && c!=f)))


None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 9/20/05 07:26 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,050

At 9/20/05 07:24 PM, Denvish wrote: if(something !== something else)

just use !=, saves a digit


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/20/05 07:27 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

Well, I did forget the == but I guess someone could make this better?

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

liaaaam

Reply To Post Reply & Quote

Posted at: 9/21/05 11:08 AM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

At 9/20/05 07:26 PM, Glaiel_Gamer wrote: just use !=, saves a digit

Yeah, thats what I use.. anyway I might as well add these if noone has already..

>= - This checks if one variable/property is identical or lesser than another variable/property. For example:

one = 1, two = 2;
if(two>=one){
trace("True");
} //will trace true.

<= - This checks if one variable/property is identical or greater than another variable/property. For example:

one = 1, two = 2;
if(two<=one){
trace("True");
} //won't trace at all

=== - This checks for STRICT equality, which means for it to return true, the two variables/properties must be identical. When using ==, the statement will return true if the first variable/property is 1 and the second is true, but with === that won't happen. For example:

num = 1;
word = true;
if (num == word) {
trace("Expression 1 = True"+newline);
}//will trace
if (num === word) {
trace("Expression 2 = True");
}//won't trace

You can also use !== for strict inequality.


All times are Eastern Standard Time (GMT -5) | Current Time: 01:47 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!