Animate text

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Animate text

Post by Tester2 » Fri Jun 21, 2013 9:00 pm

Fellow Coders,

If I want to "scroll" some text right to left across a field - picture like a "...Live Broadcast..." message going across a screen - is this doable?

If so, please share how to code this or help point me in the right direction.

Thanks so much!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Animate text

Post by Simon » Sat Jun 22, 2013 4:13 am

Sure it's doable! :)
LiveCode is super cool

Code: Select all

on mouseUp
   put "This is a scrolling newsbanner" into tText
   put tText into fld 1
   set the left of fld 1 to the right of this cd
   set width of fld 1 to the formattedWidth of fld 1
   goScroll
end mouseUp

on goScroll
   set the left of fld 1 to (the left of fld 1 - 1)
   if the right of fld 1 < the left of this cd then
      set the left of fld 1 to the right of this cd
   end if
   send goScroll to me in 10 milliseconds
end goScroll
I'm sure that could be better...

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Animate text

Post by jacque » Sat Jun 22, 2013 6:11 pm

Here's a way to do it that moves the text but doesn't move the field. Put enough spaces before the actual text so that it's out of bounds when the scrolling first starts.

Code: Select all

on mouseUp
  put "                                    This is a scrolling newsbanner." into tText -- add spaces at front for wider fields
  put tText into fld 1
  goScroll
end mouseUp

on goScroll
  put char 1 of fld 1 after fld 1
  delete char 1 of fld 1
  if the shiftkey is not down then
    send goScroll to me in 50 milliseconds
  end if
end goScroll
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply