Reputation:
Say you have a flexunit test that looks like this:
package foo {
import flexunit.framework.TestCase;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedSuperclassName;
class DescribeTypeTest {
public function testDescribeInnerType():void {
var currentInstance:ChildBar = new ChildBar();
trace(getDefinitionByName(getQualifiedSuperclassName(currentInstance)));
}
}
}
class Bar{}
class ChildBar extends Bar{}
Which throws the exception "Error #1065: Variable Bar is not defined." It only applies to inner classes (classes outside the package).
Does anyone have any way to get this to work?
Upvotes: 0
Views: 5494
Reputation:
I just tested following code with Flex 3.3 (AIR app):
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="t();">
<mx:Script>
<![CDATA[
import flash.utils.describeType;
import flash.utils.getQualifiedSuperclassName;
private function t():void {
trace(getDefinitionByName(getQualifiedSuperclassName(new FooBar())));
}
]]>
</mx:Script>
</mx:WindowedApplication>
Bar.as
package
{
public class Bar
{
}
}
FooBar.as
package
{
public class FooBar extends Bar
{
public function FooBar()
{
super();
}
}
}
As a trace result I see:
[SWF] DefTest.swf - 1,024,228 bytes after decompression
[class Bar]
Can you confirm this? Does that helps?
Upvotes: 0
Reputation: 12333
Not sure if there is any workaround, but just to confirm:
getDefinitionByName () function
public function getDefinitionByName(name:String):Object Language Version : ActionScript 3.0 Runtime Versions : AIR 1.0, Flash Player 9 Returns a reference to the class object of the class specified by the name parameter.Parameters
name:String — The name of a class. Returns Object — Returns a reference to the class object of the class specified by the name parameter.
Throws ReferenceError — No public definition exists with the specified name.
Since both Bar and ChildBar are non-public, you're getting that ReferenceError.
Upvotes: 1