| From | Sent On | Attachments |
|---|
| Subject: | Re: [haXe] overriding var getter/setter ?... | |
|---|---|---|
| From: | Nicolas Cannasse (ncan...@motion-twin.com) | |
| Date: | Feb 1, 2009 6:08:48 am | |
| List: | com.motion-twin.lists.haxe | |
Refine Search
| From | Sent On | Attachments |
|---|---|---|
| Stéphane Merlin | Jan 31, 2009 10:10 am | |
| Axel Huizinga | Feb 1, 2009 4:12 am | |
| Nicolas Cannasse | Feb 1, 2009 6:08 am | |
| Stéphane Merlin | Feb 1, 2009 8:50 am | |
| Axel Huizinga | Feb 1, 2009 10:03 am | |
| Stéphane Merlin | Feb 1, 2009 10:33 am | |
| Tony Polinelli | Feb 1, 2009 4:25 pm | |
| Baluta Cristian | Feb 2, 2009 12:09 am | |
| Nicolas Cannasse | Feb 2, 2009 12:46 am |
| Subject: | Re: [haXe] overriding var getter/setter ?... | |
|---|---|---|
| From: | Nicolas Cannasse (ncan...@motion-twin.com) | |
| Date: | Feb 1, 2009 6:08:48 am | |
| List: | com.motion-twin.lists.haxe | |
Stéphane Merlin a écrit :
Hello, Diving in the powerfull haxe language, I'm in front of a wall when I try to override a superclass variable. I explain :
/**/ class Square extends Sprite {
/******/ public static inline var WIDTH:Int = 32;
/**/ override public var x(getX, setX):Float; /**/ private var __x:Int; /**/ public function getX():Float { return __x; } public function setX(_f:Float):Float { __x = _f; super.x = Square.WIDTH * _f; return _f; }
...
I get the message "Field x has different property access than in superclass" Isn't there a way to avoid that and to use overriding property ? Thanks.
If "Sprite" is the Flash9 class, then you can't redefine its "x" property. You can however give it a different name, as _x.
If however the Sprite class already has getX/setX methods, then you can simply override these and use super.getX / super.setX.
Nicolas
-- haXe - an open source web programming language http://haxe.org

