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.
精彩评论