开发者

Implementing Indexer from C# in Actionscript3

开发者 https://www.devze.com 2023-03-31 22:42 出处:网络
Within C# the开发者_运维技巧re\'re these things called indexers that do something similar to this:

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

精彩评论

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