How to change a variable by "set value"

Gunnar shared this question 18 days ago

Hi there. By today I like to do an actually simple task, where I didn't succeed. I created a variable, which is shown in a textfield on my prototype. The variable has as a default value a number. On my prototype is a button, which should change the number by a formula. Let's say the default value of the number is 10 (set in the default field of the variable property window) and the button should add 15, the textfield in the prototype should show 25.

For the "On tap" event of the button I add the event "Set value" and added the following formula: ["variable_name" + "15"] – see the attached pic. Unluckily after simulating the prototype the value of the variable remains 10 – the "Set value" has no effect.


Has anybody an idea, how the formula can work?

To fake it by just changing the value to 25 is not an option – there will be later several buttons in the prototype which add or deduct values from the variable.

Comments (1)


Okay – found out. Here is the solution: you need to create an event for the textfield triggered by "On variable change" – so this causes an update to the textfield after pressing the button.

Hope it might also helps others here.