Now for the code, on the first key frame we need this:
ot = 0;
stop();
which simply sets time to 0 and then waits. The third frame
is also very simple:
gotoAndPlay(2);
Which just loops the movie back round to calculate the next
position of the projectile. Now for the tricky bit, the second frame. I will
show you the code first then explain it:
Every time this code is run it calculates the time passed
by adding 1/24 to the previous time (change the 24 to the frame rate your movie
is running at). This means that the projectile runs at real time, the higher
the frame rate the smoother the curve will look. It then checks to see if the
tp (time passed) has exceeded the op (overall time), if it has then it goes
back to frame 1 else it re calculates the height and range of the projectile.
It also moves the markers to the corresponding positions on the y and x axis.
The if statement for the y marker just means that it stays at the highest point.
I was not pleased with just seeing where the projectile was I wanted to see
the whole path that it had travelled along so I adapted the code to this:
The only difference is that it duplicates the mark movie
clip therefore drawing the path. If you do not understand any part of this download
the zip file and see it working or don’t hesitate to email me.
We hope the information helped you. If you have any questions
or comments, please don't hesitate to post them on the
Forums section Submit your Tutorial at Click Here