我不明白为什么只有一个论点通过。在我看来,我正在通过 2,但 flash 不这么看。为什么?我正在尝试构建一个简单的计算器,您将第一个数字(num1)放在文本字段中,将第二个数字(num2)放在另一个文本字段中,单击加/减/乘/除按钮并让答案出现在一个第三个文本字段。我在这里
ArgumentError:错误 #1063:CalculatorLab/addme() 上的参数计数不匹配。预期 2,得到 1。
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class CalculatorLab extends MovieClip {
public function CalculatorLab() {
// constructor code
var num1:Number = 0;
var num2:Number = 0;
addbtn.addEventListener(MouseEvent.CLICK, addme);
subtractbtn.addEventListener(MouseEvent.CLICK, subtractme);
multiplybtn.addEventListener(MouseEvent.CLICK, multiplyme);
dividebtn.addEventListener(MouseEvent.CLICK, divideme);
}
function addme(num1, num2):void {
num1txt.text = String(num1);
num2txt.text = String(num2);
var answer:Number = num1 + num2;
trace(answer);
answertxt.text = String(answer);
}
function subtractme(num1, num2):void {
num1txt.text = String(num1);
num2txt.text = String(num2);
var answer:Number = num1 - num2;
trace(answer);
answertxt.text = String(answer);
}
function multiplyme(num1, num2):void {
num1txt.text = String(num1);
num2txt.text = String(num2);
var answer:Number = num1 * num2;
trace(answer);
answertxt.text = String(answer);
}
function divideme(num1, num2):void {
num1txt.text = String(num1);
num2txt.text = String(num2);
var answer:Number = num1 / num2;
trace(answer);
answertxt.text = String(answer);
}
}
}