Flex – What does this ActionScript syntax mean? (Return to the inline syntax)

I am a Java programmer and now need to deal with Flex/ActionScript projects. I got an example of ITreeDataDesriptor using Flex 3 Cookbook, but there is a line of ActionScript code that is difficult to understand. I would be very grateful if anyone could explain this further.

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.

The following return expression (modified from the question)…

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…

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.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5863 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.