AS3 Reverse String

How To: Reverse Any Given String Using AS3

Tags: ,

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.

Enjoy!

Reverse Any Given String

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

Source Demonstration

Get Adobe Flash player

Download source

Related Posts

AS3 Shake Detection

Video: Shake Detection Within Flash Using AS3

Adobe Help Documentation

Dynamically Add Script to Frames of a MovieClip with AS3

3 Comments

  1. Tobey

    10.24.2009

    Reply

    This it is also possible:
    function reverseString(tString:String):String {
    return tString.split(“”).reverse().join(“”);
    }

  2. Your sollution will be no faster, it’s just harder-to-read sollution. That’s all.

  3. Rafael

    02.10.2010

    Reply

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

    More fast than Array conversion and low CPU use.

Leave a Reply









Latest Theme From WooThemes

Unsigned

By WooThemes

Unsigned is a hugely powerful, cleverly developed, yet super easy theme to use for musicians and bands looking to showcase their music, tours, photos, videos and band members all from within WordPress. It even allows you to sell your albums and merchandise thanks to the WooCommerce integration. It truly is a massive theme that will cover your every need.

Theme Categories: Multimedia, Responsive

Latest Tweets