Loading ...
Sorry, an error occurred while loading the content.

Re: [JavaScript] "setTimeout" question

Expand Messages
  • soren.j.winslow@cummins.com
    Can you post the add_leaf function? It seems that may really be where it is hanging up at. Soren Jonathan Tomshine Sent by:
    Message 1 of 4 , Mar 31, 2008
    • 0 Attachment
      Can you post the add_leaf function? It seems that may really be where it
      is hanging up at.

      Soren





      Jonathan Tomshine <jrtomshine@...>
      Sent by: JavaScript_Official@yahoogroups.com
      03/29/2008 07:35 PM
      Please respond to
      JavaScript_Official@yahoogroups.com


      To
      JavaScript_Official@yahoogroups.com
      cc

      Subject
      [JavaScript] "setTimeout" question






      I've been fighting with this problem all day, and I think I finally
      need to ask for some help.

      I've written the following function:

      ----------

      function leaf()
      {
      // set and calculate some parameters
      min_x = 0;
      min_y = 0;
      max_x = 1000;
      max_y = 100;
      end_y = 700;
      max_t = 5000;
      z_level = 1;
      leaves = 25;
      leaf_file = 'leaf_01.gif';
      start_x = Math.round((max_x - min_x) * Math.random() + min_x);
      start_y = Math.round((max_y - min_y) * Math.random() + min_y);

      // add a leaf to the browser and start it falling down
      // if I comment this out, then the recursion seems to work
      // (strange!)
      add_leaf(leaf_file, start_x, start_y, end_y, z_level);

      // add a timer to repreat this process in 1000 milliseconds
      setTimeout("leaf()", 1000);
      }

      ----------

      The goal is to place an image (of a leaf) towards the top of the
      browser window at a pseudo-random location and animate it falling
      down. All of the animating is done by the function "add_leaf" using
      setTimeout. This "leaf" function is only supposed to call "add_leaf"
      and then set up a Timeout to call itself again in 1 second.

      For whatever reason, this does not work. The "setTiimeout" call to
      "leaf()" fails immediately, and the error message claims that leaf()
      is not defined.

      If anyone could help me spot the error in this, I'd appreciate it!

      Thanks,
      Jon



      P.S. -- This is online here:

      http://www.jshine.net/test/falling/

      The complete javascript source is in a separate file here:

      http://www.jshine.net/test/falling/falling_2.js


      ------------------------------------

      Visit http://aiaiai.com for more groups to joinYahoo! Groups Links




      ______________________________________________________________________
      This email has been scanned by the MessageLabs Email Security System.
      For more information please visit http://www.messagelabs.com/email
      ______________________________________________________________________



      [Non-text portions of this message have been removed]
    • david.smart@ubs.com
      Jonathan I tried your site (with IE6) and the leaves drop and the leaves add. Have you got it fixed? Regards, Dave Smart ... From:
      Message 2 of 4 , Mar 31, 2008
      • 0 Attachment
        Jonathan

        I tried your site (with IE6) and the leaves drop and the leaves add.
        Have you got it fixed?


        Regards, Dave Smart

        -----Original Message-----
        From: JavaScript_Official@yahoogroups.com
        [mailto:JavaScript_Official@yahoogroups.com] On Behalf Of
        soren.j.winslow@...
        Sent: Tuesday, 1 April 2008 03:32
        To: JavaScript_Official@yahoogroups.com
        Subject: Re: [JavaScript] "setTimeout" question

        Can you post the add_leaf function? It seems that may really be where
        it
        is hanging up at.

        Soren





        Jonathan Tomshine <jrtomshine@...>
        Sent by: JavaScript_Official@yahoogroups.com
        03/29/2008 07:35 PM
        Please respond to
        JavaScript_Official@yahoogroups.com


        To
        JavaScript_Official@yahoogroups.com
        cc

        Subject
        [JavaScript] "setTimeout" question






        I've been fighting with this problem all day, and I think I finally
        need to ask for some help.

        I've written the following function:

        ----------

        function leaf()
        {
        // set and calculate some parameters
        min_x = 0;
        min_y = 0;
        max_x = 1000;
        max_y = 100;
        end_y = 700;
        max_t = 5000;
        z_level = 1;
        leaves = 25;
        leaf_file = 'leaf_01.gif';
        start_x = Math.round((max_x - min_x) * Math.random() + min_x);
        start_y = Math.round((max_y - min_y) * Math.random() + min_y);

        // add a leaf to the browser and start it falling down
        // if I comment this out, then the recursion seems to work
        // (strange!)
        add_leaf(leaf_file, start_x, start_y, end_y, z_level);

        // add a timer to repreat this process in 1000 milliseconds
        setTimeout("leaf()", 1000);
        }

        ----------

        The goal is to place an image (of a leaf) towards the top of the
        browser window at a pseudo-random location and animate it falling
        down. All of the animating is done by the function "add_leaf" using
        setTimeout. This "leaf" function is only supposed to call "add_leaf"
        and then set up a Timeout to call itself again in 1 second.

        For whatever reason, this does not work. The "setTiimeout" call to
        "leaf()" fails immediately, and the error message claims that leaf()
        is not defined.

        If anyone could help me spot the error in this, I'd appreciate it!

        Thanks,
        Jon



        P.S. -- This is online here:

        http://www.jshine.net/test/falling/

        The complete javascript source is in a separate file here:

        http://www.jshine.net/test/falling/falling_2.js


        ------------------------------------

        Visit http://aiaiai.com for more groups to joinYahoo! Groups Links




        ______________________________________________________________________
        This email has been scanned by the MessageLabs Email Security System.
        For more information please visit http://www.messagelabs.com/email
        ______________________________________________________________________



        [Non-text portions of this message have been removed]


        ------------------------------------

        Visit http://aiaiai.com for more groups to joinYahoo! Groups Links



        Visit our website at http://www.ubs.com

        This message contains confidential information and is intended only
        for the individual named. If you are not the named addressee you
        should not disseminate, distribute or copy this e-mail. Please
        notify the sender immediately by e-mail if you have received this
        e-mail by mistake and delete this e-mail from your system.

        E-mails are not encrypted and cannot be guaranteed to be secure or
        error-free as information could be intercepted, corrupted, lost,
        destroyed, arrive late or incomplete, or contain viruses. The sender
        therefore does not accept liability for any errors or omissions in the
        contents of this message which arise as a result of e-mail transmission.
        If verification is required please request a hard-copy version. This
        message is provided for informational purposes and should not be
        construed as a solicitation or offer to buy or sell any securities
        or related financial instruments.
      Your message has been successfully submitted and would be delivered to recipients shortly.