Making Scrolling Text in NSTextField Label

Hi Community,
I’m working on a program, and I need to create an NSTextField Label that will have text scrolling across it (much like the texts on this page). Currently I’m calling on a function and then just appending the characters one by one to the NSTextView backwards with a .04 second delay (I use Shane’s doEventFetch function to update the NSTextField). However, this is buggy as some characters will append faster than others. Is there any easier way to go about doing this? Here’s the code I have so far (the Label’s value is bound to the variable theDow):

on test_(sender)
		set theString to "THIS IS A TEST            "
		set backwardsString to {}
		set theChars to characters of theString
		set theNum to number of items of theString
		repeat theNum times
			set end of backwardsString to item theNum of theChars
			set theNum to theNum - 1
		end repeat
		set backwardsString to backwardsString as string
		set my theDow to ""
		set theNum to 0
		repeat
			if continueDow then
				repeat with i in characters of backwardsString
					set my theDow to i & theDow
					do shell script "sleep .04"
					doEventFetch()
				end repeat
				if theNum < 5 then
					set theNum to theNum + 1
				else
					set theDow to characters 1 through 78 of theDow
				end if
			else
				exit repeat
			end if
		end repeat
	end test_

Your best bet is probably an animation. The easiest way would be to resize your field, So you might start of with a marrow field set with Text Direction Right to Left, and then use something like:

		tell current application's NSAnimationContext to beginGrouping()
		tell current application's NSAnimationContext's currentContext() to setDuration_(2)
		textField's animator()'s setFrameSize_({width:400, height:17})
		tell current application's NSAnimationContext to endGrouping()

The grouping code is for setting the duration; the main thin is that instead of setting the size of the text field, you set the size of the text field’s animator.

Oh wow, I was unaware that you could do Animations in ASOC, that’s pretty amazing. It’ll be a little bit painful making the text seem as if it’s constantly looping across the screen, but the animation is definitely going to look a million times better than just appending text. Thank you so much!

By the way, just for future projects, what are the other animator functions you can use with an NSTextField other than “setFrameSize:”?

I suspect getting a repeating animation will be a bit more couple than using animator – you will possibly have to use NSViewAnimation.

“properties of the types float, double, NSPoint, NSSize, or NSRect are animatable using the proxy returned the NSAnimatablePropertyContainer method animator”

I’ve decided to stick with constantly editing the Label. I decided to switch to using an NSLoop and change the font, both of which had a huge impact and are making it run a lot more smoothly. Thank you so much for your help!

NSLoop?