5 Replies Latest reply on Dec 20, 2007 5:25 PM by freshgrad

    help! how to remove a movie effect for other scene

    freshgrad
      Hi I am working on an e-card. I have 2 scene where "Scene 1" has snow fall effect and "Scene 2" has message and greetings but do not want the snow fall effect. So far the snow effect run through out both scene but I need to stop it on scene 2.
      The script that i got online is put under frame-script at Scene 1. How can i make it stop at scene 2 and when the movie loop back to scene 1 , the snow effect will run again?

      Please help. thanks a lot.

      Below are the script that i got from a tutorial to create snow effect. It is put under scene 1 first frame.
        • 1. help! how to remove a movie effect for other scene
          LukasCanoe
          rap onEnterframe with if statement testing what scene you are in if not scene one animation stops. or put snow animation in its own movie clip.
          this.onEnterFrame = function() {
          if(scene == 1){
          for(var i=0;i<anzahl;i++) {
          if(this["schnee"+i]._x>breite+10||this["schnee"+i]._y>hoehe+10 || ersterlauf<anzahl) {
          this["schnee"+i].speed = (Math.random()*max_speed)+min_speed;
          this["schnee"+i]._x = Math.random()*breite;
          this["schnee"+i]._y = ersterlauf<anzahl ? Math.random()*hoehe : 0;
          this["schnee"+i]._xscale = this["schnee"+i]._yscale = this["schnee"+i]._alpha = (Math.random()*max_groesse)+min_groesse;;
          this["schnee"+i].r_xy = random(2) == true;
          ersterlauf<anzahl ? ersterlauf++ : ersterlauf = anzahl+1;
          } else {
          if(this["schnee"+i].r_xy) {
          this["schnee"+i].go += Math.random()*-0.2;
          if(this["schnee"+i].go < -schwing_faktor) this["schnee"+i].r_xy = false;
          } else {
          this["schnee"+i].go += Math.random()*0.2;
          if(this["schnee"+i].go > schwing_faktor) this["schnee"+i].r_xy = true;
          }
          this["schnee"+i]._x += this["schnee"+i].go;
          this["schnee"+i]._y += this["schnee"+i].speed;
          }
          }
          }
          }

          something like this.
          • 2. Re: help! how to remove a movie effect for other scene
            freshgrad Level 1
            Thanks but it is not working. The snow stop for in the first scene too.
            • 3. Re: help! how to remove a movie effect for other scene
              LukasCanoe Level 1
              I didn't say that the code would be exactly like the above you will have to create your own test in the if statement if(scene == 1){, you could use a global variable and set it to true when you are on scene one and false when you are on scene two. so it would be if(globalVar == true){

              mattCanoe
              • 4. help! how to remove a movie effect for other scene
                dr_ross Level 1
                as its just an onEnterFrame triggered animation all you need is a way to assign and delete the function from the handler

                So if you seperate off the function from the onEnterFrame handler

                i.e.

                this.onEnterFrame = myAnimationFunction

                myAnimationFunction = (){
                for(var i=0;i<anzahl;i++) {
                etc etc..

                The when you need to stop the animation you just need to call

                delete this.onEnterFrame

                and when you need to reassign it call this.onEnterFrame = myAnimationFunction

                Hope that helps, DrRoss

                Edited:- You could also do with a cleanup function to call at the same time to remove all the animated objects off screen when you delete the onEnterFrame handler.
                • 5. Re: help! how to remove a movie effect for other scene
                  freshgrad Level 1
                  Thank you very much. that is very useful.