You don't use a loop. Instead, you create the variables needed as properties, then create a function that does an *iteration* of the loop. Then on every frame you do N calls to that iteration, until it's over.

Or if you want:
http://labs.zeh.com.br/blog/?page_id=97#lzw

This is an AS2 LZW compression/decompression class that splits code between frames (with varied CPU utilization) and get the data once it's done.

Zeh

thomas nordahl wrote:
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

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to