JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old May 3rd, 2004, 11:45 PM
blaa_blaa_69 blaa_blaa_69 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 blaa_blaa_69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Need Timeout help please

hey guys i need some help with this. I am trying to make each image fade in one after another. Eg the left image fades in, then the next the next.
I have written this simple script to do it, and if i check the activity log it has loaded the images, but by the time the page is loaded it is on the last image. So I cant get the timeout to work??

<script LANGUAGE="JavaScript">
<!--
if (document.images != null) {
pic0 = new Image();pic0.src = "two0.gif";
pic1 = new Image();pic1.src = "two1.gif";
pic2 = new Image();pic2.src = "two2.gif";
pic3 = new Image();pic3.src = "two3.gif";
pic4 = new Image();pic4.src = "two4.gif";
pic5 = new Image();pic5.src = "two0.gif";
pic6 = new Image();pic6.src = "two1.gif";
pic7 = new Image();pic7.src = "two2.gif";
pic8 = new Image();pic8.src = "two3.gif";
pic9 = new Image();pic9.src = "two4.gif";
pic10 = new Image();pic10.src = "two0.gif";
pic11 = new Image();pic11.src = "two1.gif";
pic12 = new Image();pic12.src = "two2.gif";
pic13 = new Image();pic13.src = "two3.gif";
pic14 = new Image();pic14.src = "two4.gif";
}

function fadeIn() {
for(i=0; i<15; i++) {
if (i < 5) {
document.images['pic1'].src = eval('pic' + i + ".src");
}
if (i < 10) {
document.images['pic2'].src = eval('pic' + i + ".src");
}
if (i < 15) {
document.images['pic3'].src = eval('pic' + i + ".src");
}
}
setTimeout('fadeIn()',50);
}

//-->
</SCRIPT>



</HEAD>

<BODY onload="fadeIn()">


<A HREF="#"><IMG SRC="two0.gif" NAME="pic1" BORDER=0 WIDTH=21 HEIGHT=21></A>
<A HREF="#"><IMG SRC="two0.gif" NAME="pic2" BORDER=0 WIDTH=21 HEIGHT=21></A>
<A HREF="#"><IMG SRC="two0.gif" NAME="pic3" BORDER=0 WIDTH=21 HEIGHT=21></A>
<A HREF="#"><IMG SRC="two0.gif" NAME="pic4" BORDER=0 WIDTH=21 HEIGHT=21></A>
<A HREF="#"><IMG SRC="two0.gif" NAME="pic5" BORDER=0 WIDTH=21 HEIGHT=21></A>

Reply With Quote
  #2  
Old August 8th, 2005, 02:02 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 536 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 1 h 11 m
Reputation Power: 3
timeout

Are you sure the conditional testing is correct?
if i = 1 it is < 5 and it is also < 10 and it is also < 15.
Anyway you have
setTimeout('fadeIn()',50);
50 is 50 microseconds not 50 seconds. In other words 1/20th of a second. Since the for loop makes 15 passes it reaches the last image in 3/4 of a second. If you want 50 seconds use 5000 instead.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Need Timeout help please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway