I know that AS3 doesn’t normally allow method or operator overloading, but I do think I’ve seen a workaround before for the [] operator. Basically I’m trying to either inherit from or wrap around a Dictionary – I don’t necessarily care which – and create slightly special behavior for that operator, namely in the case it’s used twice in a row (object[x][y]). Isn’t there some sort of special workaround or loophole I can use for this? Thanks!
Share
You can override
gettersandsettersusing theProxyclass.If you extend
Proxyand make your classdynamic, you’ll be able to override these methods:getProperty()setProperty()Using the
[]operator will apply to this as expected (i.e.thing.xwill be the same asthing["x"]if you override the getter forx).If you look at the links I’ve added above to the Proxy class, there are blocks of example code that demonstrate how to implement what you’re trying to do.