Groups | Blog | Home
all groups > flash (macromedia) > march 2007 >

flash (macromedia) : Text box... and key controled buttons.


Donjworks
3/6/2007 11:13:46 PM
Hello,

I have a text box. Whenever the user presses space... a counters increases by
1. I have an offscreen button with actionscipt:

on (keyPress "<Space>") {
box = box + 1
}

However, when the user is typing in the input textbox... and they press
space... the counter increases... but the space doesnt appear in the textbox.
Also, the textbox become unselected altogether.

Help?
Merci.
ggshow
3/7/2007 3:56:03 AM
firstly, for this line
[h]box = box + 1;[/h]
you can write it as
[h]box+=1;[/h]
or
[h]box++;[/h]

2nd, dont use keypress for button, try to use either key listener instead

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == 32) {
box++;
}
};
Key.addListener(keyListener);



good luck :smile;


AddThis Social Bookmark Button