I have a variable, and a function for brevity lets consider it looks like this:
private function applyDiscount (value:Number):Number
{
return value*_discount; //_discount defined somewhere else
}
OK thats all fine and dandy but say I want to be able to call that function and be able to pass my own discount, but still use the _discount as a default.
I CAN do this:
private function applyDiscount (value:Number, discount:Number = 50):Number
{
return value*discount;
}
This will make discount default to 50 but I don't know it at authortime so I need to do this but its not allowed in Flex.
private function applyDiscount (value:Number, discount:Number = _discount):Number
{
return value*discount;
}
So my question is, what is the best way to achieve the same as the last example in Flex?
Thanks.