AS: Logic
Logic is usally taught in Math and deals with statements and conditionals. It relates to Flash because the Actionscript language of flash uses more or less of the same stuff that you would learn in Logic. Let me say that if you are learning Logic in Math class, pay attention!
Not all of the stuff I will teach is related to flash AS, but it deffinatly deals with other programming and languages, I can assure you that.
I'm going to go over 2 statements, and the main conditional.
The 2 statements I'm going to teach you about are the and and or statements.
and statements- The statement can only be true if all parts of the statement are true, otherwise the statement is false.
So let me give an example of how this is used. First we start off with a little key or something to tell us which parts of the statement are true or false. I will make up my own key for you.
John eats meat = true
Mary eats fruits = false
Now according to that key, if the statement says "John eats meat" then that part of the statement would be true. But if it the statement also said that "Mary eats fruits", then that part would be false, therefore making the whole statement false. So let me give a few examples of a statement with the and statement in it.
John eats meat and Mary does not eat fruits
The first part, John eats meat is true according to our key.
The second part, Mary does not eat fruits, would also be true according to the key because the key says that Mary EATS fruits is false, so if she does not, then it is true.
So that statement would be true. Lets do one more example
John does not eat meat and Mary eats fruits
The first part, John does not eat meat, is false because it is opposite of what the key says, and would be false in this case.
The second part, Mary eats fruits, is false, so the whole statement would be false.
Now lets move on to "or" statements.
The "or" statement works pretty much the same way, except that the statment can ONLY be false if both parts are false, opposite of the and statement.
Lets' use the same key as before:
John eats meat = true
Mary eats fruits = false
Now let me give you some examples with the use of the or statement:
John eats meat or Mary eats fruits.
The first part, John eats meat, according to the key, is true.
The second part, Mary eats fruits, is false.
Since one is true, and both are not false, the statement is true.
Example 2:
John does not eat meat or Mary eats fruits
The first part, John does not eat meat, is false according to the key because it is opposite of what the key says is true in Johns case.
The second part, Mary eats fruits, is also false
So, since both parts of the statement are false, the whole statement is false.
Now let's move into my favorite, Conditional Ifs and thens
These can get semi confusing, but if you memorize what each part does, it is extremely easy!!
An "if and then" conditional is used the same way in flash when writing a...well... conditional if! So let's get into it more shall we?
This does not require a key unlike the first two statements, but does require an original statement. So once again, I will make one up to benefit you all.
Original: If I eat, then I live
Now that statement, according to ME and real life, is true. So keep that in mind.
Now, there are 3 parts to a conditional if and then. They are: converse, inverse, and contrapositive. ( I love that word)
Converse
This is when you take the ORIGINAL statement, and switch the order in which it appears. Let us clarify the original statement:
Original: If I eat, then I live
Now keeping in mind that the converse switches the order, the new sentence would be:
Converse: If I live, then I eat
The Converse is ALWAYS opposite to what the original equals. In this case it would be a false statement. As you can see, the statements order was reversed, still keeping the If and then in the same positions though.
Next up:
Inverse
This negates the original sentence. That means that you would turn everything that is positive into a negative, and everything that is a negative into a positive. So let us rewrite the sentence as it's Inverse:
Inverse: If I do not eat, then I do not live.
As you can see, I added the word "not" into both parts of the sentance to negate the sentance. This would also be opposite from the original statement, thus being FALSE.
Contrapositive
This is when you take the original sentance, negate it, and switch its order. So you are using the Inverse and the Converse on the original sentance, to get a sentance with a switched order that is negated. Example:
Contrapositive from the ORIGINAL: If I do not live, then I do not eat
The order in that sentance was switched and negated. This will remain the same as the original sentance, and in this case being TRUE.
So that is basically all there is to logic, it is extremely easy if you memorize it and learn it. It is used in computer programming all the time and especially in Flash! I use this stuff all the time!
One more thing to know. There is also a term called Logically Equivalent, this is the same as the Contrapositive, so when you see those 2 words just thing "Contrapositive"
Hope you learned something out of this =D