Ambiguous reference bug for namespaces in Flex

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):

// 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..

8 thoughts on “Ambiguous reference bug for namespaces in Flex

  1. @tomwag: I don’t entirely agree with you there. First off, it’s mostly the people that call AS3 an Object Oriented language.

    But mainly I disagree because your problem (“this simple pattern of having a property read-only except for derived classes is not supported”) has little to do with a programming-language being Object Oriented or not.

  2. I’m coming from the .NET world and trying to learn Flex. Basic compiler bugs like this make it hard to take Flex seriously. Especially the fact that it hasn’t been fixed and is over a year old.

  3. The same thing is happening when we have base class with, for example, protected setter and getter. And we inherit this class. In inherited class we override, for example, getter. Then we have the same error. To fix this we need to override getter too.

Comments are closed.