RockyMyx / aszip

Automatically exported from code.google.com/p/aszip
0 stars 1 forks source link

ASZip alters source for files added to zips #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load a SWF file in an AIR application as a byteArray so it can be
included in every zip.
var _ur:URLRequest = new URLRequest( "assets/index.swf" );
var _ul:URLLoader = new URLLoader( _ur );
_ul.dataFormat = URLLoaderDataFormat.BINARY;
_ul.addEventListener( Event.COMPLETE, _onAssetSWFLoad, false, 0, true );
_ul.load( _ur );
2. Add the byteArray to a new ASZip using addFile. (This alters the length
of the byteArray, corrupting the file. It also doesn't reset the position
in the byteArray).
var _zipper:ASZip = new ASZip();
zipper.addFile( _swfFile, "index.swf" );
3. Repeat the process again, by creating a new ASZip and adding the same
byteArray using addFile. The SWF in the zipped file will be corrupted.

What is the expected output? What do you see instead?
It should not alter the source byteArray. Also (to a lesser degree) it
should reset the position in the byteArray to where it was before adding
the file.

What version of the product are you using? On what operating system?
I'm using version 0.2 of ASZip, Flex 3.0.0, Flash Player 9 and Windows XP.

Please provide any additional information below.
You can work around this by making a copy of your byteArray using the
readBytes method to make a copy.
var tempCopy:ByteArray = new ByteArray();
_swfFile.readBytes( tempCopy, 0, _swfFile.length );
_swfFile.position = 0;

Thanks for this framework, though. It is very easy to use!

Original issue reported on code.google.com by nils.thi...@gmail.com on 25 Jul 2008 at 6:19

GoogleCodeExporter commented 9 years ago
Hi Nils,

Thanks for the info. I will fix that !

cheers,

Thibault

Original comment by thibault.imbert on 14 Aug 2008 at 3:42