Reputation: 1127
Say you have an object,
var obj:Object = someOtherObject;
And you need to check if it is of the type with the name stored in myString
var myString:String = someOtherString; // ex. "int", "Number", "CustomClass"
I have tried:
if(obj is getDefinitionByName(myString))
But that doesn't seem to work. How would you go about doing this?
Upvotes: 1
Views: 89
Reputation: 13532
This works for me :
var obj:Object = 5;
var myString:String = "int";
var c:Class = getDefinitionByName(myString) as Class;
if (c && obj is c)
{
trace("obj is of type "+myString);
}
The return type of getDefinitionByName is Object so casting it to Class seems to do the trick.
Upvotes: 1