I have four movieclips on the stage. They can be dragged around. I have a class that creates a segment from two points, and returns the x-intercept, y-intercept, slope, and inverse slope of a linear function going through the two points.
On every enterFrame() i create one segment for each pair of points, then the information is displayed in a bunch of dynamic text boxes.
The Problem: whichever object is sent over last overwrites the data from the first. I am creating two different objects with different names, but the first is being overwritten by the second. What is going wrong here?
FLA included. But you will need to make this class file:
Seg.as:
import flash.geom.Point;
class Seg {
// variables
private var p1:Point;
private var p2:Point;
private var o:Object = new Object();
// constructor
public function Seg(mc1:MovieClip, mc2:MovieClip){
p1 = new Point(mc1._x, mc1._y);
p2 = new Point(mc2._x, mc2._y);
o.sy = (p2.y - p1.y) / (p2.x - p1.x);
o.sx = 1 / o.sy;
o.iy = p1.y - o.sy * p1.x;
o.ix = p1.x - o.sx * p1.y;
}
// public functions
public function vars():Object{
return o;
}
}