I need a little more information from my points, so I thought I would add the previousX, the previous one, so that I could get deltaX and deltaY. Now this works fine if I make a simple standalone class.
I think, however, that I would like to extend the flash.geom.Point class to take advantage of the other functions and calculations that it offers.
So, I expanded the point and changed the x and y settings as needed. When I compile, I get an error that these setters are not marked to override when they should be. Therefore, I override, but then I get an error message that says that they are not overriding any function.
Any clue where I squinted?
Here is the class:
package net.jansensan.geom
{
import flash.geom.Point;
public class UpdatablePoint extends Point
{
private var _previousX : Number = 0;
private var _previousY : Number = 0;
private var _deltaX : Number = 0;
private var _deltaY : Number = 0;
public function UpdatablePoint(x:Number=0, y:Number=0)
{
super(x, y);
}
override public function toString():String
{
return "(x=" + super.x + ", y=" + super.y + ", previousX=" +
_previousX + ", previousY=" + _previousY + ", deltaX=" +
_deltaX + ", deltaY=" + _deltaY + ")";
}
override public function set x(x:Number):void
{
_previousX = super.x;
super.x = x;
_deltaX = super.x - _previousX;
}
override public function set y(y:Number):void
{
_previousY = super.y;
super.y = y;
_deltaY = super.y - _previousY;
}
public function get previousX():Number
{
return _previousX;
}
public function get previousY():Number
{
return _previousY;
}
public function get deltaX():Number
{
return _deltaX;
}
public function get deltaY():Number
{
return _deltaY;
}
}
}