Skip navigation
Currently Being Moderated

How to turn off script

Apr 16, 2012 2:24 AM

Hello,

 

I have a simple but effective script from Flashmo that basically duplicates a graphic of a heart and creates a raining heart effect.

Works great,..

 

But I would like to turn it off, and then back on. So basically it starts, then stops, then starts again later.

I am reading the script and experiemented with it but I cant seem to turn it off.

 

Probably simple. Can someone help?

Here is the script...

 

------------------

 

// created by www.flashmo.com

stop();

import mx.transitions.Tween;

import mx.transitions.easing.*;

flashmo_heart._visible = false;

var interval_id:Number;

var i:Number = 1;

var duration:Number = 200;

var total:Number = 500;

 

 

function create_flashmo()

{

          var fm = flashmo_heart.duplicateMovieClip("fm" + i, total - i );

 

 

          fm._x = random(750) + 50;

          fm._alpha = random(40) + 61;

          fm._xscale = fm._yscale = random(60) + 41;

 

          if( i % 2 == 0 )

                    rotation = random(90) - 270;

          else

                    rotation = random(270) + 90;

 

          new Tween(fm, "_rotation", Regular.easeOut, rotation, 0, 1.5, true);

          new Tween(fm, "_x", Elastic.easeInOut, fm._x, fm._x + random(120) - 60, 3, true);

          fm_tween = new Tween(fm, "_y", None.easeOut, -30, 430, random(3) + 3, true);

 

          fm_tween.onMotionFinished = function()

          {

                    removeMovieClip(fm);

          }

           if(i >= total)

           {

                    i = 1;

           }

           i++;

}

interval_id = setInterval(this, "create_flashmo", duration);

 

 

flashmo_bg.useHandCursor = false;

flashmo_bg.onRelease = function()

{

          this.play();

}

 

--------------------------------------------------------------

 

Thank you very much in advance..

 
Replies
  • Currently Being Moderated
    Apr 16, 2012 6:24 AM   in reply to bkrascal

    YOu could use a clearInterval(interval_id) call to stop the creation of new hearts, but getting the existing ones to stop falling would be tricky and getting them to restart falling even trickier.  The reason for being tricky is that your code uses coded Tweens and dynamically created objects without keeping track of who's still around.  You'd be better of not using the Tweens if you wanted some way of controlling the motion more easily.

     

    While it might not be what you wanrt, you could just keep them running and add a movieclip that blocks them out when you want them stopped (not visible as well)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points