Question

I have a class (Wall) that inherits from Sprite.

Sprite already has width and height properties. But for wall, I need to do some other additional calculations when the properties change (f.e. make sure the new size won't cause it to overlap any other walls).

So, how do I set the width property inherited from the Sprite class from within the width setter of the Wall? (or perhaps there is an alternative way to do my bounds checking whenever width is set?)

public override function set width(w:Number):void {
    //make sure it is a valid size
    //if it is, then set the width of the *Sprite* to w. How?
}
Was it helpful?

Solution

super is what you are looking for:

    override public function set width(v:Number):void {
        if(v > 100) {
            super.width = v;
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top