public function getData(node:Object, model:Object=null):Object
{
if (node is Office) {
return {children:{label:node.name, label:node.address}};
}
}
The part I don’t understand is “{children:{label:node.name,label:node.address}}”. Office is just a value object containing two String properties: name and address.
return {children:{label:node.name, body:node.address}}
…is functionally equivalent to this code…
var obj:Object = new Object();
obj.children = new Object();
obj.children.label = node.name;
obj.children.body = node.address ;
return obj;
The anonymous object returned in the problem code complicates the problem because it defines the attribute twice. In this case, use the first declaration and ignore the subsequent Statement. No compile-time or runtime errors are thrown.
I am a Java programmer and now need to deal with Flex/ActionScript projects. I got one using Flex 3 Cookbook’s ITreeDataDesriptor example, but there is a line of action script code that is difficult to understand. If anyone can explain this further, I would be grateful.
public function getData( node:Object, model:Object=null):Object
{
if (node is Office) {
return {children:{label:node.name, label:node.address}} ;
}
}
The part I don’t understand is “{children:{label:node.name,label:node.address}}”. Office is just one containing two The value object of the String attribute: name and address.
The following return expression (modified from the question)……
< /p>
return {children:{label:node.name, body:node.address}}
…is functionally equivalent to this code…
p>
var obj:Object = new Object();
obj.children = new Object();
obj.children.label = node.name;
obj.children. body = node.address;
return obj;
The anonymous object returned in the problem code complicates the problem because it defines the attribute twice. In this case, use the first Statement, and ignore subsequent statements. No compile-time or runtime errors are thrown.