Change background color of dynamic component with a variable

Hi.
I have some dynamic component and I want to change the background color with a variable. If I set the variable with a fixed color, like this capture:
modo_bien
there is no problem creating the component.
But if the variable is started like this:
modo_mal
there is an error creating the component. I have tried everything (text, interger, split color…) for the variable that controls this colors but everything results in error. The only way is to put a fixed color, but then it can’t be changed with a variable (or I don’t know how to do it).
I have normal components in the projects and there is no problem changing their background colors with variables, but the same variables can’t be used with the dynamic components.
I hope I’ve explained myself.
Thanks in advance!

I don’t know if that’s a bug or not. May be if you add the 4th channel (alpha) and put 255 in it?

1 Like

Also, show your dynamic components block, where you set the color.

1 Like

also what’s the error message ?

1 Like

The color is settled with this block:


that is called from a “click button” event that generate the elements. It works perfect if the variable “ArrangementsBackgroundColor” is defined like this:
set ABC ok
But if defined like this:
set ABC con make color falla
Gives this error:

I use another variable to set the color of normal componets:
get global color oscuro
without any problem.
If “global ArragementsBackgroundColor” is defined with “global ColorOscuro” by a procedure, it fails with the message showed before.
If "global ArrangementsBackgroundColor is defined like this:
set ABC con numero falla
it fails again, same message (or quite similar).
If the interger is changed for a text with the same numbers, it fails too.
If the text is the code of the color in HEX format, it fails too.

This:


fails too.

Summarizing, the only way to define the back ground color of a dynamic element is with a color block, I can’t do it with another kind of variables that works perfectly with normal component.

How are using this SetPropertiesHArrangememt procedure? I think you are using it wrongly. If I set the properties of the components with dictionaries, I do it something likw this :point_down:

This works for me.
May be this can help you also :slightly_smiling_face:

2 Likes

I haven’t tried this with dynamic component but, As you have managed to create a color combination in the shown image, instead of variable, make it as procedure and call it where ever you need it… You need to replace variable with procedure and you got it solved . Hope this helps!

1 Like

The “setPropertiesHArrangement” is called from a button that create the horizontal arrangements and other elements inside it.
The “click button” event first call the “set properties” procedure and after that the “create arrangement” procedure. It works nice if the color is set with a color block.
I think the problem is to call a procedure that sets the value in a dictionary, changing the original type of variable (it appears to be an interger, but using intergers neither works).

Finally I solved the problem by setting the background color as an independet property, outside the set properties procedure, and this way its possible to conect the same color variable that works with normal elements. It worked fine that way.
Thanks for all your replies, have been very helpful!!