1 Reply Latest reply on Nov 11, 2010 9:44 PM by Flex harUI

    Inexplicable Error #2004 on ByteArray.writeObject()


      I'm trying to send AMF serialized objects around but I am having problems doing this because I get an error with writeObject(). I can write standard AS3 objects just fine, but I cannot write my own classes.


      The odd thing is that this error doesn't happen if I run the SWF inside an HTML page. It only happens when I run it standalone.


      The exact error is this:


      ArgumentError: Error #2004: One of the parameters is invalid.
           at flash.utils::ByteArray/writeObject()


      My code looks like this:


      data = new RemoteObject();
      var ba:ByteArray = new ByteArray();
      ba.writeObject(data); // <-- Error #2004 occurs here


      package com.example
           import flash.utils.*;
           public class RemoteObject implements IExternalizable
                protected var _number:int;
                public function set number(value:int):void {
                     _number = value;
                public function get number():int {
                     return _number;
                public function readExternal(input:IDataInput):void {
                     _number = input.readObject() as int;
                public function writeExternal(output:IDataOutput):void {


      I posted this in the Actionscript forum a while ago but this is actually happening in Flash Builder 4 on a Flex project.