neat, thanks for sharing.  :-)
 

-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
  

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Gordon Smith
Sent: Friday, November 09, 2007 6:45 PM
To: [email protected]
Subject: RE: [flexcoders] classes in packages


I think uncompress() works on an entire ByteArray. Here's the starting code
for reading a SWF that I use. It copies the compressed part of the SWF
ByteArray into a separate ByteArray, uncompresses it, and copies it back.
 
- Gordon
 
private function read():void
 {
  version = data.readUnsignedInt();
  if (version != SWC9 && version != SWF9)
   throw new Error("unsupported version");
   
  length = data.readUnsignedInt();
  size = length;
  
  if (version == SWC9)
  {
   // Uncompress the rest of the SWF
   // before continuing to read.
   var byteArray:ByteArray = new ByteArray();
   byteArray.endian = "littleEndian";
   var pos:int = data.position;
   data.readBytes(byteArray, 0, data.length - data.position);
   byteArray.uncompress();
   data.length = pos;
   data.writeBytes(byteArray, 0, byteArray.length);
   data.position = pos;
  }
  
  bounds = readRect();
  frameRate = data.readUnsignedByte() << 8 | data.readUnsignedByte();
  frameCount = data.readUnsignedShort();
  
  readTags();
  
  if (data.length != length || data.position != data.length)
   throw new Error();
 }

Reply via email to