Wednesday, April 16, 2008
Bitten and healed by describeType
Wednesday, April 16, 2008
I have a method that can take all sorts of types for a parameter. We used to do typeof stuff in AS2, now with AS3 we have something better called describeType. It bit me for a while today. I thought I would make this known in case you run into the same thing. Its a simple thing, but I didn't diagnose it until after about 20 minutes.
...
import flash.utils.describeType;
...
public function addState( oValue:* ):void
{
var varList:XML = describeType( oValue );
var result:String = varList.type.@name.toXMLString();
}
The above did absolutely nothing for me. result was never set. I pulled my hair out for 20 minutes, and then realized that when you use describeType, the XML returned to an accessor variable sets its root to that variable.
So I didn't need to do varList.type.@name.toXMLString() but I needed to ONLY do this varList.@name.toXMLString().
That wasn't exactly clear to me, but it is now. A simple thing to assume or miss for me.
Comments:
There are currently 0 Comments:

