Solved

Stopping a running Tween class

Posted on 2009-07-07
3
387 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

757 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

20 Experts available now in Live!

Get 1:1 Help Now