5 Replies Latest reply on Jun 25, 2008 2:38 PM by

    where to delete t.onEnterFrame

      Hi all. I've created a banner that has two frames on the main timeline. On the first frame is some script to create snow. There is an init() function to set some variables and then a call to a mover() function. The init() function sets t.onEnterFrame = mover(); I have a few movie clips on the stage in the first frame of my main timeline. One of them plays, then at the end has some script to start the next movie clip. At the end of my last movie clip, I have script to advance the main timeline to frame two, where I want everything to stop. I'm having trouble removing the t.onEnterFrame to get the snow to stop moving. I tried creating a global variable "finished" to keep track of when the last movie finishes and advance to frame two of the main timeline, and tried putting an "if" statement inside the mover function to check for this and remove the t.onEnterFrame. No luck. Any help is appreciated. Thanks!
        • 1. where to delete t.onEnterFrame
          clbeech Level 3
          you finished var is not getting seen because - even though the code is on the main timeline, the method is being assigned to the onEnterFrame property for 'each' snowflake clip - therefore the var doesn't exist in that scope and you need to call:

          _root.finished -or- _parent.finished

          this would also be true from within the other clip - when the clip is complete and you call to change the var use the same path. also you really should make certain the var exists in the main timeline with a declaration statement, additionally you should be able to use a Boolean value:

          //declare the variable
          var finished:Boolean = false;

          //call from the clip
          _parent.finished = true;

          //used in the moverSnow method
          if(_parent.finished) { ... }

          Also you should use:
          delete this.onEnterFrame;

          as the variable 't' doesn't exist in this scope and was only used during assignment and is local to that method
          1 person found this helpful
          • 2. Re: where to delete t.onEnterFrame
            So your right about the onEnterFrame being attached to each clip. If I write, "delete snow1.onEnterFrame" that does the trick, but I'm trying to write another for loop that loops through each clip for me and deletes the onEnterFrame for each clip. I must be getting the syntax wrong...I've tried..... delete "snow"+k.onEnterFrame; and delete("snow"+k).onEnterFrame;

            Any ideas? Thanks for the help!
            • 3. Re: where to delete t.onEnterFrame
              So your right about the onEnterFrame being attached to each clip. If I write, "delete snow1.onEnterFrame" that does the trick, but I'm trying to write another for loop that loops through each clip for me and deletes the onEnterFrame for each clip. I must be getting the syntax wrong...I've tried..... delete "snow"+k.onEnterFrame; and delete("snow"+k).onEnterFrame;

              Any ideas? Thanks for the help!
              • 4. Re: where to delete t.onEnterFrame
                clbeech Level 3
                you're close :) - you need to write it like this:
                1 person found this helpful
                • 5. Re: where to delete t.onEnterFrame
                  Thanks! Your code worked great with one small tweak. I made it:

                  delete _root['snow'+i].onEnterFrame;