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:

     

 

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=" [email protected]+"="+btn1[[email protected]]+"("[email protected]+")\n";
}
for each(var a:XML in info.accessor)
{
if([email protected]=='writeonly')
{
txt2.text+="Property="[email protected]+"("[email protected]+")\n";
}
else
{
txt2.text+="Property="[email protected]+"="+btn1[[email protected]]+"("[email protected]+")\n";
}
}
for each (var m:XML in info..method)
{
txt2.text+="Method="[email protected]+"="+btn1[[email protected]]+"("[email protected]+")\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>


  

 

Advertisements

Share on Google+Share on Google+

Using the interospection API:

Posted on: February 16, 2005 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Using the interospection API:  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads