Text Blinking?!

Fox

Active Member
Licensed User
Longtime User
Is it possible a text can blink (flash) with random colors? If yes how?!
 
Last edited:

kickaha

Well-Known Member
Licensed User
Longtime User
Anything (almost) is possible, however there is not a simple solution to this.

You need to look at setting up a timer that changes the color of the text at a regular interval.

If you put some code together we will help debug (or just admire it when you get it right first time).
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
If you want the entire text to go from one color to another, it's pretty simple. You just overlay two labels which are configured the same (same text, size, etc.) but with two different colors, then set a timer to make the one on top visible and not visible with whatever frequency you want it to "flash". You can also use the time code to randomize the colors. Or as kickaha said, the timer can rewrite the text in the label different colors. I was thinking along the lines of two labels because I was just setting up two labels to create a shadow effect, overlaying labels with the bottom label (with the black or gray "shadow" text) 1-3 pixels to the right and down.
 
Last edited:
Upvote 0

ssg

Well-Known Member
Licensed User
Longtime User
using the animation library

another dirty little trick / suggestion would to use the animation library.. here is the sample... do remember to select your animation library...

B4X:
Sub Globals
   Dim l As Label
   Dim a As Animation
End Sub

Sub Activity_Create(FirstTime As Boolean)

   l.Initialize("")
   Activity.AddView(l, 20, 20, 200, 50)
   l.Text = "Hello blinking world!"
   setLblColor
   
   a.InitializeAlpha("a", 0, 1)
   a.Duration = 200 'adjust your blinking speed
   a.RepeatCount = 0
   a.Start(l)
   
End Sub

Sub a_AnimationEnd
   setLblColor
   a.Start(l) 'any advice if it is fine to start an animation here??
End Sub

Sub setLblColor
   l.TextColor = Rnd(Colors.Black, Colors.White)   
End Sub

cheers!
 
Upvote 0

Fox

Active Member
Licensed User
Longtime User
another dirty little trick / suggestion would to use the animation library.. here is the sample... do remember to select your animation library...

B4X:
Sub Globals
   Dim l As Label
   Dim a As Animation
End Sub

Sub Activity_Create(FirstTime As Boolean)

   l.Initialize("")
   Activity.AddView(l, 20, 20, 200, 50)
   l.Text = "Hello blinking world!"
   setLblColor
   
   a.InitializeAlpha("a", 0, 1)
   a.Duration = 200 'adjust your blinking speed
   a.RepeatCount = 0
   a.Start(l)
   
End Sub

Sub a_AnimationEnd
   setLblColor
   a.Start(l) 'any advice if it is fine to start an animation here??
End Sub

Sub setLblColor
   l.TextColor = Rnd(Colors.Black, Colors.White)   
End Sub

cheers!

Thanks guys :) this help an beginner alot :) thanks for the snippet...
 
Upvote 0
Top