AS3 Reverse String

How To: Reverse Any Given String Using AS3

Reversing a string is not something you might implement on a daily basis, however, having a handy way of doing so is always a great go to option. Here is a function that allows you to input a string of any length and it will then be outputted being reversed. This is definitely one function to add to your Flash utilities.


Reverse Any Given String

function reverseString(tString:String):String {
var tmp_array:Array=tString.split("");
var tmpString:String=tmp_array.join("");
return tmpString;

Source Demonstration

[kml_flashembed publishmethod=”static” fversion=”9.0.0″ movie=”” width=”510″ height=”160″ targetclass=”flashmovie”]Get Adobe Flash player


Download source

3 thoughts on “How To: Reverse Any Given String Using AS3

  1. function reverseString(tString:String):String {
    var tmpString:String = "";
    var len:uint = tString.length;
    tmpString += tString.substr(len-1, 1);
    return tmpString;

    More fast than Array conversion and low CPU use.

Comments are closed.