5 Replies Latest reply on Jun 18, 2009 1:02 PM by kglad

    Stop movieclip

    chewbears Level 1

      // Flash8 code
      import flash.display.BitmapData;
      import flash.filters.GlowFilter;
      //
      var maxBoltThickness:Number = 5;
      var boltHeight:Number = 400;
      var maxSplitsPerBolt:Number = 1;
      //

      //
      function firstLight() {
      // remove old bolt and create init bolt
      _root.lightning.removeMovieClip();
      newBolt(_root, 0, 0);
      // apply a filter for metal bluish light effect
      _root.lightning.filters = new Array(new GlowFilter(0xBBBBFF, 100, 13, 13, 3, 4));
      }
      // function for onEnterFrame
      function lightgrow() {
      this.y += 7;
      this.x += Math.random()*18-9+this.tendenz;
      // randomly split the bolt
      if (Math.random()*4-2>1.9 && this.splits>0) {
      this.splits--;
      newBolt(this, this.x, this.y);
      }
      // get thinner the closer it gets to the ground
      thickness = _root.maxBoltThickness-this.y/_root.boltHeight*_root.maxBoltThickness;
      this.lineStyle(thickness, 0xFFFFFF);
      this.lineTo(this.x, this.y);
      if (this.y>_root.boltHeight) {
      this.onEnterFrame = null;
      if (this == _root.lightning) {
      _root.firstLight();
      }
      }
      }
      // create a new bolt
      function newBolt(where:MovieClip, x:Number, y:Number) {
      var light:MovieClip = where.createEmptyMovieClip("lightning", where.getNextHighestDepth());
      if (where == _root) {
      light._x = Math.random()*200+150;
      }
      light.splits = _root.maxSplitsPerBolt;
      light.x = x;
      light.y = y;
      light.thickness = 0;
      light.tendenz = Math.random()*14-7;
      light.moveTo(x, y);
      light.onEnterFrame = lightgrow;
      }
      // initialize

      firstLight();

       

      I can not make the above stop when the root moves on to frame 2.

       

      Thanks

        • 1. Re: Stop movieclip
          kglad Adobe Community Professional & MVP

          try:

           

          chewbears wrote:

           

          // Flash8 code
          import flash.display.BitmapData;
          import flash.filters.GlowFilter;
          //
          var maxBoltThickness:Number = 5;
          var boltHeight:Number = 400;
          var maxSplitsPerBolt:Number = 1;
          //

          //
          function firstLight() {
          // remove old bolt and create init bolt
          _root.lightning.removeMovieClip();
          newBolt(_root, 0, 0);
          // apply a filter for metal bluish light effect
          _root.lightning.filters = new Array(new GlowFilter(0xBBBBFF, 100, 13, 13, 3, 4));
          }
          // function for onEnterFrame
          function lightgrow() {
          this.y += 7;
          this.x += Math.random()*18-9+this.tendenz;
          // randomly split the bolt
          if (Math.random()*4-2>1.9 && this.splits>0) {
          this.splits--;
          newBolt(this, this.x, this.y);
          }
          // get thinner the closer it gets to the ground
          thickness = _root.maxBoltThickness-this.y/_root.boltHeight*_root.maxBoltThickness;
          this.lineStyle(thickness, 0xFFFFFF);
          this.lineTo(this.x, this.y);
          if (this.y>_root.boltHeight) {
          this.onEnterFrame = null;
          if (this == _root.lightning) {
          _root.firstLight();
          }
          }
          }
          // create a new bolt
          function newBolt(where:MovieClip, x:Number, y:Number) {
          light = where.createEmptyMovieClip("lightning", where.getNextHighestDepth());
          if (where == _root) {
          light._x = Math.random()*200+150;
          }
          light.splits = _root.maxSplitsPerBolt;
          light.x = x;
          light.y = y;
          light.thickness = 0;
          light.tendenz = Math.random()*14-7;
          light.moveTo(x, y);
          light.onEnterFrame = lightgrow;
          }
          // initialize

          firstLight();

           

          // call to stop

          funtion stopF(){
          light.onEnterFrame=null;

          light.removeMovieClip();
          }

          1 person found this helpful
          • 2. Re: Stop movieclip
            chewbears Level 1

            kglad I think I messed up.  I don't want to "stop" it but pause it.  So basically when the frame finishs I want to pause where the bolt is for a moment and then I will use

             

            _root.lightning.removeMovieClip();

             

            on the next frame to delete it.

             

            So how would I place a pause in it? on the next frame.

             

            An aside what is controling the speed of the line being drawn.

             

            Thanks

            • 3. Re: Stop movieclip
              kglad Adobe Community Professional & MVP

              this will toggle pause and play:

               

              if(!this.toggle){
              light.onEnterFrame=null
              } else {
              light.onEnterFrame=lightgrow;
              }
              this.toggle=!this.toggle;

               

              the speed is controlled by the framerate and this line:

               

              this.y += 7;

              1 person found this helpful
              • 4. Re: Stop movieclip
                chewbears Level 1

                Kglad thanks for the response very helpful, but I don't want a play/pause just a pause.

                 

                Frame 1 = plays introduction, while it plays lighnting moves

                Frame 2 = pause to highlight the last position of the lightning

                frame 3 = delet movie clip and enter website.

                 

                So the pause I am looking for would be coded in frame 2 of the root.

                 

                thanks

                • 5. Re: Stop movieclip
                  kglad Adobe Community Professional & MVP

                  // pause
                  light.onEnterFrame=null

                  // play

                  light.onEnterFrame=lightgrow;