Continuous object movment in flash
In this Macromedia Flash tutorial you will see how to make an object move across the stage, and when its done it will start over.
1.
This is acturlly very simple, all we need is an object to move, and a "wall" of block that reacts when our object touch it.
So start by making your graphic, right click and convert it to a movie clip.
Place it all the way to the left of the stage.
2.
Now make a wall that has the same or more height then the stage, and place it all the way to the right as shown below.
Right click and convert it to a movie clip, in the properties panel name it wall.
3.
Now select the object we want to move then go to the actionscript panel and type in the following code.
onClipEvent(enterFrame) {
_x += 10
if (hitTest(_root.wall)) {
_x = -150.0
}
}
----------------------------
onClipEvent(enterFrame) {
}
This tells flash to repeat the content of the event for every frame.
This code is the code that tells our object to move across the stage by adding 10 px to the x position of the object.
_x += 10
Now we need to you the hittest function to test if our object hits the wall graphic we made, and if it does hit the wall then it will place the object at -150, (to the left of the stage).
if (hitTest(_root.wall)) {
_x = -150.0
4.
Now we are ready to test our flash movie.
You can make more movie clips and copy the actionscript code into them to as I did.