Introspects the Button control and prints the details to TextArea controls:
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".
This user guide is licensed for use under the terms of the Creative Commons Attribution
Non-Commercial 3.0 License.
This License allows users to copy, distribute, and transmit the user guide for noncommercial
purposes only so long as
(1) proper attribution to Adobe is given as the owner of the user guide; and
(2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms.
The best way to provide notice is to include the following link.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="getDetails()">
<s:layout>
<s:VerticalLayout />
</s:layout>
<fx:Script>
import flash.utils.*;
public function getDetails():void {
var classInfo:XML = describeType(button1);
ta2.text = classInfo.toString();
ta1.text = "Class " + classInfo.@name.toString() + "\n";
for each (var v:XML in classInfo..variable) {
ta1.text += "Variable " + v.@name + "=" + button1[v.@name] + " (" + v.@type + ")\n";
}
for each (var a:XML in classInfo..accessor) {
if (a.@access == 'writeonly') {
ta1.text += "Property " + a.@name + " (" + a.@type +")\n";
}else {
ta1.text += "Property " + a.@name + "=" + button1[a.@name] + " (" + a.@type +")\n";
}
}
for each (var m:XML in classInfo..method) {
ta1.text += "Method " + m.@name + "():" + m.@returnType + "\n";
}
}
</fx:Script>
<s:Button label="This Button Does Nothing" id="button1" />
<s:TextArea id="ta1" width="400" height="200" />
<s:TextArea id="ta2" width="400" height="200" />
</s:Application>
Related examples in the same category