Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StringBuilder in Flex

I'm looking for fast string concatenation class or so in Flex. Like StringBuilder in Java.

Thanks

like image 609
tefozi Avatar asked May 12 '10 01:05

tefozi


1 Answers

var str1:String = "Vinoth";
var str2:String = "Babu";
var str3:String = "Chennai";
var str4:String = concat(str1, " ", str2, " ", str3)

trace(str4) would result you str4 == "Vinoth babu Chennai"

String Concat Class

public class StringBuffer
{
    public var buffer:Array = new Array();

    public function add(str:String):void
    {
        for (var i:Number = 0; i < str.length; i++)
        {
            buffer.push(str.charCodeAt(i));
        }
    }

    public function toString():String
    {
        return String.fromCharCode.apply(this, buffer);
    }
}

Here you have a more indepth than the above class written.

http://blogs.adobe.com/pfarland/2007/10/avoiding_string_concatenation.html

like image 155
Thalaivar Avatar answered Oct 16 '22 08:10

Thalaivar