I am creating objects for a game, they are all sprites. but I also want them to implement an interface. Is it possible to do both ? If not, how can i have an object have the capabilities of a sprite and also have it implement an interface. I am wanting to create another class that checks all my objects to see what datatype they are and evaluate them accordingly
+1
A:
It is possible for all ActionScript objects to both implement an interface and extend a class. Here's an example:
public class RedZoid extends Sprite implements IColoredZoid
Furthermore, the is
keyword works with interface implementations:
var z1:RedZoid = new RedZoid();
if (z1 is IColoredZoid) {
// This branch will be hit, since the interface is implemented
}
Michael Greene
2009-12-30 05:10:42
what about the other way around. z1:IColoredZoid, then have a if statement chcek to see if z1 is Redzoid. lets just say that z1 is passed through a method.
numerical25
2009-12-30 15:59:25