KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Creating a moving object in the form
PRODUCT: 4D | VERSION: 6.7 | PLATFORM: Mac & Win
Published On: May 26, 2000

Suppose you want to create an object that can move from one position to another inside a form, you can easily do that with the command called "MOVE OBJECT". This command allows you to move an object(s) in the current form, by defining horizontal and vertical parameters. You can use this command to create a moving text, button, picture and etc.



In the example database, the text moves from left to right and back.
Here is the code used for the example:

Here is a text copy of the code shown above for you to cut-and-paste into you own project:

If (Form event=On Load )
 SET TIMER(1)
 direction:="forward"
End if
If (Form event=On Timer )
 Case of
  : (direction="forward")
  If (bound<100)
   MOVE OBJECT(*;"Text1";1;0)
   bound:=bound+1
  Else
   direction:="backward"
  End if
  : (direction="backward")
  If (bound>0)
   MOVE OBJECT(*;"Text1";-1;0)
   bound:=bound-1
  Else
   direction:="forward"
  End if
 End case
End if