开发者

Implementing Indexer from C# in Actionscript3

Within C# the开发者_运维技巧re're these things called indexers that do something similar to this:

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

You can then call it like so:

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

I'm just wondering if it's possible to have something like this implemented in AS3 where you use the square brackets, or do I require a function to do this?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜