Make the leaves fall

I worked on this last year and could not get it working so I thought I would try to get it to work again. It looks correct to me but I must be missing something. All help greatly appreciated.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 
              <html xmlns="http://www.w3.org/1999/xhtml"> 
              <head>
                <title></title>
               <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
               <script type="text/javascript">
                 /* <![CDATA[ */
                 
                  var leaf = New Array(6);
                  var curLeaf = 0;
                   var begin;
		           var imagesLoaded = 0;
		           
                  for (var imagesLoaded=0; imagesLoaded < 6; ++imagesLoaded) {
	                   leaf[imagesLoaded] = new Image();
	                   leaf[imagesLoaded].src = "leaf" + imagesLoaded + ".gif";
	                   if (imagesLoaded == 15)
	                       setInterval("fall()", 200);
	             }
                  function fall() {
	                  if (curLeaf == 5)
	                          curLeaf = 0;
	                  else 
	                       ++curLeaf;
	                  document.getElementById("leafImage").src= leaf[curleaf].src;
	                  
	            }
                  
                 /* ]]> */
                 </script>
                 </head>

     
                 <body>
                      <img src="leaf0.gif" id="leafImage" height="100" width="200" alt="Image of a leaf." />
          
                      
         
                 </body>
                 </html>

:x

  1. you have at least 1 syntax error.

  2. you are calling fall(), which references the element “leafImage” before the element is loaded.

  3. if you still have problems after fixing 1) and 2) you can place alert(‘got here’) statements in your code, along with alert()'s to display variable values to find logic errors in your code.

I found the mistakes and corrected them and it works great now thank you for the help. :smiley: