setting actionscript 3 superclass variables
- by jedierikb
In AS3, if I have a class such:
public class dude
{
//default value for a dude
protected var _strength:Number = 1;
public function dude( ):void
{ super( );
//todo... calculate abilities of a dude based on his strength.
}
}
and a subclass
public class superDude extends dude
{
public function superDude( ):void
{
_strength = 100;
super( );
trace( "strength of superDude: " + _strength );
}
}
This will trace strength of superDude is 1. I expected the variable I set in the subclass (prior to calling the superclass constructor) to remain.
Is there a way to assign class variables in subclass constructors which are not over-written by the superclass construtor? Or should I pass them up as constructor variables?