Skip to main content
paul_james123
Inspiring
January 12, 2014
Answered

Tween event listener not working

  • January 12, 2014
  • 3 replies
  • 797 views

Hi,

In a frame script I have an event listener that should call the 'onFinish' function when the tween motion is finished. (See pertinent parts in red below.) I never see that 'done tweening' output. It fails silently. I've tried the addEventListener in different places.. to no avail. What am I missing?

Thanks!

import fl.transitions.*;
import fl.transitions.easing.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;

var currentFrameMC = animImg;

var scaleXTween:Tween=new Tween(animImg,"scaleX",Bounce.easeOut, 1,2,2.4,true);
var scaleYTween:Tween=new Tween(animImg,"scaleY",Bounce.easeOut, 1,2,2.4,true);
var alphaTween:Tween = new Tween(animImg, "alpha", Strong.easeOut, .5, 1, 11, true);

//Put a listener on the MC so I can tell when it's done tweening the scale.
currentFrameMC.addEventListener(TweenEvent.MOTION_FINISH, onFinish);


//This is another event listner put on a button:
//(The button, when clicked, will trigger the shrinking of the animImg MC)
reverseTween1.addEventListener(MouseEvent.CLICK,shrinkFrameMC);

//Shrink/scale down the anImg by tweening
function shrinkFrameMC(e:MouseEvent)  //This scales down the playing movie clip

scaleXTween=new Tween(currentFrameMC,"scaleX",None.easeNone, currentFrameMC.scaleX,1,3,true);
scaleYTween=new Tween(currentFrameMC,"scaleY",None.easeNone, currentFrameMC.scaleY,1,3,true);
//Tween the alpha state of the movie clip again, this time in reverse
alphaTween=new Tween(currentFrameMC, "alpha", Strong.easeOut, 1, .5, 11, true);
}


function onFinish(e:TweenEvent):void //This does an action when the frame MC is done tweening
{
   trace ("done tweening" );
   //NEVER SEE THIS OUTPUT
}

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Ned Murphy

You need to assign the Tween event listener to the Tween, not the object being tweened.

3 replies

Ned Murphy
Ned MurphyCorrect answer
Legend
January 12, 2014

You need to assign the Tween event listener to the Tween, not the object being tweened.

paul_james123
Inspiring
January 12, 2014

oops. Thanks, Ned!

Ned Murphy
Legend
January 12, 2014

You're welcome Paul.