question

Alan Zhang avatar image
0 Likes"
Alan Zhang asked Matthew Gillespie commented

Assign color to label in Process Flow

I have a simple question. I am trying to store a color value in a token label, then assign object's color using that label value later.

Basically, I added a label named myclolor and assigned the value Color.red in an Assign Label activity. Then later in a Change Visual activity, I used the Set Object Color option, and assigned token.color to the object. In the code window, it has the following code:

Object object = /** \nObject: *//***tag:object*//**/token.item/**/; object.color = /** \nColor: *//***tag:color*/ /**/token.mycolor/**/;

Then I got a FlexScript compling error:

"Could not resolve correct operator for = operation, left side type is Color&, right side type is Variant."

Is there a way to convert Variant to Color& as required here?

Thanks,

FlexSim 17.0.0
process flowobject color
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
1 Like"
Matthew Gillespie answered Matthew Gillespie commented

Currently there isn't a way to directly convert a Variant to a Color. You need to construct a new Color object using the elements stored in an Array.

obj.color = Color(token.myColor[1], token.myColor[2], token.myColor[3]);
· 3
5 |100000

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

Alan Zhang avatar image Alan Zhang commented ·

Thank you, Matthew. Your code works.

A follow-up question. Creating object dynamically in FlexScript is a new language feature. Is anywhere in help or other doucments I can learn more about this?

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Alan Zhang commented ·

All our documentation for new dot syntax FlexScript can be found in the User Manual in FlexSim Coding > FlexScript Class Reference. Clicking on the object type you're interested in will bring up the documentation about that object's methods, properties, and constructors.

0 Likes 0 ·
David Seo avatar image David Seo commented ·

I also want to get the manual or document about this new dot syntax features to support flexsim commands.

0 Likes 0 ·