A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Each char in a text field stored in an array (MX)

  1. #1
    Member
    Join Date
    Mar 2003
    Posts
    30

    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.
    <3 steve.

  2. #2
    Member
    Join Date
    Apr 2002
    Posts
    76
    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

  3. #3
    Member
    Join Date
    Mar 2003
    Posts
    30
    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.
    <3 steve.

  4. #4
    Member
    Join Date
    Apr 2002
    Posts
    76
    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

  5. #5
    Member
    Join Date
    Mar 2003
    Posts
    30
    you RULE!
    <3 steve.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center