[Tweener] Mouse-Drag Tweening
Zeh Fernando
zeh at zehfernando.com
Tue Dec 16 15:58:17 PST 2008
That sort of animation should not be done by tweening. You're better off
with an approximation algorithm; it'll be easier to control, more fluid, and
use a lot less resources.
An approximation/easing works like this:
mc.addEventListener(Event.ENTER_FRAME, onMCEnterFrame);
public function onMCEnterFrame(e:Event): void {
var destX:Number = parent.mouseX+10;
var destY:Number = parent.mouseY+10;
var ease:Number = 4; // from 1 (immediate change) to infinity (slower
change)
x -= (x-destX) / ease;
y -= (y-destY) / ease;
}
Honestly, using a tweening for that (with Tweener or any other similar
library) is like using a screwdriver to fix a nail: it may work, but it's
still the wrong tool and it'll be doing more work than you should.
Zeh
On Tue, Dec 16, 2008 at 12:13 PM, Makc <makc.the.great at gmail.com> wrote:
> well, I assume those clips are expected to follow the mouse in some
> way; if that's not the case, what I said doesnt make sense to you for
> a reason :) if that is the case, imagine if on every mouseMove event
> you do
>
> Tweener.addTween (clip, { x: mouseX + 10, y: mouseY + 20, time: 0.5 });
>
> then previous tween gets cancelled, and the clip is instructed to get
> into new position after 0.5 seconds. Now, if two mouseMove events are
> registered at 20 pixels away from each other (user moves mouse
> slowly), you have 20/0.5 = 40 pixels per second average speed for your
> clip, but if two mouseMove events are registered at 200 pixels away
> from each other (user moves mouse fast), you have 20/0.5 = 400 pixels
> per second average speed for your clip. So you have this kind of
> relationship automatically.
>
>
> On Tue, Dec 16, 2008 at 4:45 PM, Sascha <sbalkau at gmail.com> wrote:
> > Thanks Makc but I'm not sure what exactly is meant with passing constant
> > time to Tweener. Could you explain this a bit more in detail? I mostly
> only
> > used addTween and removeTween so far.
> >
> >
> >> -----Original Message-----
> >> From: tweener-bounces at lists.caurinauebi.com [mailto:tweener-
> >> bounces at lists.caurinauebi.com] On Behalf Of Makc
> >> Sent: Tuesday, December 16, 2008 22:01
> >> To: tweener at lists.caurinauebi.com
> >> Subject: Re: [Tweener] Mouse-Drag Tweening
> >>
> >> you dont need to do that. if you pass constant time to tweener (like
> >> 500ms) but user moves his mouse over greater distance, this will
> >> naturally result in higher speed - it is necessary to cover greater
> >> distance in the same time.
> >>
> >> On Tue, Dec 16, 2008 at 2:51 PM, Sascha <sbalkau at gmail.com> wrote:
> >> > Thanks! So much for the easy part. But let's say you want to increase
> >> the
> >> > speed of the tweening the further the mouse y position goes from it's
> >> origin
> >> > (the coord where the user clicked and held the button), either up or
> >> down.
> >> > How do you calculate this value from the mouse positions?
> >> > I'm calculating the distance between origin mouseY and current mouseY
> >> but I
> >> > don't know how to translate this value into a useful value for
> >> Tweeners
> >> > tween speed property. Would be great to hear any ideas.
> >> >
> >> > Sascha
> >> >
> >> >
> >> >> -----Original Message-----
> >> >> From: tweener-bounces at lists.caurinauebi.com [mailto:tweener-
> >> >> bounces at lists.caurinauebi.com] On Behalf Of Makc
> >> >> Sent: Tuesday, December 16, 2008 18:01
> >> >> To: tweener at lists.caurinauebi.com
> >> >> Subject: Re: [Tweener] Mouse-Drag Tweening
> >> >>
> >> >> you can compute targets depending on mouse coords and start tweens
> >> on
> >> >> mouseMove event if the button is down
> >> >>
> >> >> On Tue, Dec 16, 2008 at 6:56 AM, Sascha <sbalkau at gmail.com> wrote:
> >> >> > Hi List,
> >> >> >
> >> >> > I have a job task that requires a number of movieclips to scroll
> >> >> upwards or
> >> >> > downwards depending on the user dragging the mouse up or down,
> >> kind
> >> >> of like
> >> >> > scrubbing a wheel. I'm using Tweener to animate the clips and at
> >> the
> >> >> moment
> >> >> > I have absolutely no clue how I could implement this. Has anyone
> >> ever
> >> >> made
> >> >> > such kind of a user-interaction and is it possible to do this with
> >> >> Tweener?
> >> >> >
> >> >> > Thanks,
> >> >> > Sascha
> >> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > Tweener mailing list
> >> > Tweener at lists.caurinauebi.com
> >> > http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
> >> >
> >> _______________________________________________
> >> Tweener mailing list
> >> Tweener at lists.caurinauebi.com
> >> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
> >>
> >>
> >> __________ Information from ESET NOD32 Antivirus, version of virus
> >> signature database 3695 (20081216) __________
> >>
> >> The message was checked by ESET NOD32 Antivirus.
> >>
> >> http://www.eset.com
> >>
> >
> > _______________________________________________
> > Tweener mailing list
> > Tweener at lists.caurinauebi.com
> > http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
> >
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20081216/bcc6f36f/attachment.htm>
More information about the Tweener
mailing list