With this code
function someFunction(classParam:Class):Boolean
{
// how to know if classParam implements some interface?
}
i.e. Comparing classParam
with IEventDispatcher
interface:
someFunction(EventDispatcher) // returns true
someFunction(Object) // returns false
I know it can't be done with is
operator. But, is there a way to do it? Is there a way to know if a class implements some interface? (or is a subclass of another class?)
Possible solutions:
A. Creating an object of classParam
and using that object to compare using is
operator.
function someFunction(classParam:Class):Boolean
{
return (new classParam()) is IEventDispatcher
}
B. Using describeType()
function someFunction(classParam:Class):Boolean
{
var xml:XML = describeType(classParam)
// found "implementsInterface" value in xml and compare to IEventDispatcher
}
There is a way that DOES NOT USE describeType
or creates a new
operator?