开发者

ActionScript instanceof for dynamic interface

interface If { ... }
c开发者_Go百科lass Impl implements If { ... }

function test(type:Class, obj) {
  return obj instanceof type;
}

test(If, new Impl());

The call to test on the last line returns false, but it should be true. How can I do this check right, with the requirement that it must be inside the function?


Real code:

    public function iterate(callback:Function, type:Class = null) {
        for (var node:EntityListNode = beginNode; node != null; node = node.next) {
            if (type == null || node.entity instanceof type) callback(node.entity);
        }   
    }


if(Object is IInterface) ... works fine for that AFAIK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜