# f8: objects returned from my class being overwritten

**URL:** <https://forum.kirupa.com/t/f8-objects-returned-from-my-class-being-overwritten/224822>\
**Category:** flash\
**Created:** [May 5, 2007, 10:46pm UTC](https://forum.kirupa.com/t/f8-objects-returned-from-my-class-being-overwritten/224822 "2007-05-05T22:46:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aesir](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@Aesir](https://forum.kirupa.com/u/Aesir)\
**Post date:** [May 5, 2007, 10:46pm UTC](https://forum.kirupa.com/t/f8-objects-returned-from-my-class-being-overwritten/224822/1 "2007-05-05T22:46:00Z")

</div>

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:

```auto

 
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;
   }
}
 

```
