A Sweet Feeling of Accomplishment

:::: ^__^ :::::

In process of making a "minimalist" theme.. had the idea to put the currently playing track on screen.. but some titles were too long.. So I decided to attempt something I've never done before! A scrolling display! How was it done? Read on...

1. Make a base image i.e.
2. Make a 2nd image i.e.
3. Make a text object and assign it the DXPlayer ability - Clip Name

4. Parent the 2nd image to the base image
5. Parent the text object to the 2nd image
6. Get exact width of 2nd image (in this case it's 238 pixels)
7. Insert the following code into your text object:

'Called when the script is executed
Sub Object_OnScriptEnter
Object.SetTimer 1, 1
Object.Left = 2 'Aligns the text object 2pixels in from parent image
End Sub

Sub Object_OnTimer1
If Object.Left + Object.Width <= 236 Then ' Checks when the end of text is lined up with right edge of parent image - 2
Object.SetTimer 4, 2500 ' Pause timer
Object.KillTimer 1
Else
Object.Left = Object.Left - 1 ' if still not at right edge - carry on moving left
End If
End Sub

Sub Object_OnTimer3
Object.SetTimer 1, 1
Object.KillTimer 3
End Sub

Sub Object_OnTimer4
Object.SetTimer 2, 1
Object.KillTimer 4
End Sub

Sub Object_OnTimer2
If Object.Left => 2 Then ' Checks the text is back at starting position, 2 pixels in from left edge of parent image
Object.SetTimer 3, 2500
Object.KillTimer 2
Else
Object.Left = Object.Left + 1
End If
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit
Object.KillTimer 1
End Sub
11,494 views 14 replies
Reply #1 Top
Thought about posting to http://scratchpad.wikia.com/wiki/DesktopX ?
Reply #2 Top
Thought about posting to http://scratchpad.wikia.com/wiki/DesktopX ?


I second that! It would be a great contribution to the wiki.
Reply #4 Top
Nice
Reply #5 Top
Ditto
Reply #6 Top
Oh my God! I've got a "Nice" from RomanDA! *Is honoured*

(not being sarcastic, you are regarded as a Script GOD!)
Reply #7 Top
Oh my God! I've got a "Nice" from RomanDA! *Is honoured*

(not being sarcastic, you are regarded as a Script GOD!)


.... waiting on some comment from Zu now..
Reply #8 Top
I wish I had a eighth of the talent David has in graphic design or scripting. There are better and worse DX coders out there who give to the community, but David makes a real effort to reach out to the noobs.

However, that being said, he'll probably steal your code in a heartbeat if it's better than his and he can find a way to use it.

For the record, and not to dismiss the tutorials that David has written, most of the really good DX builders here comment their code very well and there's a lot you can learn from reading what they've done.
Reply #9 Top
It seems I can help you... Please look below:

'Note: The scrolling text must be longer than scroll area for this example!

Dim onscroll,sd,xb,xe,tp,xpath

Sub Object_OnScriptEnter
desktopx.object("scrolltext").text = "ENTER SOME LONG TEXT HERE...."
onscroll = False
sd = 20 '<== a small delay between the steps of scrolling
tp = 500 '<== delay between the cycles of scrolling
xb = 0 '<== "zero" position
xe = desktopx.object("scrollback").width '<== "end" position
xpath = desktopx.object("scrolltext").width - desktopx.object("scrollback").width
desktopx.object("scrolltext").left = xb
OnScrolling_Ex
End Sub

Sub OnScrolling_Ex()
object.SetTimer 1, tp
End Sub

Sub object_OnTimer1
object.KillTimer 1
onscroll = True
object.SetTimer 2, 1 '<== this timer is need to "wake" a sleeping object
End Sub

Sub object_OnTimer2 '<== SCROLLING CYCLE (the text object will move onward/backward)
object.KillTimer 2
If onscroll = True Then
If desktopx.object("scrolltext").left = xb Then
For i = 0 To xpath
If desktopx.object("scrolltext").right > xe - 1 Then
desktopx.object("scrolltext").left = desktopx.object("scrolltext").left - 1
object.sleep sd
End If
Next
desktopx.object("scrolltext").right = xe
onscroll = False
OnScrolling_Ex
Else
If desktopx.object("scrolltext").right = xe Then
For j = 0 To xpath
If desktopx.object("scrolltext").left < xb - 1 Then
desktopx.object("scrolltext").right = desktopx.object("scrolltext").right + 1
object.sleep sd
End If
Next
desktopx.object("scrolltext").left = xb
onscroll = False
OnScrolling_Ex
End If
End If
End If
End Sub

Before use this code you need only two things:
1. Create two objects: the "srollarea" and "scrolltext" which must be joined to the "scrollarea" (Parent/Qwner)
2. Add this code to the "srollarea" object and run.

Good Luck with DesktopX 
Reply #11 Top
Well the specific numbers given for the left values (i.e. Object.Left = 2 & If Object.Left + Object.Width <= 236) are relevant to the width of the parent image - the image is 238 pixels in width - 2 for a border. You might need to adjust these values depending on the parent image you use.
Reply #12 Top
Well Cyberium's script could be repaired so instead of manually inserting numbers it would check what parent object width is ( pow = DesktopX.object("parent").width). Put that in Object_OnScriptEnter sub OR write "DesktopX.object("parent").width" instead of a number and it should make no problems
Otherwise it's a cool script

my modest opinion.
Reply #14 Top
One of those threads I'm sure I'll want to find someday when I have time.