PDA

View Full Version : No such variable: getQualifiedClassName


th03pson
09-11-2009, 05:31 PM
Hi,

I have an event handler for mouse clicks which I'd like to only process the event if the target is a specific type of class. For this, I'm executing flash.utils.getQualifiedClassName on the event target.

For some reason though, flash.utils.getQualifiedClassName always evaluates to an error (No such variable: getQualifiedClassName). There's no compile-time error and in run-time the error is interpreted to false.

What am I missing?!

private function mouseClicked(e:Event):void
{
// if the mouse was double clicked on a TextBox component
if ((flash.utils.getQualifiedClassName(e.target)) == "com.ernrg.data::TextBox")
{
// process mouse click
// etc....
}
}

Thanks!

lordofduct
09-11-2009, 05:46 PM
you import the function and run...


import flash.utils.getQualifiedClassName;

... stuff

private function mouseClicked(e:Event):void
{
if(getQualifiedClassName(e.target) == "com.ernrg.data::TextBox")
}


furthermore there is a faster way to check if something IS something:


if( e.target is TextBox )

th03pson
09-11-2009, 06:28 PM
Thanks lordofduct.

Importing the function and running is actually what I had done before; it makes no difference which way you reference getQualifiedClassName. The problem was that the event trigger was a child of the TextBox; I've fixed this by setting textBox.mouseChildren = false. (The error message was seemingly a red herring.)

I've also updated my code to use the IS operator; much easier, thanks again!