PDA

View Full Version : need help with text input box



DesignerDude05
December 6th, 2005, 06:41 AM
ok, i have a movie clip with lots of frame lables and i want a user to type in his or her postcode but when they click submit i want it to only pick up the first LETTERS only and then it will play the letter on the timeline and flash on the map where its corresponding place is, i have done the map animation i just need to know how to select the users first letters, bare in mind you can have postcodes like this....

OL10 4PF
M24 2DP
BL1 33A

for example on them i want it to take the "OL", "M", & "BL" and say gotoAndPlay("OL") OR ("M") OR ("BL") Cheers guys!! and gals!!!

DesignerDude05
December 6th, 2005, 07:07 AM
*bump* oh cmon people, someones gotta know this, please :( i really need it i gotta finish this within the hour or two :) please help...

DesignerDude05
December 6th, 2005, 07:13 AM
ok i have found this this should help in a sence,


go_btn.onRelease = function(){
gotoAndPlay(+postcode_ti.text);
}

this should goto and play the postcode frame correct, but the user will type say BL1 I want it to ignore the number 1 and just take the first few letters and this example should gotoAndPlay("BL"); Frame label

DesignerDude05
December 6th, 2005, 08:08 AM
no one have a clue atleast? please???

nipi
December 6th, 2005, 10:13 AM
this takes two letters at beginning of the text and ignores nummeric values.


stop();
function getLetters() {
var myStr:String = postcode_ti.text;
letters = [];
for (var i:Number = 0; i<2; i++) {
if (!parseInt(myStr.charAt(i))) {
letters.push(myStr.charAt(i));
}
}
labelToGo = letters.join("")
_root.gotoAndPlay(labelToGo);
}
go_btn.onRelease = function() {
getLetters();
};



see is it works

gokhan
December 6th, 2005, 10:23 AM
try this code
function parse(str) {
temp = "";
for (i=0; i<str.length; i++) {
if (!(Number(str.charAt(i)))) {
temp += str.charAt(i);
} else {
break;
}
}
return temp;
}
trace(parse("BL1 33A"));

DesignerDude05
December 6th, 2005, 10:52 AM
nipi can you comment that out please do i have to change anything???

nipi
December 6th, 2005, 12:00 PM
at first, i didīnt think correctly then i gived th first solution. there is no need to use temporary array like i did. as you see , gokhanīs code uses only strings. and i think that way is much better. so i changed my solution a bit

stop();
function getLetters() {
var myStr:String = postcode_ti.text;//takes text from inputtextfield
labelToGo = "";//new empty string
for (var i = 0; i<2; i++) {//loop. runs 2 times. so function checking only first two characters
if (!parseInt(myStr.charAt(i))) {//if character is not an integrer
labelToGo += myStr.charAt(i);//add this character to "labelToGo" string
}
}
_root.gotoAndPlay(labelToGo);//change "_root", if those labels are not in main timeline
}
go_btn.onRelease = function() {
getLetters();//function for button just starts the getLetters function.
};



if those labels placed on main timeline, i think there is no need to change anything. but as you know, i realy cant immagine, how your movie is build up.

i dont use English everyday so -- sorry if ...