1 Reply Latest reply on Nov 23, 2007 9:50 AM by kglad

    odd createEmptyMovieClip bug

    SimonClark
      thisi s a very simple snippet from a much more complex project, but it shows the problem I am having.

      quote:

      function setupNextSlide() {
      var newMC = this.createEmptyMovieClip("slide_"+this.getNextHighestDepth(), this.getNextHighestDepth());
      trace("newMC after createEmptyMovieClip: "+ newMC);
      setTimeout(setupNextSlide, 1000); // this fails
      //setupNextSlide(); // this works
      }

      setupNextSlide();
      //setupNextSlide(); // works
      //setupNextSlide(); // works



      As it is, it will create the first movieclip, but createEmptyMovieClip returns undefined for all subsequent calls, but only using setInterval or setTimeOut. If I call setupNextSlide() recursively or repeatedly, it works. If I call another routine from the setTimeOut, which calls setupNextSlide, it works! so, I have a workaround, but t is Very Odd.
        • 1. Re: odd createEmptyMovieClip bug
          kglad Adobe Community Professional & MVP
          "this" is undefined when you use setInterval() etc: you're out of scope of your timeline when you use that function or setTimeout to call setupNextSlide().

          to remedy, use a timeline reference instead of this, use the 2nd form of setInterval() (that explicitly passes scope) or use mike chamber's delegate.create method.