I have an string made from using getpixel on an image.
I want to compress this string using lzw compression, but the string is way
too big so my flash application hangs.
is there anyway to make flash pause 50 milliseconds every 3 sekunds? or
every 1000 iteration?
here is the part of the code that compress the string
public static function compress(str:String):String {
var dico:Array = new Array();
var skipnum:Number = xmlsafe ? 5 : 0;
for (var i = 0; i<256; i++) {
dico[String.fromCharCode(i)] = i;
}
if (xmlsafe) {
dico["<"] = 256;
dico[">"] = 257;
dico["&"] = 258;
dico["\""] = 259;
dico["'"] = 260;
}
var res:String = "";
var txt2encode:String = str;
//var txtArray:Array = new Array();
//
var splitStr:Array = txt2encode.split("");
var len:Number = splitStr.length;
var nbChar:Number = 256+skipnum;
var buffer:String = "";
//<------------------------------------------->// her is the
compression
for (var i = 0; i<=len; i++) {
var current = splitStr[i];
if (dico[buffer+current] !== undefined) {
buffer += current;
} else {
res += String.fromCharCode(dico[buffer]);
dico[buffer+current] = nbChar;
nbChar++;
buffer = current;
}
}
//<------------------------------------------->//
return res;
}
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders