The equation from A to B

5 posts

Flag Post

Hi, how can I make a script so that The A point will go to B no matter what?
Tip: The destination point ca change his _x and _y, like: attach him to mouse.

Flag Post

There’s not enough information here for anybody to help you.

Programming is about solving problems, and the first step in any problem is to define it clearly.

What is Point A? Is it a movieclip, the mouse pointer, a Point object? How to you want it to ‘go’? Teleport, move in a straight line, or like a homing missile? What language are you using?

Flag Post

A-movieclip represented by a circle
B-movieclip represented by a circle
I need an equation to move the point A to B.

Problem: The basic equation (X-Xa)/(Xb-Xa)=(Y-Ya)/(Yb-Ya) gets bugged if the point B changes his position.
where: Xa, Xb, Ya, Yb are the initial coordonates of the 2 points. Those should not change.
Xa will be saved in var a;
Xb in var b;
Ya in a2
Yb in b2
Possible Solution: When Point B changes his possition, his X and Y saved will be re-memorated in 2 variables.

Flag Post

Actionscript won’t solve equations for you. To move a movieclip, you need to give specific instructions for where you want it to go. A common way to animate a movieclip is to set an x velocity and y velocity, and use them to modify the location of the clip each frame:

//I defined CircleAVelocity as a point so I can store X and Y velocity in a single variable 
CircleAMovieClip.x += CircleAVelocity.x;
CircleAMovieClip.y += CircleAVelocity.y;

If the target location moves, you will need to recalculate CircleAVelocity every frame.

Flag Post

Thank you very much!