Ipoint interface | ActionScript 3.0 AS3

It amazes me that ActionScript (AS3) does not have interfaces listed for all its classes. Often you want to create a class that inherits from something like MovieClip and MovieClip inherits all the way down a long list of classes. So you are left with the daunting task of creating all those interfaces. Fortunately some of us have been publishing those interfaces on the web to fill the void with which Adobe Flash ActionScript 3 has left us.
In the case of IPont I had to extend the flash.geom.Point class and change the property accessors in order to have them work in the interfaces since Point has finalized its properties. You could create your own Point Class and use composition to wrap the real Point class if you wanted to preserve the same properties instead of using dataX for x.
package
{
import flash.geom.Point;
public class DataPoint extends Point implements IDataPoint
{
public function get dataX():Number{
return super.x;
}
public function get dataY():Number{
return super.y;
}
public function get dataLength():Number{
return super.length;
}
}
}
package
{
public interface IDataPoint extends IPoint
{
function get dataX():Number;
function get dataY():Number;
function get dataLength():Number;
}
}
package
{
import flash.geom.Point;
public interface IPoint
{
function add(v:Point):Point;
function clone():Point;
function normalize(thickness:Number):void;
function offset(dx:Number, dy:Number):void;
function subtract(v:Point):Point;
}
}

comments powered by Disqus