Solved

Stopping a running Tween class

Posted on 2009-07-07
3
391 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
[X]
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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

751 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