Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Stopping a running Tween class

Posted on 2009-07-07
Medium Priority
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?

Question by:corin_pearce
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 39

Accepted Solution

blue-genie earned 2000 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();


Author Comment

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...

Author Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

721 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