PDA

View Full Version : New way to make text box with actionscript


brendanww
11-26-2005, 11:59 PM
I've been familiarizing myself with some functions that will be useful for new chat features, and I made a different type of textbox in flash:


createEmptyMovieClip("fudge", 0);
fudge.createTextField("dynamictext", getNextHighestDepth(), 0, 0, 300, 300);
fudge.dynamictext.border = true;
fudge.dynamictext.html = true;
keyListener = new Object();
k = 0;
keyListener.onKeyDown = function() {
lastkeycode = Key.getCode();
if (lastkeycode == 8) {
if (k>0) {
k--;
curtext = fudge.dynamictext.text;
newtext = curtext.substring(0, k);
fudge.dynamictext.text = newtext;
}
} else {
k++;
fudge.dynamictext.text = _root.fudge.dynamictext.text+chr(Key.getAscii());
}
};
Key.addListener(keyListener);

bleepbloop
12-08-2005, 04:03 PM
what does it do? Which key has a value of 8?

Headshotz
12-20-2005, 09:16 AM
Pretty cool :cool:, you used php formatting on your code though, AS:


createEmptyMovieClip("fudge", 0);
fudge.createTextField("dynamictext", getNextHighestDepth(), 0, 0, 300, 300);
fudge.dynamictext.border = true;
fudge.dynamictext.html = true;
keyListener = new Object();
k = 0;
keyListener.onKeyDown = function() {
lastkeycode = Key.getCode();
if (lastkeycode == 8) {
if (k>0) {
k--;
curtext = fudge.dynamictext.text;
newtext = curtext.substring(0, k);
fudge.dynamictext.text = newtext;
}
} else {
k++;
fudge.dynamictext.text = _root.fudge.dynamictext.text+chr(Key.getAscii());
}
};
Key.addListener(keyListener);

PsychoSpike
02-06-2006, 08:04 AM
that is a way to make text, but not the best way, (of course you know how)

i was tinkering with key. events too and found that there is no way to use shift with non letters (i mean uppercase and lowercase letter can work) but not for for example "?" which is shift + "," on my keyboard...

any ideas?

sophistikat
02-10-2006, 02:05 PM
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002294.html
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("The ASCII code for the last key typed is: "+Key.getAscii());
};
Key.addListener(keyListener);1 = 49
Shift = 0
Shift + 1 = 33

Headshotz
02-11-2006, 05:11 AM
Thanks for that link :)