Using the interospection API:

In the present API, we will describeType() method which will return an E4X XML object, this kind of object contains the description of the target object in XML format.

Using the interospection API:

Using the interospection API:

     

 

In the present API, we will describeType() method which will return an E4X XML object, this kind of object contains the description of the target object in XML format. This method accesses only public member.

In this tutorial you can see a new loop called for each in, it is slightly different from for each loop, for each loop access the elements randomly and for each in loop works on a specific property.

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="getProperties()">

<mx:Script>
<![CDATA[
import flash.utils.*;

public function getProperties():void
{
var info:XML=describeType(btn1);
txt1.text=info.toString();
[email protected]();
for each (var v:XML in info..variable)
{
txt2.text+="Variable=" +v.@name+"="+btn1[v.@name]+"("+v.@type+")\n";
}
for each(var a:XML in info.accessor)
{
if(a.@access=='writeonly')
{
txt2.text+="Property="+a.@name+"("+a.@type+")\n";
}
else
{
txt2.text+="Property="+a.@name+"="+btn1[a.@name]+"("+a.@type+")\n";
}
}
for each (var m:XML in info..method)
{
txt2.text+="Method="+m.@name+"="+btn1[m.@name]+"("+m.@returnType+")\n";
}

}

]]>
</mx:Script>
<mx:Button id="btn1" label="Click" x="320" y="106"/>
<mx:TextArea id="txt1" height="250" width="250" x="360" y="152"/>
<mx:TextArea id="txt2" height="250" width="250" x="106" y="152"/>
</mx:Application>