0

有谁知道如何访问 Action 脚本中可用的所有类的名称及其函数和变量(字符串、数组、数学......)。

我正在构建某种代码编辑器,我想在其中实现代码辅助。我正在使用 Flash 生成器。我的意思是,毕竟,当你说:

var a:String = String.valueOf(12345);

那么flash builder必须知道“String”和“valueOf”是什么意思,那么有什么方法可以访问这些信息吗?

4

1 回答 1

1

Adobe provides full documentation for their packages in the ActionScript 3.0 Reference for the Adobe Flash Platform.

The ActionScript® 3.0 Reference for the Adobe® Flash® Platform contains the ActionScript language elements, core libraries, and component packages and classes for the tools, runtimes, services and servers in the Flash Platform.

Otherwise, you could describeType() packages from playerglobal.swc.

Produces an XML object that describes the ActionScript object named as the parameter of the method. This method implements the programming concept of reflection for the ActionScript language.

Value parameter may be an instance or class type.

By instance: describeType(new MovieClip());

If the value parameter is an instance of a type, the returned XML object includes all the instance properties of that type, but does not include any static properties. You can check for this condition when you parse the XML object by examining the value of the <type> tag's isStatic attribute, which is false when the value parameter is an instance of a type.

By type: describeType(MovieClip);

To obtain the static properties of a type, pass the type itself for the value parameter. The returned XML object includes not only the type's static properties, but also all of its instance properties. The instance properties are nested inside a tag named <factory> to distinguish them from the static properties. In this case, the isStatic attribute of the <type> tag is true.

For example, to obtain all variables and accessors of a type for your content assist / intellisense implementation, you could:

/**
 * Returns variables and accessors
 */
public function properties(value:*):XMLList
{
    var xml:XML = describeType(value);
    return (xml..variable + xml..accessor);
}
于 2013-05-14T15:01:43.923 回答