3 Replies Latest reply on Aug 20, 2007 11:13 AM by kamckng

    setInterval help - Actionscript 2.0

    mynameissam.co.uk
      Hey,

      I'm programming some tweens with actionscript and I want the flashplayer to wait 0.5 seconds between each action. I've used set interval before, but that was when I only wanted the playhead to stop, wait so many seconds.

      In this instance I need it to go like this:

      import mx.transitions.easing.*;
      import mx.transitions.Tween

      var mc1:Tween = new Tween(mc1, "_y", mx.transitions.easing.Bounce.easeOut, -20, 330, 10, false);

      wait 0.5 seconds (need the code for this bit!)

      var mc2:Tween = new Tween(mc2, "_y", mx.transitions.easing.Bounce.easeOut, -20, 330, 10, false);

      wait 0.5 seconds (need the code for this bit!)

      var mc3:Tween = new Tween(mc3, "_y", mx.transitions.easing.Bounce.easeOut, -20, 330, 10, false);

      e.t.c and there are 20 mc's that I need to tween. Obviously don't want to have mountains of nested code, any ideas? If you could set out the syntax in your replies that would be great as otherwise I probably won't understand!

      Cheers

        • 1. Re: setInterval help - Actionscript 2.0
          Level 7
          I'd suggest you check out the Fuse Kit - aka Fuse - from
          www.mosessupposes.com
          It's an animation sequencer and has a built in delay setting to make things
          like this easy.
          Using Fuse you'd do something like this:

          import com.mosesSupposes.fuse.*;
          ZigoEngine.register(Fuse, PennerEasing);

          var a:Fuse = new Fuse();

          a.push([{target:mc1, start_y:-20, _y:330, seconds:3,
          ease:"easeOutBounce"},{target:mc2, start_y:-20, _y:330, seconds:3,
          ease:"easeOutBounce", delay:.5},{target:mc3, start_y:-20, _y:330, seconds:3,
          ease:"easeOutBounce", delay:1}]);

          a.start();

          In Fuse, you push objects onto the Fuse, which extends Array. If you push
          the objects individually, then the next one starts when the previous one
          finishes. If you push an array of objects, like I did here, then all those
          objects begin their tweens at the same time. Note the second one starts with
          a delay of .5 seconds, and the third with a delay of 1... You could stick
          the building of the object array into a for loop also, if you're doing 20 of
          them.

          HTH
          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: setInterval help - Actionscript 2.0
            Level 7
            DMennenoh **AdobeCommunityExpert** wrote:
            > I'd suggest you check out the Fuse Kit - aka Fuse - from
            > www.mosessupposes.com
            > It's an animation sequencer and has a built in delay setting to make things
            > like this easy.
            > Using Fuse you'd do something like this:
            >
            > import com.mosesSupposes.fuse.*;
            > ZigoEngine.register(Fuse, PennerEasing);
            >
            > var a:Fuse = new Fuse();
            >
            > a.push([{target:mc1, start_y:-20, _y:330, seconds:3,
            > ease:"easeOutBounce"},{target:mc2, start_y:-20, _y:330, seconds:3,
            > ease:"easeOutBounce", delay:.5},{target:mc3, start_y:-20, _y:330, seconds:3,
            > ease:"easeOutBounce", delay:1}]);
            >
            > a.start();
            >
            > In Fuse, you push objects onto the Fuse, which extends Array. If you push
            > the objects individually, then the next one starts when the previous one
            > finishes. If you push an array of objects, like I did here, then all those
            > objects begin their tweens at the same time. Note the second one starts with
            > a delay of .5 seconds, and the third with a delay of 1... You could stick
            > the building of the object array into a for loop also, if you're doing 20 of
            > them.
            >
            > HTH


            Also, you could google for TweenSuperExtended. I did something similar
            to this idea, but it seems to work well.

            • 3. Re: setInterval help - Actionscript 2.0
              kamckng
              yourTween:Tween = new Tween(all the stuff);

              yourTween.onMotionFinished = function () { setTimeout(callback_func, milliseconds, [extra params]); }

              you can also use setInterval, but if you want it just called once after each motin then i'd use setTimeout