A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: string.slice

  1. #1
    I'm trying to cut the first part of a sring off. In the actionscipt help it mentioned this slice funcion but I can't seem to get it to work. Any tricks or ideas?

    Thanks

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    667
    I prefer to use the string.substr() or string.substring() functions. for string.substring() The first number is the start index, the last number is the end index. For string.substr() it the index of the first char and how many to take from there

    Hard to explain so Ill give an example:
    Code:
    myStr = "Have a nice day!";
    a = myStr.substring(0,4);
    b = myStr.substring(5,6);
    c = myStr.substring(7,11);
    d = mystr.substring(12);
    trace("a = " + a);
    trace("b = " + b);
    trace("c = " + c);
    trace("d = " + d);
    or
    Code:
    myStr = "Have a nice day!";
    a = myStr.substr(0,4);
    b = myStr.substr(5,1);
    c = myStr.substr(7,4);
    d = mystr.substr(12);
    trace("a = " + a);
    trace("b = " + b);
    trace("c = " + c);
    trace("d = " + d);
    Give the same result.


    They work a little diffrently so try them out and see wich one is best for you.

  3. #3
    Thanks etcettra,
    That works great! Appreciate the help.

  4. #4
    Thanks etcettra,
    That works great! Appreciate the help.

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