1

在 C# 中有一些称为索引器的东西,它们的作用与此类似:

public Something
{
     public Object this[String s]
     {
           // do something with s
           return something;
     }
}

然后你可以这样称呼它:

Something instance = new Something();
Object obj = instance["banana's"];

我只是想知道是否可以在使用方括号的 AS3 中实现类似的功能,还是我需要一个函数来执行此操作?

4

1 回答 1

1

You can achieve something similar by extending flash.utils.Proxy.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Proxy.html

But it's not quite the same or as flexible as the C# option.

于 2011-08-29T04:16:49.350 回答