我们已经知道,在包中可以直接定义函数。我迫切地想知道,在包中定义的函数到底是什么呢(也就是父类是什么)?一个新的函数:flash.util.describeType浮出了水面。这个函数可以以XML的形式返回这个对象所有的可用信息。
//TEST3.AS
package {
import flash.util.trace;
import flash.util.describeType;
import flash.display.MovieClip;
public var surname:String = "Mueller";
public function willi(){
trace("willi " + surname + " was here");
}
public class Test extends MovieClip {
public function Test() {
trace("Test " + describeType(willi));
}
}
}
我们会看到以下信息:
[SWF] C:\Documents and Settings\Administrator\My Documents\Flex\TEST2\bin\TEST2-debug.swf - 1,121 bytes after decompression
Test <type name="[[MethodClosure]]" base="Function" dynamic="false" final="true" static="false">
<accessor name="length" access="readwrite" type="int" declaredBy="[[MethodClosure]]"/>
<accessor name="prototype" access="readwrite" type="Object" declaredBy="Function"/>
<method name="toString" declaredBy="Function" returnType="String"/>
<method name="call" declaredBy="Function" returnType="Object">
<parameter index="1" type="Object" optional="true"/>
</method>
<method name="apply" declaredBy="Function" returnType="Object">
<parameter index="1" type="Object" optional="true"/>
<parameter index="2" type="Object" optional="true"/>
</method>
</type>
//TEST3.AS
package {
import flash.util.trace;
import flash.util.describeType;
import flash.display.MovieClip;
public var surname:String = "Mueller";
public function willi(){
trace("willi " + surname + " was here");
}
public class Test extends MovieClip {
public function Test() {
trace("Test " + describeType(willi));
}
}
}
我们会看到以下信息:
[SWF] C:\Documents and Settings\Administrator\My Documents\Flex\TEST2\bin\TEST2-debug.swf - 1,121 bytes after decompression
Test <type name="[[MethodClosure]]" base="Function" dynamic="false" final="true" static="false">
<accessor name="length" access="readwrite" type="int" declaredBy="[[MethodClosure]]"/>
<accessor name="prototype" access="readwrite" type="Object" declaredBy="Function"/>
<method name="toString" declaredBy="Function" returnType="String"/>
<method name="call" declaredBy="Function" returnType="Object">
<parameter index="1" type="Object" optional="true"/>
</method>
<method name="apply" declaredBy="Function" returnType="Object">
<parameter index="1" type="Object" optional="true"/>
<parameter index="2" type="Object" optional="true"/>
</method>
</type>
回复Comments
作者:
{commentrecontent}