Simple color change

<< Click to Display Table of Contents >>

Navigation:  Examples > Change the color of an object >

Simple color change

Previous pageReturn to chapter overviewNext page

Let's assume that in our project there is a certain object that has two states: on, off. The object's state data is passed to the tag. We want the object's fill color to differ on the screen depending on the state of the object.

1.  Let's create a tag named State, which is responsible for data about object's state (set the data type of the tag to Boolean and the default value to false):

 

tagstate

 

2. Now let's create a Rectangle object (choose the object that suits your specific case) and bind it to the State tag.

 

rectangleex

 

3. Let's set the "Fill Color" property. For example, we want to have red fill color if the object is turned off, and blue fill color if the object is turned on:

 

statefillcolor

 

4. Let's run the simulation to check the settings:

 

 

commonfillcolor

 

You can download this project here.