Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
753 views
in Technique[技术] by (71.8m points)

actionscript 3 - Not all text is being displayed when using on-screen keypad

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...