Here is this class i have written.
package
{
import flash.events.Event;
public class Radius
{
public var theRadius:Number;
private var sideX:Number;
private var sideY:Number;
private var obj1:Object;
private var obj2:Object;
public function Radius(firstObject:Object,secondObject:Object,whoListens)
{
// constructor code
whoListens.addEventListener(Event.ENTER_FRAME, mainloop);
this.obj1 = firstObject;
this.obj2 = secondObject;
}
public function mainloop(e:Event)
{
sideX = Math.abs(obj1.x - obj2.x);
sideY = Math.abs(obj1.y - obj2.y);
theRadius = Math.sqrt(sideX * sideX + sideY * sideY);
//trace(theRadius);
}
}
}
Now outside the class, I do this:
var radius1 = new Radius(someObject1,someObject2,stage);
Okay, now that I have one…
I want to see what the radius is…so…
trace(radius1.theRadius);
And we get…NaN…
Oh god, why?
I have been starring at it too long.:sen: