There is a Point (flash.geom.Point) class in as3
I want to add method to class Point (e.g. convertToStagePointMyMethod()) and I’d like to call this method by using
var a:Point=new Point();
a.convertToStagePointMyMethod()
What should I do in order to add this method to class Point? Is it possible without inheritance. I’d like to use it like “partial” classes in .NET
Here is a quick example using prototype :
This is the only way to do this without extending a class.
Also note that the compiler will not compile in strict mode if you try to use
p.foo("test"), that’s why i wrotep["foo"]("test")in my example.