Reputation: 5916
I need to check the component is spark or mx I have tried with checking is IVisualElementContainer
But both spark and mx component are fall into IVisualElementContainer
my code sample are as follows
displayMessage(vidbox, 'videbox removed');
public function displayMessage(messageParent:*, message:String, fontSize:String = "30"):void {
messageLabel.text = message;
if(messageParent is IVisualElementContainer)
messageParent.addElement(messageLabel);
else
messageParent.addChild(messageLabel);
}
any helps are highly appreciated
Upvotes: 0
Views: 54
Reputation: 1032
There is getQualifiedClassName which returns "the fully qualified class name of an object.", so then you can check if class name starts with "mx." or "spark.".
Code sample:
var fullClassName:String = getQualifiedClassName(messageParent).toLowerCase();
if(fullClassName.indexOf("spark.") == 0)
{
//spark comp
messageParent.addElement(messageLabel);
}
else if(fullClassName.indexOf("mx.") == 0)
{
// mx comp
messageParent.addChild(messageLabel);
}
else
{
// other
}
Upvotes: 2