|
-
Dec 4th, 2000, 07:27 PM
#1
Thread Starter
Member
I would like to animate something(this is not the problem) I want it to animate it after a cmd button is clicked. How do I get the animation code in the timer sub to animate when a cmd button is clicked. Can I put the animation code directly in the cmd button and some how make the timer know that this code is for it?
Help would be much appriciated,
Thanks,
Marc
cram
[email protected]
_ _ _ _ _ _ _ _ _ _ _ _ _ _
Things to Ponder

|Man who stands on toilet,
Is high On pot|
|Baseball Wrong,
Man with four balls cannot walk|
-
Dec 4th, 2000, 07:32 PM
#2
Hyperactive Member
Unless I understood the problem somehow wrong, just set the timers enabled value to false, and in the button code put:
Timer1.Enabled = 1
Then put the animation code to the timer and remember to set the interval.
-JR-
-
Dec 4th, 2000, 07:34 PM
#3
Frenzied Member
Just Enable the Timer 
Code:
Sub Command1_Click()
Timer1.Interval = 1000 'every second
Timer1.Enabled = True 'activate
'now the timer'll start activating the animation.
End Sub
Anyway, you could also loop it, just a matter of preference.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Dec 4th, 2000, 07:37 PM
#4
Hyperactive Member
Actually I told to first (in design) set the timer1.enabled to false so it doesn't start doing the animation stuff right when the prog starts.
-JR-
-
Dec 4th, 2000, 08:06 PM
#5
Thread Starter
Member
But my prob is that I want the animation to start only when a cmd button is clicked this is what the code looks like:
Private Sub cmdSpin_Click()
Timer1.Enabled = 1
If (imgBlur.Left = 4200) And _
(imgBlur.Top > 3120) Then
imgBlur.Left = imgBlur.Left + 0
imgBlur.Top = imgBlur.Top - 50
Else
imgBlur.Left = 2880
imgBlur.Top = 4200
End If
End Sub
Is this right or what is wrong, how can I get the animation to go when the button is clicked
Thanks a bunch,
Marc
cram
[email protected]
_ _ _ _ _ _ _ _ _ _ _ _ _ _
Things to Ponder

|Man who stands on toilet,
Is high On pot|
|Baseball Wrong,
Man with four balls cannot walk|
-
Dec 4th, 2000, 08:25 PM
#6
Maybe this thread will help you a little with your animation?
-
Dec 4th, 2000, 08:47 PM
#7
Thread Starter
Member
Sleep 1
What is the "sleep 1" mean?
cram
[email protected]
_ _ _ _ _ _ _ _ _ _ _ _ _ _
Things to Ponder

|Man who stands on toilet,
Is high On pot|
|Baseball Wrong,
Man with four balls cannot walk|
-
Dec 4th, 2000, 10:08 PM
#8
Hyperactive Member
Timer1.Enabled = 1
If (imgBlur.Left = 4200) And _
(imgBlur.Top > 3120) Then
imgBlur.Left = imgBlur.Left + 0
imgBlur.Top = imgBlur.Top - 50
Else
imgBlur.Left = 2880
imgBlur.Top = 4200
End If
End Sub
in the command button put :
timer1.enabled = true
in the timer event put :
If (imgBlur.Left = 4200) And _
(imgBlur.Top > 3120) Then
imgBlur.Left = imgBlur.Left + 0
imgBlur.Top = imgBlur.Top - 50
Else
imgBlur.Left = 2880
imgBlur.Top = 4200
End If
End Sub
-
Dec 4th, 2000, 10:18 PM
#9
sleep 1 slows the animation down a bit to give it a nice smooth effect, or it will go to fast.
Code:
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
'Adjust to fit your needs
Do Until Image1.Left = 6120
Image1.Left = Image1.Left + 5
Sleep 1
Loop
End Sub
^Just an example, as it says, adjust to fit your needs.
It kind of makes an object move across the form and gives it this cool looking rolling effect. Try it, you might like it .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|