5 Replies Latest reply on Dec 30, 2006 5:38 PM by kglad

    Looking for this nice effect

    Detonate 2004 Level 1
      Hello everyone,
      I've been looking around for a couple of days and am trying to build this smooth easing effect. Please have a view here: http://www.cozumelrs.com.br/

      When you move your mouse around on the 1st page before selecting languages, everything responds in a smooth mouse opposite behavior. Anyone worked on something similar or might have any suggs?
        • 1. Re: Looking for this nice effect
          kglad Adobe Community Professional & MVP
          that's not very smooth, so that can be done using an onEnterFrame loop or setInterval() without frequent stage refreshes.

          for the easing, you can use a standard ease based on the _xmouse and _ymouse properties. for example:

          • 2. Re: Looking for this nice effect
            Detonate 2004 Level 1
            kglad, thanks a lot for pointing out in this direction. I've been trying to implement something with Robert Penner's tweening classes without any success. This concept works a-ok and I understand your approach perfectly!

            If I'd like to affect say 5 objects,
            1. How can I create the code for constructing the function without repeating this over and over (object instance name reapeat). Also, changing the easing slightly for each object would be nice also...
            2. Would it be problematic if I get rid of the "clearinterval" and let the movie run?

            Again, thanks a lot for helping out with an example. It's very appreciated =)



            • 3. Re: Looking for this nice effect
              kglad Adobe Community Professional & MVP
              first 2 general comments: 1) if you use setInterval() with a small time parameter (like 2 ms), then you should use updateAfterEvent() in the function being called so the stage updates after the function executes. otherwise, you lose the benefit of those frequent function calls.

              2) always use clearInterval() to terminate a setInterval() loop that's no longer needed. and an even better rule-of-thumb is to use clearInterval() even when you don't think a setInterval() has been defined or you think it has already been cleared. ie, you can't use too many clearInterval() statements. they cause no issue when you (try to) clear an interval that doesn't exist. on the other hand, if you ever execute identical setInterval() statements you'll have a mess that cannot be fixed after the duplicate interval is created. (an example is below.)

              you can use a similar function, to the above, for any number of movieclips and any number of easing equations. the essential part of the easing equations i used is that the number multiplying yourMC._x plus the number multiplying destX equal 1. that way you can be sure yourMC._x will converge to destX.

              with the easing equation you used for yourMC._x, yourMC._x will converge to .8*destX.

              anyway, to generalize that code:

              • 4. Re: Looking for this nice effect
                Detonate 2004 Level 1
                Thanks kglad,
                the above example and explanation points out exactly what I needed to understand =) This has been a very informative learning thread! Cheers for all your time and patience.
                • 5. Re: Looking for this nice effect
                  kglad Adobe Community Professional & MVP
                  you're welcome.