-
Each char in a text field stored in an array (MX)
how can i get the contents of a text field stored into an array so i can parse it letter by letter (so i can URL encode it).
i have absolutely no idea how to. im quite new to action script, but very familiar with other languages, so i can pick up on it quick.
thanks in advance, and any help would be much appreciated.
-
hi,
assuming your textfield is named myTextField,
__________________________________________________ ____
myArray = new Array();
myArray=myTextField.text.split("");
trace(myArray);
__________________________________________________ ____
Now myArray will contain the text in array form
V E N K A T
~~~~~~~~~~~~~~~~~~~~~~~
BEGIN WITH END IN THE MIND
-
thanks alot, it worked. but im still having problems getting my original task done. im trying to get the contents of a text field to be url encoded so i can pass it to a php file. heres what i got so far:
theNews is my array
adminnews is my text field
-------------------------------------
theNews = new Array();
theNews=adminnews.text.split("");
for(i=1;i<theNews.length();i++){
if(theNews[i]=='\n'){
theNews[i]="%0A";
}
if(theNews[i]=='\r'){
theNews[i]="%0D";
}
if(theNews[i]==' '){
theNews[i]="%20";
}
trace(theNews[i]);
}
----------------------------------------------
if you can shed some light on how i can get this done, that would be awesome, if not, thanks so much for your help already.
-
hi,
if url encoding is your ultimate goal then might as well not use an array. flash offers a function to url encode the string. here is how it goes.
assuming your textfeild name is myTextField
then
----------------------
trace(escape(myTextField.text));
----------------------
this should do away with the if statements..
V E N K A T
~~~~~~~~~~~~~~~~~~~~~~~
BEGIN WITH END IN THE MIND
-
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
|