2010-03-08 55 views
0
interface If { ... } 
class Impl implements If { ... } 

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

test(If, new Impl());

在最後一行調用test返回false,但它應該是true。我該如何做這個檢查的權利,要求它必須在功能內?動態接口的ActionScript instanceof


真正的代碼:

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); 
     } 
    } 

回答

1

if(Object is IInterface) ...爲了AFAIK工作正常。