Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Flex Using the interospection API:

Related Tutorials


 
 

Share on Google+Share on Google+

Using the interospection API:

Advertisement
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();
txt2.text=info.@name.toString();
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>


  

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 16, 2005

Related Tutorials

Discuss: Using the interospection API:  

Post your Comment


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