-
why does this script stop working after the 1st loop?
1st Frame:
myString = "anonymous";
2nd Frame:
_root.word.text = myString;
if (myString.lastIndexOf(String.fromCharCode(Key.getA scii())) == myString.length-(myString.length)) {
myString = myString.slice(1, myString.length);
}
3rd Frame:
gotoAndPlay(2);
after u type the letter "a", it doesn't respond to any keypress. anyone kno y this would b?
I am determined to make better mistakes tomorrow.
-
What do you mean it doesnt respond to any keypress?
I made up a small one just like you have and I can type in it.?
Explain
-
ok, when i test it, i can type the first letter "A" and the code works, but when i try to type the next letter "N", it doesnt do anything. and i even set it up so that a message would a appear when the first if statement (myString.lastIndexOf(String.fromCharCode...) is fulfilled, and that doesnt work! im not sure wuts wrong... could u send me the one that u set up?
I am determined to make better mistakes tomorrow.
-
The ActionScript Master
Would
code:
myString = "anonymous";
myString = myString.slice(1, myString.length);
trace(myString)
//traces: ""
??????
Master64
useing:XP,MX
don't send me PM's because i never check it so if you what to contact me use Email
-
so your trying to get it to remove a ltter with a letter is presses?
-
i want the user to press the key that corresponds with the first letter of the word, on the key press i want that letter to be removed and then the user will hav to press the next key until the word is gone
I am determined to make better mistakes tomorrow.
-
Former Member now elsewhere
Ok. I'd approach this in a single frame:
//You set the value for the string
myString = "anonymous";
//Then you replaced it with input text
_root.word.text = myString;
// This code I'm not following too well but I think you did
// length-length which is always 0. If that's true then you slice.
// This is your original:
if (myString.lastIndexOf(String.fromCharCode(Key.getA scii())) == myString.length-(myString.length)) {
myString = myString.slice(1, myString.length);
}
// What about something like this (my syntax may be wrong here!!
// But you can get an idea of the approach)
while(mystring.length>0){
onClipEvent(keydown){
if(mystring.index[0]==Key.getAscii){
myString = myString.slice(1, myString.length);
}
}
}
That the idea?
NCD
-
no im sorry... its still not working. i dont get it, my code works with some word like "abcdefghijklmnopqrstuvwxyz" but not "anonymous". can anyone figure this out?
I am determined to make better mistakes tomorrow.
-
hey im not sure if anyone cares but i found out how to do it
if (Key.getAscii() == myString.charCodeAt(0)) {
myString = myString.slice(1, length);
}
thank you all!
I am determined to make better mistakes tomorrow.
-
Cool!! Thanks for posting that you fixed it and thanks for posting the script that fixed it. Its good to not leaving us hanging
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|