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.
精彩评论