Skip to main content
Participating Frequently
January 5, 2008
Question

Inheritance problem

  • January 5, 2008
  • 4 replies
  • 406 views
Hi.

According to "ActionScript 3.0 Language and Components Reference" you "cannot use the override attribute on any of the following: Variables, Constants, Static methods, Methods that are not inherited, Methods that implement an interface method, Inherited methods that are marked as final in the superclass".

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/statements.html#override

So how can I have a boolean property in a subclass as true instead of false as in its superclass. Something like:
This topic has been closed for replies.

4 replies

kglad
Community Expert
Community Expert
January 6, 2008
you're not overriding the super class. you're creating a super class that does not have a variable b with a fixed value.
PluraAuthor
Participating Frequently
January 6, 2008
Thanks guys.

Another way, I think, is to create getter/setter methods that can be override in the extended class...
Participating Frequently
January 5, 2008
package {
public class MyClass {

public var b:Boolean = false;

public function MyClass(){}

public function setB(val:Boolean):void {
b = val;
}

}
}


package {
public class SubClass extends MyClass {

public function SubClass () {
super();
super.setB(true);
}
}
}
kglad
Community Expert
Community Expert
January 5, 2008
you can't. create another super class of MyClass that does contain b. then extend that class with a SubClass that has b=false and extend that class with another SubClass that has b=true, if it seems desirable to have b fixed to one value or another for each class.