Ambiguous reference bug for namespaces in Flex
by Ruben
Before coming up with a solution for binding read-only accessors a few months ago, I had already tried out various alternatives, among which the following (which was later also pointed out by others through the comments):
[Bindable] // public getter: public function get someProperty ():String { return this._someProperty; } // protected setter: protected function set someProperty (value:String):void { this._someProperty = value; }
However, the problem here was that Flex throws an error saying "1000: Ambiguous reference to someProperty" whenever you try to use the setter.
After reading a post by Adam Flater I decided to start looking through the documentation and found out that this is in fact a known compiler bug:
174646: If a class contains accessor functions with different access control namespace attributes, (for example, aprotected setter and a public getter) using one of them causes a compile-time-error, for example,Compiler-Error 1000: Ambiguous reference to myVar
The workaround is to rename your getter or setter function to avoid the mismatch.
Common Flex 2 compiler errors and known issues
This bug doesn't seem to have been fixed in any of the Flex 2 hotfixes, and neither in the Flex 3 Beta (thanks to Wietse for testing). Let's hope the folks over at Adobe are going to do something about it..
Comments (read newer)
Hi,
May be, you want to refer to the next code:
protected function set someProperty
Regards,
Dano
Ah Dano thanks so much, darn human automatism
if setter namespace is known(for example public) you can do following to go around that bug.
when you refference the setter do :
myObject.public::someProperty and compiler is happy again
Cool! Thanks levan
thanks for the article
it seems odd that AS3 calls itself an OOP language…but this simple pattern of having a property read-only except for derived classes is not supported…thanks Adobe!