You may be able to find a combination package FLASH.UTIL croatia in AS3, these kits provide reflection, not the reflective and visual effects here in the "reflection" confusion. Reflection mentioned here comply with the following features. (I believe some programs written reflective certainly know what? Foreign authors croatia very carefully) 1, 2 determines the class of an object, to get this kind of modifier, properties, methods, constructors, and the parent class 3, identify Constant affirms and method definitions that belong to a specific interface 4, 5 objects at run time by the name of the class structure of a class, get the value of each domain / Settings croatia category, even until runtime domain names are unknown. croatia 6. The method calls the object, even if the method is still unknown at run time. 7, you can be described as an object to use as an XML class returns such as, for example: package {importflash.display.Sprite importflash.utils.describeType publicclassDescribeTypeExample extendsSprite {publicfunctionDescribeTypeExample () {var child: Sprite = newSprite () var description: XML = describeType (child) trace (())}}} If we want to dynamically create an object when the next one under the name, then we can use this method "getDefinitionByName ()". package {importflash.display.DisplayObject importflash .display.Sprite importflash.utils.getDefinitionByName publicclassGetDefinitionByNameExample extendsSprite croatia {privatevarbgColor: uint = 0xFFCC00; privatevarsize: uint = 80 publicfunctionGetDefinitionByNameExample () {varClassReference: Class = getDefinitionByName croatia ("flash.display.Sprite") as Class varinstance: Object = newClassReference () instance.graphics.beginFill (bgColor) instance.graphics.drawRect (0, 0, size, size) instance.graphics.endFill () addChild (DisplayObject (instance))}}} Of course, some limitations to handle reflection when FLASH PLAYER croatia when, because of lack of information, when compiled, at run time, so the built-in classes for SPRITE may very well, but if it is a custom class, making some of the following operations when we may have trouble package { importcom.customtypes.string // Custom String Implementation Class importflash.utils.getDefinitionByName publicclassGetDefinitionByNameExample {publicfunctionGetDefinitionByNameExample () {varClassReference: Class = getDefinitionByName ("com.customtypes.string") as Class varinstance: Object croatia = newClassReference () instance.customParameter = " my parameter "}}} Although we import the required packages, getDefinitionByName method call because there is no reference croatia to the internal interrupted, the reasons noted earlier runtime compilation is still allowed. croatia To solve this problem, you must declare an example of an object at least in the aforementioned code. So your custom objects will be compiler so that when the dynamic execution of access to relevant information so if you have this idea: using reflection and XML files (save some configuration UI) is dynamically croatia create a series of UI You must realize that affirms your custom UI to FLASH PLAYER at runtime can learn this information
2014 Baidu
No comments:
Post a Comment