Basic Movment in Flash
Hey guys, this is mackheads101 and today I'm going to be, uh, well we got a special guest and he's going to be showing you some action script. So, um, here we go.
Okay, so first of all I'm going to open up Flash. I'm going to be using Action Script 2 because I'm, uh, I'm not familiar with Action Script 3.
Um, for in this tutorial, I'm going to teach you how to move an object with, um, with your the arrow keys. I'm going to convert this to a symbol, name it box. Then I'm going to open up the actions, or you can press F9, and um, I'm going to write uh, on clip event and then I'm going to write a, uh, an ellipse and write enter frame, which means it will do this every time, uh, every time, every 12 times per second because of the frames per second.
Then I'm going to write if, if, and if the things inside the ellipses are true, if key period is down, key period left. Then I'm gonna write a bracket, a scrolly bracket thing, I'm writing a close bracket.
So to close the um, the if key equals is down left, I'm going to write x, meaning the x of the box plus, oops, plus equals 10. Now if we test this, uh, there'll be a command enter. What it should do, oops, I forgot a, uh, thing there. What it should do is it should move in, uh, one direction.
Now, I didn't do this correctly so I'm gonna have to change the plus to a minus so that it goes in the correct direction. So when I go with this key, it goes here. Now I'm gonna copy to make the other one. I'm going to copy this, I'm going to paste that here and write if and change the left here to a right with all caps.
I'm just going to change the minus to a plus and then if I command enter, I'll test it and I can move in both directions. Now for up and down, I'm going to paste this here and change the right to up and then change the x to a y and then minus equals 10.
Now if I command enter and test this, I can move in three directions: up, down, left, and right. And lastly, for the for down, I'll just copy paste that here, change the up to a down and change the minus to a plus.
Now I'll just test that and I can move in all four directions and, uh, and that's al...