1 Reply Latest reply on Oct 17, 2006 6:20 AM by Newsgroup_User

    setInterval not working properly

    DJ_James Level 1
      I have a swf file that is loaded into some courseware that is the navigation for the entire lesson. It has a dynamic menu system that I want to close if the user rolls out of any of the buttons in the menu for more than a second.

      Here is the code for the function on the root timeline of the file:

      _global.closeIntNum = 0;

      _global.closeMenu = function() {
      ssDebug.trace("closing menu...")
      for (var i=0; i<_root.segArray.length; i++) {
      _root.controlPanel.navMenu.segMenu[_root.segArray ].topMenu._visible = false;
      for (var t=0; t<_root.topArray
      .length; t++) {
      _root.controlPanel.navMenu.segMenu[_root.segArray ].topMenu[_root.topArray[t]].frmMenu._visible = false;
      }
      }
      navMenu._visible = false;
      clearInterval(_root.closeIntNum)
      }

      Here is the code on the button that is buried inside movie clips for the menu (i stripped out uncessary code):

      on(rollOver) {
      clearInterval(closeIntNum)
      }

      on(rollOut) {
      closeIntNum = setInterval("closeMenu",1000);
      }

      on(release) {
      closeMenu();
      }

      Any time the closeMenu() function is called normally, it works fine.. but if I use the setInterval to make it be called in 1 second.. it just won't work at all..

      any ideas?
        • 1. Re: setInterval not working properly
          Level 7
          DJ James,

          > Any time the closeMenu() function is called normally, it works fine..
          > but if I use the setInterval to make it be called in 1 second.. it just
          > won't work at all..

          I see it.

          > closeIntNum = setInterval("closeMenu",1000);

          In this line, you need to call the actual function, not a string, so
          drop the quotation marks. You only need a string when you're specifying an
          object reference as the first parameter.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."