views:

54

answers:

1

Hi
How do I backspace a text string. If this was a login screen, I should be able to backspace one character if I made an error, and continue my login. I'm not sure how to accomplish this. Please help.
Thanks,

The sample code is obviously wrong, but may help explain

var log:String = "LOGIN_777";
trace(log);
b.addEventListener(MouseEvent.CLICK, strangThang);

function strangThang(e:MouseEvent){
/*
I want it to read 'LOGIN_77' and keep decreasing
after one click, it outputs 'LOGIN_7770'
*/
    log += log.charAt.length-1;
}
+3  A: 

I'd guess you should try something like that (not a lot AS experience, so might require some more work).

log = log.substr(0, log.length - 1);
Mario
@Mario, thanks. That's what I was trying to do.
VideoDnd
You can just say `log = log.substr(0, -1);`. If you pass a negative number as a parameter to `substr`, it is counted from the end of the string.
TandemAdam