I came across some very weird behaviour and I can't seem to find an explanation for it. I am trying to write a class that will store compressed ByteArrays that are retreive throught the bitmapData.getPixels. Here is some testing code, that I wrote for the testing if a decompressed ByteArray can be parsed back into an Bitmapdata object.

It all works well if the uncompress/compress block is in the code. When i comment that code out, I get this error:

Could someone tell me what is happening here?


<error>
Error: Error #2030: End of file was encountered.
        at flash.display::BitmapData/setPixels()
        at GreyFilter_fla::MainTimeline/frame1()
</error>

<code>

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

var destPoint:Point = new Point();
var source:Sprite = getChildByName('mcWalkArea') as Sprite;
var sourceRect:Rectangle = new Rectangle(0, 0, source.width, source.height);
var a:BitmapData = new BitmapData(sourceRect.width, sourceRect.height);

var storedMapData:ByteArray;

a.draw( source );
//create a black and white area.
a.threshold(a, sourceRect, destPoint , "!=", 0xFFFFFFFF , 0xFF000000 );
storedMapData = a.getPixels(sourceRect);

/* Try uncommenting this
trace(storedMapData.length);
storedMapData.compress()
trace(storedMapData.length);

storedMapData.uncompress()
trace(storedMapData.length);
*/

var tData:BitmapData = new BitmapData(sourceRect.width , sourceRect.height)
tData.setPixels( sourceRect , storedMapData );

var i:int = 0
while(i < source.width){
        
        trace( tData.getPixel(i , 0 ) )
        i++
}

</code>

Jiri
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to