Created a keypad in Flash cs6 following a tutorial. Once done the "1" key and the "4" key work--those numbers show up in the display. The rest of the numbers, however, do not. For example, if I click the 1, 2, 3, and 4 buttons the display only shows "14" instead of "1234". I put a "trace" line of code on each button to see if they are at least being recognized when I click on them...all of the buttons apparently work.
The code:
stop();
var displayText:String = "";
function numDisplay(num:String)
{
displayText += num;
displayNum.text = displayText;
}
key1bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey1);
function pressedKey1(event:MouseEvent):void{
numDisplay("1");
trace(displayNum.text);
}
key2bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey2);
function pressedKey2(event:MouseEvent):void{
numDisplay("2");
trace(displayNum.text);
}
key3bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey3);
function pressedKey3(event:MouseEvent):void {
numDisplay("3");
trace(displayNum.text);
}
key4bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey4);
function pressedKey4(event:MouseEvent):void {
numDisplay("4");
trace(displayNum.text);
}
key5bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey5);
function pressedKey5(event:MouseEvent):void {
numDisplay("5");
trace(displayNum.text);
}
key6bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey6);
function pressedKey6(event:MouseEvent):void {
numDisplay("6");
trace(displayNum.text);
}
key7bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey7);
function pressedKey7(event:MouseEvent):void {
numDisplay("7");
trace(displayNum.text);
}
key8bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey8);
function pressedKey8(event:MouseEvent):void {
numDisplay("8");
trace(displayNum.text);
}
key9bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey9);
function pressedKey9(event:MouseEvent):void {
numDisplay("9");
trace(displayNum.text);
}
key0bttn.addEventListener(MouseEvent.MOUSE_DOWN, pressedKey0);
function pressedKey0(event:MouseEvent):void {
numDisplay("0");
trace(displayNum.text);
}
Thanks, appreciate any help you can give.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…