One second blinker in an expression

I use this expression in the foreground and background bindings for components when I want them to alternate colors, or flash, if you will, every second to indicate that something is happening. For instance, if I have a two state toggle button named btnScanning on my root container, and I have another component that I want to flash when btnScanning’s state is high, I would bind the component’s foreground color to this expression…

if ({Root Container.btnScanning.state}, if ((dateExtract(now(), 'second') & 1) , 'black', 'white')

For the background color, you just reverse the black and white lines so they will contrast with the foreground color. Simple and sweet. You don’t need a timer elsewhere to provide your toggling effect. The only problem is that it only toggles at a one second rate. If you need faster or slower, you’ll need to use a timer or something else.

I’ve used a timer script to toggle a client tag. Then the rate becomes infinitely (well, to within millisecs) adjustable and universal across the project.

Also, remember that most components support “styles” (right click->Style Customizer) which makes things like this fairly easy as well. In this case, “State” would be your driving property, and then you would configure foreground and background to blink based on it.

Regards,