# TweenEvent dispatches not always happening

**URL:** <https://forum.kirupa.com/t/tweenevent-dispatches-not-always-happening/304208>\
**Category:** flash\
**Created:** [February 3, 2010, 12:13pm UTC](https://forum.kirupa.com/t/tweenevent-dispatches-not-always-happening/304208 "2010-02-03T12:13:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimjiminyjimjim](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jimjiminyjimjim](https://forum.kirupa.com/u/jimjiminyjimjim)\
**Post date:** [February 3, 2010, 12:13pm UTC](https://forum.kirupa.com/t/tweenevent-dispatches-not-always-happening/304208/1 "2010-02-03T12:13:31Z")

</div>

I found this post on the [Actionscript.org](http://Actionscript.org) forums about TweenEvent dispatches not happening consistently.

> I’ve come up against a similar problem in the past. The first thing to check is that the Tween instance does not go out of scope. For example (this is pseudo code)…

```auto
ActionScript Code:
private function doTween():void {
  var tween:Tween = new Tween(....);
  tween.addEventListener(TweenEvent.MOTION_FINISH, onFinished);
}

```

… will not work reliably - the tween instance goes out of scope when the function finishes (despite having an event listener attached to it) and I’ve found this unreliable. I make sure that the tween instance is always in scope:

```auto
ActionScript Code:
private var tween:Tween;
private function doTween():void {
  tween.addEventListener(TweenEvent.MOTION_FINISH, onFinished);
}

```

My question is this - where do I call this part

```auto

  var tween:Tween = new Tween(....);

```

is this what I’m meant to do:

```auto
ActionScript Code:
private var tween:Tween;
private function doTween():void {
  var tween:Tween = new Tween(....);
  tween.addEventListener(TweenEvent.MOTION_FINISH, onFinished);
}

```

As this doesn’t seem to make any difference. Thanks
