Slider Position on Startup

If I set a Slider element up like this:

And then define a global variable thus:

And then set a label text to that global variable thus:

Why does it return 30?

I know in the documentation that 30 is the system default thumb position, but should not the settings I create in the Designer void those and use my settings nominated in the first image above?

Works as expected here....

Try refreshing browser, AI2,companion...

This is what I am getting,

image

Do It over, slider variable timescaleSlider only, and let us know what is there,

Will try. I generally always compile code to apk to test.

The slider thumb position is graphically placed at the right spot, equating to where 5 would be, just the value being returned is 30.

If I start the app and click and drag the slider one position left or right, the value returns 4 or 6.

Could be a timing issue, you may need to introduce a clock on initialise (250ms) to allow time for the slider to get its values

Probably unrelated, but I have been getting a lot of lag and even timeout errors when I switch between Designer and Blocks windows over the last few days.

With Companion connected:
image

However, still returns 30 in my debug label.

It could be because of

I do have an initClock already for some problematic Canvas and imageSprite stuff. That is set to 1ms.

I inserted:

and also tried the initClock at 250ms, but it made no difference. Tried in both Companion and compiling APK.

However, If I use:

in the initClock (set to 1ms), it resolved the issue.

It seems like the:

Is being compiled prior to the base settings for the slider being adjusted to my values. The compiler then sorts everything else out but mistakenly leaves the global variable thumbTimeScale at the original value of 30.

It might be obvious, but for clarity, I have this block that creates the update:

App Inventor is basically a complex programming language simplified in the form of blocks. In almost every language, Global variables are initialised before everything else.
In order to fix this, instead setting the value during initialisation, set it with the "Set Variable" block.

Yes, I believe this is what is going on.

In my initClock.timer routine, I now include:

and it resolves the issue.

You will be lucky if you get 1ms, minimum 10ms, most likely 50ms. I usually do not set below 100ms.

Has been working well for my Canvas/imageSprite issue and now the slider thumb position issue.

I'll keep it in mind if I start seeing a return to unexpected behaviour on these elements.

Perhaps it's not so much about what the timer delay is set at, but rather when within the nitty-gritty of the compilation that the timer is first initiated. It may be one of the last things to kick-off in the process of setting global variables, overriding defaults, setting up the screens etc, so the actual timer interval may not matter so much for some elements.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.