6 Replies Latest reply on Aug 25, 2007 10:57 AM by Greg Dove

    JSFL

    Damon Edwards Level 3
      anyone know of something that will run through your document and tell you if there are any onEnterFrame that haven't been deleted or setInterval that haven't been cleared? and possibly where they are.?..
        • 1. Re: JSFL
          NSurveyor Level 2
          You can't use JSFL at runtime. However, you can use ActionScript to find onEnterFrames. Simply call: trace(_root.findOE()); when you want to see still existing onEnterFrame's. It will trace an array of all MovieClips that have an onEnterFrame defined. But you have to put this code on the first frame of your movie:

          MovieClip.prototype.findOE = function(){
          var oe = this.onEnterFrame ? [this] : [];
          for(var c in this){
          if(typeof(this[c])=='movieclip'){
          oe = oe.concat(this[c].findOE());
          }
          }
          return oe;
          }

          setInterval, there is no easy way to verify. You could however create your own version of setInterval that does keep track. The following function clears out all intervals that haven't been done so already:

          function clearIntervals(){
          var dummy = function(){};
          var id = setInterval(dummy,0);
          for(var i=1;i<=id;i++){
          clearInterval(i);
          }
          }
          • 2. Re: JSFL
            Damon Edwards Level 3
            thank you, this is perfect.
            • 3. Re: JSFL
              clbeech Level 3
              Quest for knowledge: if not deleted or set to null, do onEnterFrame events continue running after a mc or swf get's removed from the timeline or unloaded, like setIntervals do?
              • 4. Re: JSFL
                Greg Dove Level 4
                @cbeech I believe removeMovieClip gets rid of them (I tested this recently and found it to be true on one occasion), unloadMovie leaves things behind (a belief.. I didn't test this but its what the documentation says).
                • 5. Re: JSFL
                  NSurveyor Level 2
                  You're welcoe.

                  In reply to the quest for knowledge, it seems that both unloadMovie and removeMovieClip kill off onEnterFrames, as seen with this code:

                  _root.createEmptyMovieClip('x',0);
                  _root.createEmptyMovieClip('y',1);
                  _root.x.onEnterFrame = function(){
                  trace('Unloaded');
                  }
                  _root.y.onEnterFrame = function(){
                  trace('Removed');
                  }
                  _root.x.unloadMovie();
                  _root.y.removeMovieClip();

                  Interestingly, unloadMovie allows the onEnterFrame to run once while removeMovieClip does not.
                  • 6. JSFL
                    Greg Dove Level 4
                    @NSurveyor hmmm, so I see. Like I said I just read about that in the docs. it wouldn't be the first time the documentation is incorrect.
                    I don't really understand the purpose of unloadMovie anyway... I always use removeMovieClip. The way its described in the docs gives you the impression its like reseting the display contents to 'emptyMovieClip' status, but retaining the properties and handlers... and I guess there might be a situation where you'd want to do that but I just haven't come across it yet. And it seems the docs are not completely true (at least for the onEnterFrame handler - after one frame's effort - bizarre!).
                    x however does behave like the docs say for other properties (e.g. if you set its _x property) and it does continue to exist after the unloadMovie, unlike removeMovieClip... so parts of it are true.