Public properties have implicit getter/setter behavior, but as you found you
can not override an implicit function with an explicit override (yes, once
compiled their will be an actual explicit function if you look at the
source, but this doesn't help you during compilation).

If Class A is always used as a super class, have your colleague change it
from public to protected. If however, you really want to add custom
code/functionality for the retrieval of the variable that is different than
what is supplied by the underlying public property (in your example it looks
like you are trying to force it to return a set value regardless of what the
actual value is).

I'd suggest playing with BindingUtils (assuming the public property
iAmPublic is [Bindable]):

var cw:ChangeWatcher = BindingUtils.bindSetter( overrideSet, this,
iAmPublic);

private function overrideSet( value:int ):void
{
  iAmPublic = 9;
}

This guarantees that if the property is set, it is set to the value you
want, but does not guarantee that the property has a value (or in this case
a specific value. You can ensure the property is set by explicitly assigning
a vale (then overridden to your desired value) during initialization.



On Tue, Dec 7, 2010 at 2:51 PM, Dale Bronk <[email protected]> wrote:

> I'm sure there is a reason for this, but I don't know it and can't seem to
> find it googling.
>
> I have:
>
> ClassA
>        public var iAmPublic : int = 0;
>
> ClassB extends ClassA
>        public function get iAmPublic() : int { return 9; }
>                - or -
>        override public function get iAmPublic() : int { return 9; }
>
> Both compile error out.  Either with I must override the function or
> invalid
> override.
>
> If I change ClassA to have public function get/set ....   it will work
> fine.
> I realize that behind the scenes a get/set must be created for me, but it
> seems to me the compiler should be smart enough to handle this.  The big
> problem is that I'm dealing with a swc that has the property as a public
> var
> so I can't override it.
>
> Anyone have any ideas?  I can go to the person and have them change it to
> do
> getter/setter, but doesn't this seem like something that should just work?
>
> Thanks,
> Dale
>
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in
> the subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by http://www.fusionlink.com
> -------------------------------------------------------------
>
>
>


-- 
Darin Kohles

Reply via email to