3 Replies Latest reply on May 2, 2008 5:28 AM by Newsgroup_User

    Leave function

    lammspillning Level 1
      I have this code, but It keeps looping. I need to tell the function to stop after it has been executed once..
      I'm not sure how or where to do this.
        • 1. Re: Leave function
          Level 7
          If you look at help for setInterval, you'll see it returns an id value,
          which you can use to clear the interval with.

          var int1:Number;
          var int2:Number;

          //Text2 fade in
          text2_fadeIn = function(){
          TransitionManager.start(text2, {type:Fade, direction:Transition.IN,
          duration:2, easing:None.easeNone});
          int1 = setInterval(text2_fadeIn,4000);

          //Text2 fade out
          text2_fadeOut = function(){
          TransitionManager.start(text2, {type:Fade, direction:Transition.OUT,
          duration:2, easing:None.easeNone});
          int2 = setInterval(text2_fadeOut,6000);

          That should work. Are you using intervals to delay your animation? If so,
          I'd suggest looking at a better tweening class (Tweener, Fuse) where you can
          just specify a delay value right in the tween. Even if that's not what
          you're doing, I'd suggest using a tweening engine other than the built in

          Dave -
          Head Developer
          Adobe Community Expert

          • 2. Re: Leave function
            robdillon Most Valuable Participant
            Assign each setInterval function to a variable and then use clearInterval to stop the function from being called again. Here's one example:

            • 3. Re: Leave function
              lammspillning Level 1
              Ok nice! Thanks alot!