What is the "hasOwnProperty()" equivalent for interface?
What is the "hasOwnProperty()" equivalent for interface?
I have found this related bug at Adobe: https://bugs.adobe.com/jira/browse/FB-27683
Any workaround except try..开发者_JS百科catch statement?
Have you considered this?
if("foo" in bar){ ...
where "foo" is the name of a property and bar is the object reference as Interface?
Here it is in action in a real world scenario:
import flash.events.IEventDispatcher;
import flash.events.EventDispatcher;
var i:IEventDispatcher = new EventDispatcher();
if("dispatchEvent" in i){
trace(" I have dispatchEvent");
}
The other answer is better, but you can also use
i['hasOwnProperty']('dispatchEvent')
精彩评论