6 Replies Latest reply on Nov 15, 2009 10:00 PM by nmpg\pmorris

    Unexpected error when using appendChild() in SDK 3.4 and above

    nmpg\pmorris

      I'm using an API class to build XML objects within AS3 and passing them as a String (of well-formed XML) to a Web service. This class has worked just fine in Flex 3.0:

       

      public class MyXMLClass

      {

      private var message:XML = <root></root>;

       

      public function MyXMLClass()

      {

      message.appendChild(<arguments></arguments>);

      }

       

       

      public function setArgument(name:String):void

      {

      message.arguments[0].appendChild("<argument name=\"" + name +"\"></argument>");

      }

       

      public function setArgumentValue(name:String,value:String):void

      {

      message.arguments[0].argument.(@name == name).appendChild("<value>" + value + "</value>");

      }

       

      public function getMessage():XML

      {

      return message;

      }

      }

       

      //Take the result of getMessage().toXMLString() and pass that into the Web service as a String.

       

       

      But now that I am running Flash Builder whether I compile with 3.4 or 4.0 SDK I get:

       

      Error #1086: The appendChild method only works on lists containing one item.

       

      The line of code it chokes on is the setArgumentValue function.