Thursday, April 17, 2008
Man, it's like I'm having a conversation with myself here. Once I blurt out something here, only a few moments later do I have a revelation about how lousy the previous post might have been.
As it turns out, I don't need the class below (TypeDescriptor) unless I really want to dig into the hierarchy, and if I did, I would need to re-factor the class in a major way to make it actually useful in an abstracted kind of way.
Or just leave it to a developer (including myself) to worry about. For designers, they probably never need to see the XML output of describeType... ever.
So all a designer really needs to worry about is:
trace( getQualifiedClassName( this ) );
trace( getQualifiedSuperclassName( this ) );
And that's it really. All my class was doing was breaking the describeType down a little bit, and that's a sincere waste of time.
Forget about all the posts and class crud I've buggered this blog up with. It's all nonsense now that I've spent more time in the flash.utils documentation. The two classes mentioned above are most of what anyone might need.
package
{
import flash.utils.describeType;
public class TypeDescriptor
{
public function TypeDescriptor()
{
}
public function getType( sValue:String, value:* ):String
{
var varList:XML;
var result:String;
switch( sValue )
{
case "typeName":
varList = describeType( value );
result = varList.@name.toXMLString();
break;
case "typeBase":
varList = describeType( value );
result = varList.@base.toXMLString();
break;
case "typeIsDynamic":
varList = describeType( value );
result = varList.@isDynamic.toXMLString();
break;
case "typeIsFinal":
varList = describeType( value );
result = varList.@isFinal.toXMLString();
break;
case "typeIsStatic":
varList = describeType( value );
result = varList.@isStatic.toXMLString();
break;
default:
result = "error";
break;
}
return result;
}
public function getExtendsClass( value:* ):String
{
var varList:XML = describeType( value );
var result:String = varList.extendsClass.@type.toXMLString();
return result;
}
public function getImplementsInterface( value:* ):String
{
var varList:XML = describeType( value );
var result:String = varList.implementsInterface.@type.toXMLString();
return result;
}
}
}
1 Comments:
-
Erik van der Neut said...
-
“Very cool -- just tried it out.
Next version of the class: set of static consts for the sValue strings.
Pretty sweet class. This will come in very handy.
Thanks,
- Erik”








