5 Replies Latest reply on Apr 15, 2013 10:50 AM by kglad

    Tween Problem?

    JonnyDL Level 1

      I'm loading up images dynamically and trying to get them to tween, but it isn't working as expected (or the way it should)

      Once Ive creted the empty movieclip, and load the movie it appears on stage. I have a set interval and then the tweens activate. The problem is only one of them activates (and its the last one). Id like an animation that would move the image off the stage in two directions at the same time (diagnal with a bit of rotation if possible).


      Here is the code,

      import mx.transitions.Tween;

      import mx.transitions.easing.*;

      import flash.filters.GlowFilter;

      import flash.filters.DropShadowFilter;

      import flash.filters.BlurFilter;

      import flash.filters.BevelFilter





      this.createEmptyMovieClip("mcHolder", 1);

      var myLoader:MovieClipLoader = new MovieClipLoader();






      myLoader.loadClip("Pool.png", mcHolder);

      mcHolder.forceSmoothing = true;







      var timerone = setInterval(frameOne, 4000)

      function frameOne()


                var sideways:Tween = new Tween(mcHolder, "_x", Strong.easeIn, mcHolder._x, 312, 3, true);

                var updown:Tween = new Tween(mcHolder, "_y", Strong.easeOut, mcHolder._y, 230, 3, true);





      Can a movieclip created like I have be tweened ke I want (or would I need to go into some code to do it)

        • 1. Re: Tween Problem?
          kglad Adobe Community Professional & MVP

          1. you should wait until loading is complete to start your setInterval.

          2.  you should clear your interval before setting it (to prevent run-away intervals).

          3. you're only loading one image with that code so your comment about the only one activating makes no sense.

          • 2. Re: Tween Problem?
            JonnyDL Level 1

            I'm trying to understand ways to use setInterval (a simple concept I can't seem to work with =]) Simply Id like to know the best way to tween one object into another with a pause inbetween. I can get one transition to work, when I use another the setinterval gets in the way.

            My understanding of inerval: it needs to be set outside a function, and then calls that function in a time set (with a clear), So It starts at launch. When I've tried to place it in a function and then clear it in another function. it didn't clear.


            example above:

            I can get that first tween to work. The image sits on the stage for 4 seconds and then tweens. When I try to repeat the action it messes up or dosent work, because I've set a setinterval outside a function and triggers but at the wrong spot or inside the next called function (onMotionFinished), but wont clear.

            Can you give any clarity on what to do to get the set interval to work properly

            • 3. Re: Tween Problem?
              kglad Adobe Community Professional & MVP

              use an onMotionFinished handler (applied to your tween) to detect when a tween completes.  in that handler use setTimeout() to call another function that starts the next tween.

              • 4. Re: Tween Problem?
                JonnyDL Level 1

                THANK YOU!!! Some new useful code to use. I'll experiment with this.

                I went to adobe resource to get a quick view of the code and its use/syntax. It appears that the set inteval in a general timer best used for repeatative (single actions/functions) settimeout is used to switch/delay different functions.

                Thank you again

                • 5. Re: Tween Problem?
                  kglad Adobe Community Professional & MVP

                  you're welcome.