A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Flash 8 Movement Script Help

  1. #1
    Member
    Join Date
    Aug 2003
    Location
    Asia
    Posts
    74

    Flash 8 Movement Script Help

    Hi, sorry if this thread has been posted before. Since i have so little time.
    I have a problem with an object movement animation.

    My simple question is:
    How can I make a MovieClip moves with a velocity V (it's a vector so if V is minus, then the MovieClip moves to the left) and angle @ ?

    I know it involves some trigonometric stuffs...

    Thanks for any helps !!!

  2. #2
    Senior Member
    Join Date
    Jun 2007
    Posts
    204
    Velocity is simulated by how far you move an object in a given amount of time. If every 1/12 of a second (the standard flash frame rate is 12fps) I move an object forward by 5 pixels it will appear to be moving more slowly than an object moving 10 pixels every 1/12 of a second.

    To move an object horizontally:

    [target]._x += 10

    The [target] should target the object you want to move (e.g. this or _root.mc). The larger the number the faster it moves. To move backwards you can change "+=" to "-=".

    If you want to also move vertically:

    [target]._y += 10;

    The above x and y ration will move the object at a 45 dregree angle.

  3. #3
    Member
    Join Date
    Aug 2003
    Location
    Asia
    Posts
    74
    Thanks.

    That's what I understand so far. So, it's not a big problem if the movement is constant.

    Right now, I'm creating a Homing-Missile script for my Flash Game. And I have difficulties in implementing this question:

    About a Function which has parameter: V for Velocity, A for Angle, P for Points(x,y) and now D for Deviation. Deviation is an Error Rate of the missile. So, if D is 30 the it has 30% chance to mis-hit point P.

    So, perhaps my script will look like this (in action): Missile.Move(V, A, P, D); and the Missile starts to move to point P with certain V,A and D.

    I'm confused with the formulae. So, any help about it? Thx in advance.
    Last edited by blackjenova; 11-17-2007 at 08:27 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center