nickMiddleweek.blog.search();

Tuesday, 3 November 2009

Flex's describeType() function

ok, well this is a great function for the newbie Flex Developer...

describeType(value:*):XML
http://livedocs.adobe.com/flex/3/langref/flash/utils/package.html#describeType()

... This great Flex function helps when debugging and interrogating objects. Using it with the trace statement to output to the console let's you inspect an XML dump of an object's properties, class chain, what Interfaces it supports and a host of other info to, well describe the object that you pass to it and exactly is available to you.

I've had loads of occassions when I'm just stuck in the debugger with what is available to me, what the object is, say from a Renderer, what I can cast it to and what properties I have access to... I wish I found this month ago :)


e.g. usage:
trace(describeType(this.owner));

e.g. output:
<type name="mx.containers::VBox" base="mx.containers::Box" isDynamic="false" isFinal="false" isStatic="false">
<extendsClass type="mx.containers::Box"/>
<extendsClass type="mx.core::Container"/>
<extendsClass type="mx.core::UIComponent"/>
<extendsClass type="mx.core::FlexSprite"/>
<extendsClass type="flash.display::Sprite"/>
<extendsClass type="flash.display::DisplayObjectContainer"/>
<extendsClass type="flash.display::InteractiveObject"/>
<extendsClass type="flash.display::DisplayObject"/>
<extendsClass type="flash.events::EventDispatcher"/>
<extendsClass type="Object"/>
<implementsInterface type="mx.validators::IValidatorListener"/>
<implementsInterface type="mx.core::IUIComponent"/>
<implementsInterface type="mx.core::IDataRenderer"/>
<implementsInterface type="mx.core::IChildList"/>
<implementsInterface type="mx.core::IFlexModule"/>
<implementsInterface type="mx.core::IRawChildrenContainer"/>
<implementsInterface type="mx.core::IUID"/>
<implementsInterface type="flash.events::IEventDispatcher"/>
.
.
.

No comments:

Post a Comment

The internet is a crazy place so please help us keep it under control by leaving only relevant messages and comments, thanks a bunch! :m)