hobbis
09-29-2006, 03:13 PM
Getting some strange behaviour trying to override a private var:
private var _hit:Boolean = false;
public function get hit():Boolean { return _hit; }
public function set hit(b:Boolean):void
{
_hit = b;
}
//in child class
override public function get hit():Boolean { return _hit; }
override public function set hit(b:Boolean):void
{
_hit = b;
asset_mc.animation_mc.gotoAndPlay("capture");
}
In the child class, it doesn't know about _hit:
ReferenceError: Error #1065: Variable _hit is not defined.
So I guess I have to declare the _hit var in the child class as well? This seems a bit strange. Can someone explain how to override private properties using the get set methods? Thanks
private var _hit:Boolean = false;
public function get hit():Boolean { return _hit; }
public function set hit(b:Boolean):void
{
_hit = b;
}
//in child class
override public function get hit():Boolean { return _hit; }
override public function set hit(b:Boolean):void
{
_hit = b;
asset_mc.animation_mc.gotoAndPlay("capture");
}
In the child class, it doesn't know about _hit:
ReferenceError: Error #1065: Variable _hit is not defined.
So I guess I have to declare the _hit var in the child class as well? This seems a bit strange. Can someone explain how to override private properties using the get set methods? Thanks