# Interrupted Tweens

**URL:** https://forum.kirupa.com/t/interrupted-tweens/315805
**Category:** flash
**Created:** [November 4, 2010, 3:56pm UTC](https://forum.kirupa.com/t/interrupted-tweens/315805 "2010-11-04T15:56:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![laira1](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@laira1](https://forum.kirupa.com/u/laira1)
#### Post date: [November 4, 2010, 3:56pm UTC](https://forum.kirupa.com/t/interrupted-tweens/315805/1 "2010-11-04T15:56:41Z")

</div>

I’m writing a Think Fast program to teach myself Actionscript, and running into a problem. I’ve written a function to get 3 bars to tween in, one after the other. This is working well, except due to the nature of a think fast game, sometimes time expires while the tweens are still running, and everything gets all gummed up.

Since the tweens need to happen one after the other, I call them inside a function, which means, as far as I understand it, that their variables aren’t accessible by other functions. Any advice for figuring out how to stop tweens inside a different function if the tweens are still running? Or am I just doing it all wrong?

Here’s the tween code

```auto
function questionTween()
	{
		next_b.mouseEnabled = false;
		next_b.visible = false;
		shade1.x = originX;
		shade2.x = originX;
		shade3.x = originX;
		sndChannelAlive = sndWhoosh.play();

		var shade1Tween:Tween = new Tween(shade1,"x",Strong.easeOut,originX,233,tweenSpeed,true);
		shade1Tween.addEventListener("motionFinish", finishedTween1);

		function finishedTween1(event:Event):void
		{
			shade1Tween.removeEventListener("motionFinish", finishedTween1);
			sndChannelAlive = sndWhoosh.play();
			var shade2Tween:Tween = new Tween(shade2,"x",Strong.easeOut,originX,233,tweenSpeed,true);
			shade2Tween.addEventListener("motionFinish", finishedTween2);

			function finishedTween2(event:Event):void
			{
				shade2Tween.removeEventListener("motionFinish", finishedTween2);

				var shade3Tween:Tween = new Tween(shade3,"x",Strong.easeOut,originX,233,tweenSpeed,true);
				shade3Tween.addEventListener("motionFinish", finishedTween3);
				sndChannelAlive = sndWhoosh.play();

				function finishedTween3(event:Event):void
				{
					shade3Tween.removeEventListener("motionFinish", finishedTween3);

					timetxt.visible = true;
					enable_disable(1);
					fl_CountDownTimerInstance.start();
					if (difficultyLevel == 5)
					{

					}
					else
					{
						next_b.visible = true;
						next_b.mouseEnabled = true;
					}
				}
			}
		}

	}

```
