Expand my Community achievements bar.

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

Avatar

Level 1
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.





2 Replies

Avatar

Level 2
Any chance you can narrow this down to something that is
clearer and more consice? If you can provide just the simplest
example (include the mxml and as files) that would be great.

Avatar

Level 1
Wish I could isolate this problem, in a simpler one.



As I said when I am creating a public class similar to
Product Class in the same flexstore package, I am getting this
error for creation of object of this non-dynamic class Server. How
ever when I qualified this Server class with "dynamic" key word,
the error was gone and App worked quite well.



But my question is, why for Product class (without dynamic
key word) in the same package, it is allowing the object for it to
be created where as not for Server class (written by me) in a
similar fahsion.



Any answers to this would be welcome.



Flexstore is a publicaly availabe application with all its
sources.