as3 overriding setters
- Started
- Last post
- 11 Responses
- Fariska
I'm trying to override a setter:
public override function set visible(b:Boolean){
//whatever
}but i keep getting this error:1023: Incompatible override.
- skelly_b0
I think a lot of the built in stuff is protected.
- +1 if your setter is not public from the main class, then you get failurefusionpixel
- wordsinyourmouth0
never tried overriding a setter
- Fariska0
That's pretty strange. I mean, i was able to override the play() function for the FLV playback...
- whiteout0
try and data type the function, at worst it could give you a more descriptive error
- skelly_b0
FLVPlayback is a component though. visible is DisplayObject property that is damn near the core of all things Flash. If they let you monkey with that you could be breaking things left and right.
- wordsinyourmouth0
something tells me you're going to be able to override a native api getter / setter
- wordsinyourmouth0
are you subclassing DisplayObject?
- wordsinyourmouth0
you need to find out if it's intrinsic or not.... if it's intrinsic, you're fucked
- nevermind, that was meant to be a shortcut. Doing it in a more normal wayFariska
- acescence0
A function marked override must exactly match the parameter and return type declaration of the function it is overriding. It must have the same number of parameters, each of the same type, and declare the same return type. If any of the parameters are optional, that must match as well. Both functions must use the same access specifier (public, private, and so on) or namespace attribute as well.
- Pupsipu0
i overrode .x .y like this
public override function get x():Number {
return super.x
}public override function set x(value:Number):void {
super.x = value - parent.localToGlobal(gp).x
}I don't remember why exactly you need to return super, but for your case I'm assuming
public override function set visible(b:Boolean){
super.visible = false
}Anyway, seems stupid to do.
- acescence0
yes, you are missing the return type...
public override function set visible(b:Boolean):void{
//whatever
}