As3: Main
ok, well someone has to supply some easy things for some total begginers, ill start with some stuff ive recently learned.
First off it would be cool if you could follow along by doing some stuff i tell you, or you could just read it but if your an animator you probably could get more out by following along.
For the first example draw 2 objects, make it easy to tell the difference between them, for instance a stragth line and a curved line.
give your first object the instance name of object 1, instances are found in the properties panel after converting your creation into a movie clip.
next give your second object the instance name of object 2.
instance names are needed so that when you create the code flash knows which objects to use. imagine flash is a blind person, and there are 2 people, but flash doesnt know their names. he doesnt want to be rude so he wont call out hey you. his only chance is to call out random names which is totally useless, so instance names are names for the blind person. the the blind person has names he can communicate with the other people.
now for the script. type in
if (object1.hitTestObject(object2)){
trace("i am touching you");
}
now you probably dont know what that script means, so i will divide it up for you
if (object1.hitTestObject(object2)){
First lets explain the if statement. that tells flash that if this is happening..... and the second part is what comes next. the this part is
(object1.hitTestObject(object2)
so lets continue our sentence. if _______ is happening..., the _____ is what is above. what that means is if object one, is touching object 2 then.....
the { means to start a commandamabob.
trace("i am touching you");
}
so now lets keep going, now we are getting to the commandamabob, which is trace. trace basically means output this text, or say this. this is only visible when you export from flash so it is good to see if things are working properly while making a game.
our completed sentence is
If object one is touching object 2 then say "i am touching you". then } which means close the command.
BUT WAIT HASH!!! what if object one isnt touching object 2
well my child you will use an else command
else {
trace("let me touch you");
}
well hopefully you can guess what that means but i will explain it anyways.
else {
this means if ____ isnt happening then do this...
trace("let me touch you");
}
so if ______ isnt happening then say "let me touch you"
so heres the full code
if (object1.hitTestObject(object2)){
trace("i am touching you");
} else {
trace("let me touch you");
}
i hope this helped people who are starting out.
i might explain hittests in more depths but td is still teaching me the stuff