A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Move Symbol in The Direction of a Point

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    1

    Question Move Symbol in The Direction of a Point

    I have a Bullet symbol on my stage, but I want to move it towards a Point at a given speed. Is there any way of doing this (using ActionScript 3)?

  2. #2
    There is way for everything in AS3 You can use script like this:

    Actionscript Code:
    var speed:int = 10;

    Bullet_mc.addEventListener(Event.ENTER_FRAME,myEnterFrame);

    function myEnterFrame(event:Event) {

    while(Bullet_mc.x != Point_mc.x){

    Bullet_mc.x = Bullet_mc.x + speed;

    };

    }


    Scotty does know how to Fla-make cool ads.

    http://flamake.net - this Ads will Fla-make you crazy. Find your cheap flash banners and see the best commercials around the world.

  3. #3
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    760
    Remember the distance equation.

    distance=sqrt((x2-x1)2+(y2-y1)2)
    [SIGPIC][/SIGPIC]

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