检查类实现特定接口 [英] Check if Class Implements a Specific Interface

查看:138
本文介绍了检查类实现特定接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ActionScript 3.0中,有几个方法可以检查类的扩展。例如,如果我想知道的定制类扩展雪碧我可以使用操作符:

in ActionScript 3.0, there are a few ways to check a class's extension. for example, if i want to know of a custom class extends Sprite i could use the is operator:

跟踪(MyClass的是雪碧);

我还可以使用 flash.utils.getQualifiedSuperclassName

trace(getQualifiedSuperclassName(MyClass));

我想接受一个类作为参数,并检查是否传递的类实现一个特定的接口。有一个同样简单的或常用的方法来检查,如果我的自定义类奉行一个接口?也许是这样的:

i would like to accept a class as an argument and check to see if the passed class implements an certain interface. is there an equally simple or common way to check if my custom class adheres to an interface? perhaps something like:

跟踪(MyClass的实现IMyInterface的);

推荐答案

为什么不跟踪(MyClass的是IMyInterface的);

这篇关于检查类实现特定接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆