1
votes

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
}
2

2 Answers

0
votes

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

0
votes

its working:

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

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