2 Replies Latest reply on Mar 9, 2010 2:09 AM by huray

    Interval to remove MC


      I have a movie clip which on enterframe duplicates movie clips. I want to set an interval to stop it from duplicating for 3 seconds then start duplicating again.

      I have tried the following:


      red.onEnterframe =function () { timer=setInterval (unloadMovie(hat,3000),clearInterval(timer); };


      I get not effect,  but when I delete clearInterval(timer), it stops duplicating and swf and Flash are force to close.


      Need help for this.

        • 1. Re: Interval to remove MC
          Ned Murphy Adobe Community Professional & MVP

          You can build a conditional into your enterframe function that checks a value to determine if it should process whatever it processes or not.  Have some mechanism set that variable to false and call a setTimeout function that waits 3 seconds before calling a function that sets that variablew back to true.


          var createMCs = true;


          red.onEnterframe =function () {


                    // whatever your enterframe does




          // ??? Missing link goes here - what sets the createMCs value to false?


          var delayProcessing:Number = setTimeout(delayFunction, 3000);


          function my_delayedFunction (arg1) {
                createMCs = true;



          What is missing in your description of this scheme is the mechanism that triggers the 3 seconds of no enterframe output.  Your 3 seconds of non-productivity has to start at some point, and that starting point is what is missing.  If the intention is to have it trigger every 3 seconds, then using setInterval would be more appropriate and would only need to involve toggling that true/false variable in each cycle (createMCs = !createMCs).

          • 2. Re: Interval to remove MC
            huray Level 1

            The following is my script:


            var timer;


            red.onEnterFrame=function() {timer=setInterval(unloadMovie(hat,3000);clearInterval(timer);
                _root.flower= 1;
                _root.i += 1;
                duplicateMovieClip(_root.hat, "hat"+_root.getNextHighestDepth(),


            Attach to movie clip "basket",

            onClipEvent (load) {
                this._visible = 0;
                if (_root.flower == 1) {
                    this._x = _root.basket._x;
                    this._y = _root.basket._y;
            onClipEvent (enterFrame) {
                if (this != _level0.bullet) {
                    if (_root.flower == 1) {
                        this._y -= 5;
                        this._visible = 1;
                    if (this._y<0) {


            what I want is hat is duplicating from basket for 3 seconds, stop, then duplicate again for another 3 seconds.


            I did intergrate your script but hat is not duplicating. Hoping your amendment.