extending a class and implementing an interface
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 h开发者_StackOverflow中文版ave 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
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
}
精彩评论