Obtaining the Result of a Method: use a return statement that specifies the value to return.
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var playerScore:Number = average(6, 10);
trace("The player's average score is " + playerScore);
}
private function average (a:Number, b:Number):Number {
return (a + b)/2;
}
}
}
Related examples in the same category