variablesapache-flexsyntax

declaring variables in flex


I found this in an ActionScript class in flex.

protected::valueMin

Please let me know what this exactly means. at the outset, I dont see any type declaration. I am a newbie in flex.


Solution

  • As spash said, this syntax is used for namespaces. In this case it is actually used to workaround a compiler issue. The thing is that you can't declare an accessor in which the getter has a different scope as the setter. It is to say, you can declare it, but accessing the accessor via it's name will result in a compile error.

    Consider the following:

    private var _name:String;
    
    [Bindable(event="nameChange")]
    public function get name():String {
      return _name;
    }
    
    private function set name(value:String):void {
      if (value !== _name) {
        _name = value;
        dispatchEvent(new Event("nameChange"));
      }
    }
    

    If you now try to access the "name" property to get or set it, this will result in a compile error:

    name = "John Doe";
    

    However, if you specify the scope the code will compile.

    private::name = "John Doe";