Canvas Apps Controls Expressions

X – X property – How to auto scroll text!

Multiple advertisement banners at Times Square, NYC
Multiple advertisement banners at Times Square, NYC

Introduction

Just like with the need for automatic vertical scrolling for my teleprompter app, auto horizontal scrolling can be pretty useful as well. For example, if you want to show a banner or a notification or a series of messages in a horizontally scrolling text in your app.

Auto scrolling with X property

Just like with the vertical scrolling, the idea is simple. To change the X property of a label using a timer. So, to achieve this, set the X property of a label to:

- Self.Width + (Parent.Width + Self.Width) * Timer.Value / Timer.Duration

As the timer starts running, the Timer.Value / Timer.Duration changes from 0 to 1. The X position of the label changes from outside of the screen on the left side to outside the screen on the right side. To control the speed, change the duration. Higher the duration, the slower the transition.

Here is a quick demo:

Auto horizontal scrolling
Auto horizontal scrolling

To learn more about the timer control, click here.

Stay tuned for the remaining 2 tips!

Recent articles

Leave a Reply