Posted By

alvincrespo on 02/15/10


Tagged

actionscript String to reverse how as3


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

adrianparr


How to Reverse a String


 / Published in: ActionScript 3
 

  1. var pString:String = "hello";
  2. var rString:String = "";
  3.  
  4. /*
  5. h e l l o
  6. 0 1 2 3 4 - position of the letter
  7. 1 2 3 4 5 - length of string
  8. - initial length is 5
  9. - substr("position of letter", "get one letter")
  10. */
  11.  
  12. for(var i:int = pString.length-1; i>=0; i--){
  13. rString += pString.substr(i,1);
  14. }
  15.  
  16. trace("String: " + pString);
  17.  
  18. trace("Reverse String: " + rString);

Report this snippet  

You need to login to post a comment.