phate Posted January 3, 2006 Share Posted January 3, 2006 I want to create an animation and have just read a bit on javascript and came up with this. I don't have the jpg files yet so haven't been able to test it. Does it look like it would work? I want each jpg to play for 1 second then go onto the next one and when the last jpg is shown I want it to start again by showing the first jpg. I'll have lots of jpgs but have only shown it with 3 here.I know I don't really need the array but i've put it in anyway.<head><script type="text/javascript">function functionname()silk = 1pic = new Array ("name1.jpg","name2.jpg","name3.jpg")a = setTimeout ("document.sw.src = "pic[0]"",1000)b = setTimeout ("document.sw.src = "pic[1]"",1000)c = setTimeout ("document.sw.src = "pic[2]"",1000)while (silk=1){abc}</script></head><body><img src="name1.jpg" name="sw" onload=functionname()/></body> Link to comment Share on other sites More sharing options...
phate Posted January 3, 2006 Author Share Posted January 3, 2006 I think I can't use the Onload event in an image tag. If that's the case could I just put this in the body?<script type="text/javascript">silk = 1pic = new Array ("name1.jpg","name2.jpg","name3.jpg")a = setTimeout ("document.sw.src = "pic[0]"",1000)b = setTimeout ("document.sw.src = "pic[1]"",1000)c = setTimeout ("document.sw.src = "pic[2]"",1000)while (silk=1){abc}</script> Link to comment Share on other sites More sharing options...
aspnetguy Posted January 3, 2006 Share Posted January 3, 2006 I think you are looking for something like thishttp://javascript.internet.com/miscellaneo...ge-rotator.html Link to comment Share on other sites More sharing options...
phate Posted January 4, 2006 Author Share Posted January 4, 2006 Thanks for the link. I'll try that first as it's more likely to work than what I did . Will the code I did not work? I assume not because the links code looks alot more complex. Link to comment Share on other sites More sharing options...
Chocolate570 Posted January 5, 2006 Share Posted January 5, 2006 No, I don't think it will work, because i don't think you can call a timer statement. :S Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now