I am a Java programmer and need to work on a Flex/ActionScript project right now. I got an example of using ITreeDataDesriptor from Flex 3 Cookbook, but there is one line of actionscript code that’s hard for me to understand. I appreciate if someone could explain this a little further.
public function getData(node:Object, model:Object=null):Object { if (node is Office) { return {children:{label:node.name, label:node.address}}; } }
The part that I didn’t understand was ‘{children:{label:node.name, label:node.address}}’. Office is simply a value object that contains two String properties: name and address.
The following return expression (modified from the question) …
… is functionally equivalent to this code …
The anonymous object returned in the question code complicates matters because it defines a property twice. In that case, the first declaration is used, and the subsequent one(s) are ignored. No compile-time or runtime error is thrown.