本文介绍了如何正确的类继承的ActionScript 3的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ActionScript 3中,你可以计算出物体O是否是C类的,或者扩展或实现C类(直接或间接)使用一类...

In ActionScript 3, you can figure out whether object O is of class C or of a class that extends or implements class C (directly or indirectly) using...

if (O is C) {
    ...
}

我想要做的是测试是否CC级扩展或实现C类(直接或间接),而不必实例化一个对象。

What I want to do is to test whether class CC extends or implements class C (directly or indirectly), without having to instantiate an object.

在Java中,你可以使用...

In Java, you would use...

if (C.isAssignableFrom (CC)) {
    ...
}

http://java.sun.com/javase/6/docs/api/java/lang/Class.html#isAssignableFrom%28java.lang.Class%29

怎么样的ActionScript 3?

How about ActionScript 3?

谢谢!

推荐答案

您可以在CC直接调用describeType()全面。你不必实例化对象。

You can call describeType() on CC directly. You do not have to instantiate the object.

var typeXML:XML = describeType(CC);
if(typeXML.factory.extendsClass.(@type=="C").length() > 0)
{
...

这不是那样干净,我想,但我不能找到更好的东西。

It's not as clean as I'd like but I can't find anything better.

(通过Amarghosh:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#describeType%28%29%5D%5B1%5D )

(via Amarghosh: [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#describeType%28%29%5D%5B1%5D )

这篇关于如何正确的类继承的ActionScript 3的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 16:17