9 messages in com.motion-twin.lists.haxeRe: [haXe] overriding var getter/sett...
FromSent OnAttachments
Stéphane MerlinJan 31, 2009 10:10 am 
Axel HuizingaFeb 1, 2009 4:12 am 
Nicolas CannasseFeb 1, 2009 6:08 am 
Stéphane MerlinFeb 1, 2009 8:50 am 
Axel HuizingaFeb 1, 2009 10:03 am 
Stéphane MerlinFeb 1, 2009 10:33 am 
Tony PolinelliFeb 1, 2009 4:25 pm 
Baluta CristianFeb 2, 2009 12:09 am 
Nicolas CannasseFeb 2, 2009 12:46 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [haXe] overriding var getter/setter ?...Actions
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