question

Gui Vaccaro avatar image
0 Likes"
Gui Vaccaro asked Gui Vaccaro commented

Bug (?) colorFromPalette when value is flexscript label

Hello,

let's say I have

  1. MyObject.labels["myLabel"]

as a flexscript label.

If I call

  1. Color.fromPalette(MyObject.labels["myLabel"], myPalette);

the command creates a new entry

1737561327861.png

If I call

  1. Color.fromPalette(MyObject.labels["myLabel"].value, myPalette);

the command also creates a new entry

1737561479327.png

None of them evaluates the node flexscript.

Is there a correct syntax?

Thank you.

FlexSim 25.0.2
color paletteflexscript labelfrompalette
1737561327861.png (23.0 KiB)
1737561479327.png (25.3 KiB)
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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Gui Vaccaro commented

This is not a bug; you just need to use different syntax.


The treenode.labels property accesses labels as nodes.

  1. MyObject.labels["myLabel"] // returns the label node


The treenode.value property gets the value of the node. Even if the node is a FlexScript node the value will be the string data on the node.

  1. MyObject.labels["myLabel"].value // returns the string data on the node


The treenode.evaluate() method returns the same value as treenode.value but will also evaluate nodes toggled as code. You can also pass parameters to the code node.

  1. MyObject.labels["myLabel"].evaluate() // executes the code node and returns the result


treenode.labelProperties (or dynamic label properties) gives you shorter syntax for the above evaluate call (although you can't pass parameters or have spaces in the label name)

  1. MyObject.myLabel // executes the code node and returns the result
· 1
5 |100000

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