question

Arun Kr avatar image
5 Likes"
Arun Kr asked Matt Long commented

Difference between Object and treenode in FlexScript Dot Syntax

Hi Support,

I am getting an error for the script given below. (The aim is to change the xlocation of the source object by 2)

Error Message:

exception: FlexScript exception: Label property location retrieved on /Source1. Label does not exist. at /0 c: /testlink_instance i: /testlink_associated

  1. treenode src = model().find("Source1");
  2. src.location.x += 2;
  3.  

Instead of the script lines

  1. treenode src = model().find("Source1");
  2. Object srcAsObject = src;
  3. src.as(Object).location.x += 2;

Conceptually both are same right ? Or location can be used only with the object class?

Please correct me, if I had made a wrong question.

But the script given below is working.

  1. treenode src = model().find("Source1");
  2. Object srcAsObject = src;
  3. srcAsObject.location.x += 2;

Regards,

Arun KR

FlexSim 17.0.0
flexscriptobjecttreenodedot syntax
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Kaspar Chabot avatar image
5 Likes"
Kaspar Chabot answered Matt Long commented

Dear Arun KR,

I might be totally wrong about this, but for the moment this is how I think it works...

I think the reason this isn't working is the same as pointed out in the answers to this post.

Basically, you cannot use some of the dot syntax specific to certain classes on treenodes, if I'm not mistaken.

Probably you can use .location on the Object class, but e.g. not on the Table class, both of which can be referenced by a treenode

Since the .location syntax cannot be used for everything that can be referenced to as a treenode, src.location will be interpreted as being a label called 'location' attached to the treenode src.

Kind regards,

Kaspar

· 11
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.