Scrolling Text

Monday, September 4, 2006 by Hilbillyoct19 | Discussion: DesktopX

I would like to make an object that is text but I don't want it to just be static.  I would like it to scroll from right to left and then start over like you would see in a news flash at the bottom of the screen.  But not take up the hole screen width.  Or as a media player would display the song man if it is longer then a spesified length. I don't really care if it is scripted or what I just have no idea how to make it work right. 
rabidrobot
Reply #1 Monday, September 4, 2006 4:33 PM
I think scripting will be required. I have used a technique in my last two widgets that I think works pretty well, but it is not the only solution. Also, it reverses the scroll direction when it reaches an end of the scrolling text (rather than repeating the text and scrolling in the same direction).



' InfoCrawl settings
' Initial crawl direction
Dim direction
direction = "Left"
' How many pixels to crawl each iteration
Const CRAWL_STEP = 1
' Milliseconds between iterations
Const CRAWL_TIME = 100
' Milliseconds pause between direction change
Const CRAWL_PAUSE = 750

Dim dxCrawlText, dxCrawlCont
Set dxCrawlText = DesktopX.Object("Crawl_Text")
Set dxCrawlCont = DesktopX.Object("Crawl_Container")

' Called when the script is executed
Sub Object_OnScriptEnter
' The text string can be (re)set at any time.
dxCrawlText.Text = "A long string of text that will scroll"
' I like to reset the crawl position too. May not be strictly neccessary
dxCrawlText.Left = 0
Object.SetTimer 444, CRAWL_TIME
End Sub


' Move text Timer
Sub Object_OnTimer444
Select Case direction
Case "Left"
' Has end of text become fully visible?
If dxCrawlText.Right <= dxCrawlCont.Width Then
' Then Pause and reverse
Object.KillTimer 444
direction = "Right"
Object.SetTimer 777, CRAWL_PAUSE
' Needs to be moved some more
Else
dxCrawlText.Left = dxCrawlText.Left - CRAWL_STEP
End If

Case "Right"
' Has beginning of text become fully visible?
If dxCrawlText.Left >= 0 Then
' Then Pause and reverse
Object.KillTimer 444
direction = "Left"
Object.SetTimer 777, CRAWL_PAUSE
' Needs to be moved some more
Else
dxCrawlText.Left = dxCrawlText.Left + CRAWL_STEP
End If

End Select

End Sub

' Crawl text pause between directions
Sub Object_OnTimer777
Object.KillTimer 777
Object.SetTimer 444, CRAWL_TIME
End Sub

Sub Object_OnScriptExit
Object.KillTimer 444
Object.KillTimer 777
Set dxCrawlText = Nothing
Set dxCrawlCont = Nothing
End Sub




The general idea is to set the text object as a contained child of another (non-text) object, then move it a certain direction until conditions are met, and reverse.


Because the text is a contained child of another object, you can set the viewable area by setting the size of the parent object (which can have a transparent image for its graphics if you wish). As the text extends outside those boundries it will become invisible.

Scrolling continously in a single direction would use a similar approach of using a timer to move the text, checking a condition at each step (Has the text been moved completely outside the parent?). But I think you'll need a second, identical text object, so that as one scrolls off it can leap-frog the other and be ready to scroll on again.

Depending on the situation, you may also want to check and include behavior (such as stopping the timers) if the text string is so short it fits entirely within the viewable area.
Hilbillyoct19
Reply #2 Tuesday, September 5, 2006 10:18 AM
Thanks for the kick in the head. I forgot completely about the child proporties. I now know how to get the results I am looking for. I will just change the script a little so insted of a direction change it will start over again. And will take your advice and if it will display the whole text then not to scroll.
WickedDesktop
Reply #3 Tuesday, November 7, 2006 6:27 PM
hey i tried that and i cant get it to work...
i wanted a script that would scrool the inside a spesified length
how can i do that???
i found no artis+song name on the scripts and how to do that

thanks!

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01