Image rotation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gcong2
    New Member
    • May 2007
    • 1

    Image rotation

    I'm wanting to rotate an image, can someone tell me whats wrong with this script? Thanks.
    [code=javascript]
    <script language="JavaS cript">
    <!--
    var birth=new array();
    for(i=0 ;i<=2;i=i+1)
    birth=[i]=new Image();
    }
    birth[0].mce_src="http://sba-nl-sm6-03.medseek.com/websitefiles/jordanhealthsys 68254/images//birth2.jpg";
    birth[1].mce_src="http://sba-nl-sm6-03.medseek.com/websitefiles/jordanhealthsys 68254/images//birth3.jpg";
    var current;
    current=Math.ro und(2*Math.rand om()-.5);
    function rotate(){

    if(current<2){
    current=current +1;
    }
    else{
    current=0;
    }
    document.images[0].src=birth[current].src
    }
    function getfirst(){
    document.images[0].src=birth[current].src;
    setInterval("ro tate()",2000);
    }
    //--></script>[/code]
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by gcong2
    I'm wanting to rotate an image, can someone tell me whats wrong with this script? Thanks.

    <script language="JavaS cript">
    <!--
    var birth=new array();
    for(i=0 ;i<=2;i=i+1)
    birth=[i]=new Image();
    }
    birth[0].mce_src="http://sba-nl-sm6-03.medseek.com/websitefiles/jordanhealthsys 68254/images//birth2.jpg";
    birth[1].mce_src="http://sba-nl-sm6-03.medseek.com/websitefiles/jordanhealthsys 68254/images//birth3.jpg";
    var current;
    current=Math.ro und(2*Math.rand om()-.5);
    function rotate(){

    if(current<2){
    current=current +1;
    }
    else{
    current=0;
    }
    document.images[0].src=birth[current].src
    }
    function getfirst(){
    document.images[0].src=birth[current].src;
    setInterval("ro tate()",2000);
    }
    //--></script>
    Moved to Javascript forum

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Code:
      birth=[i]=
      should be
      Code:
      birth[i]=
      "array" should be "Array".

      What goes wrong with the script? Does it not work at all? What is it supposed to do - keep swapping images every 2 seconds?

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        having the proper sytax try to use try/catch block in JS.

        then have the familiarity with JS errors geneally occures.

        Regards.

        Comment

        Working...