VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Simply animation by changing Visible property to show and hide images alternately.

by ahamedferrari (2 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 8th October 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Simply animation by changing Visible property to show and hide images alternately.

Rate Simply animation by changing Visible property to show and hide images alternately.




 The Code
Private Sub Timer1_Timer()

If Image1.Visible = True Then
Image1.Visible = False
Image2.Visible = True
ElseIf Image2.Visible = True Then
Image2.Visible = False
Image1.Visible = True
End If

End Sub

 
 

 

 
 


Next example shows a complete cycle of a motion such as the butterfly flapping its wing. Previous examples show only manual animation while this example will display an automatic animation once you start the program or by clicking a command button. Similar to the example under lesson 24.2, you need to insert a group of eight images of a butterfly flapping its wings at different stages. Next, insert a timer into the form and set the interval to 10 or any value you like. Remember to make image1 visible while other images invisible at start-up. Finally, insert a command button, rename its caption  as Animate and key in the following statements by double clicking on this button. Bear in mind that you should enter the statements for hiding and showing the images under the timer1_timer subroutine otherwise the animation would work. Clicking on the animate button make timer start ticking and the event will run after every interval of 10 milliseconds or whatever interval you have set at design time. In future lesson, I will show you how to adjust the interval at runtime by using a slider bar or a scroll bar. When you run the program, you should see the following animation:

 Private Sub Form_Load()
Image1.Visible = True
x = 0
End Sub

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
If Image1.Visible = True Then
Image1.Visible = False
Image2.Visible = True

ElseIf Image2.Visible = True Then
Image2.Visible = False
Image3.Visible = True

 

 
 ElseIf Image3.Visible = True Then
Image3.Visible = False
Image4.Visible = True
ElseIf Image4.Visible = True Then
Image4.Visible = False
Image5.Visible = True
ElseIf Image5.Visible = True Then
Image5.Visible = False
Image6.Visible = True
ElseIf Image6.Visible = True Then
Image6.Visible = False
Image7.Visible = True
ElseIf Image7.Visible = True Then
Image7.Visible = False
Image8.Visible = True
ElseIf Image8.Visible = True Then
Image8.Visible = False
Image1.Visible = True
End If
End Sub 


Download this snippet    Add to My Saved Code

Simply animation by changing Visible property to show and hide images alternately. Comments

No comments have been posted about Simply animation by changing Visible property to show and hide images alternately.. Why not be the first to post a comment about Simply animation by changing Visible property to show and hide images alternately..

Post your comment

Subject:
Message:
0/1000 characters