2 Replies Latest reply on Nov 28, 2006 10:54 PM by ravisingh_id

    Error #1056: Cannot create property serverID on samples.flexstore.Server

    ravisingh_id
      I am just tweaking with the sample application flexstore found at the start page of Flex2

      I have created a similar dynamic Action Script class in server.as on similar lines of product.as, in order to read and store as similar XML based data as in catalog.xml

      Here is the code of the class

      package samples.flexstore
      {

      [Bindable]
      public class Server
      {

      public var serverId:int;
      public var name:String;
      public var port:String;
      // public var qty:int;

      public function Server()
      {

      }

      public function fillServer(obj:Object):void
      {
      for (var i:String in obj)
      {
      this = obj;
      }
      }

      [Bindable(event="propertyChange")]
      public function get featureString():String
      {
      var str:String = "";
      return str;
      }
      }

      }


      And here is the corresponding hard-coded XML data

      <serverList>
      <server serverID="1">
      <name>svr1</name>
      <port>8081</port>
      </server>

      <server serverID="2">
      <name>svr2</name>
      <port>8081</port>
      </server>

      <server serverID="3">
      <name>svr3</name>
      <port>8081</port>
      </server>

      <server serverID="4">
      <name>svr4</name>
      <port>8081</port>
      </server>

      </serverList>

      when HTTP Service gets the data an event is fired, here is the code for the same

      [Bindable]
      private var serverList:ArrayCollection;

      private function serverServiceResultHandler(event:ResultEvent):void
      {
      //HTTPService returns an ArrayCollection for nested arrays
      var servers:ArrayCollection = event.result.serverList.server;
      var tempServer:ArrayCollection = new ArrayCollection();
      var cursorServer:IViewCursor = servers.createCursor();
      while (!cursorServer.afterLast)
      {
      var server:Server = new Server();
      server.fillServer(cursorServer.current);
      tempServer.addItem(server);
      cursorServer.moveNext();
      }
      serverList = tempServer;
      }


      Now the problem is in call to server.fillServer(cursorServer.current); I get the following Run time error

      ReferenceError: Error #1056: Cannot create property serverID on samples.flexstore.Server.