3 Replies Latest reply on Oct 17, 2007 1:49 AM by JabbyPandaUA

    Serializing with ByteArray.writeObject gives a different object.

    hessml Level 1
      When I serialize an object ByteArray.writeObject and then back in with readObject I get a different object. Anyone know how to fix this?

      package {
      import flash.display.Bitmap;
      import flash.display.Sprite;
      import flash.utils.ByteArray;

      public class MarshallingTest extends Sprite {
      public function MarshallingTest() {
      var ba:ByteArray = new ByteArray();
      ba.writeObject(new Bitmap());
      ba.position = 0;
      var obj:Object = ba.readObject();
      trace(obj is Object); // true
      trace(obj is BitMap); // false
      }
      }
      }

      On further examination I can see all the fields of the object but I can't call any of it's methods. It seems to me that serializing is either:

      1) Busted
      2) Nearly useless
      or
      3) I'm missing something important

      I'm hoping for the last.