Solved

Stopping a running Tween class

Posted on 2009-07-07
3
388 Views
Last Modified: 2013-11-11
I have a tween class defined in a function like below, which runs when the user clicks a left or right arrow to scroll some thumbnails:

function scroll_thumbs() {
// code that defines scroll_to's value
var mcTween:Tween = new Tween( paintings_strip_mc, "_x", Strong.easeOut, paintings_strip_mc._x, scroll_to, 5, true );
}

This works perfectly, but I also want to move the same mc (paintings_strip_mc) in another way if the user hovers over the mc. This doesn't use a tween - instead it uses a timer which gently scrolls the mc along.

All good. However if the tween above is still running from the user clicking an arrow, then it fights with the timer scrolling and you get a horrible effect and it doesn't move but instead jiggles about. You have to wait for the tween to finish, and then it works.

Since I've defined the tween in a function, how can I tell it to stop if the user hovers over the strip?

Thanks!
0
Comment
Question by:corin_pearce
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 24793643
firstly don't define the tween in a function.
import mx.transitions.*;
var mcTween:Tween;
function scroll_thumbs() {
// code that defines scroll_to's value
 mcTween = new Tween( paintings_strip_mc, "_x", Strong.easeOut, paintings_strip_mc._x, 500, 5, true );
}

then just call mcTween.stop();

0
 

Author Comment

by:corin_pearce
ID: 24793678
Thanks! I thought of that, but problem is I want to change mcTween each time an arrow is pressed - i.e. there will be a new scroll_to value each time.

So that's why I put it in a function, so that it could be made again and again...
0
 

Author Comment

by:corin_pearce
ID: 24793684
ahhh sorry I misread your comment, I'll have a go at that
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now