PLEASE help - Motion_Finish problem
In this code, I have two tweens that complete the process of turning a card over (using scaleX). However, between the first and second tween, I've set up a function to run at Motion_Finish of the first tween (basically shifting the movieclip to the next frame to change the "face" of the card to another image). The problem is that when I run it, the "face" doesn't change until BOTH tweens are completed, which looks pretty awkward. What's wrong?
Here's the code....
Quote:
next_btn.addEventListener(MouseEvent.CLICK, clickNext);
prev_btn.addEventListener(MouseEvent.CLICK, clickPrev);
var shrinkCard:Tween;
var expandCard:Tween;
var shrinkCardB:Tween;
var c:MovieClip = new Card;
var container:MovieClip = new MovieClip;
container.x = stage.stageWidth/2;
container.y = stage.stageHeight/2+50;
c.stop();
container.addChild(c);
addChild(container);
function shrinkFront():void{
var shrinkCard:Tween = new Tween(container, "scaleX", Strong.easeOut, container.scaleX, -1, 1, true);
shrinkCard.addEventListener(TweenEvent.MOTION_FINI SH, flipGraphic);
}
function expand():void{
var expandCard:Tween = new Tween(container, "scaleX", Strong.easeOut, -1, 1, 1, true);
}
function shrinkBack():void{
var shrinkCardB:Tween = new Tween(container, "scaleX", Strong.easeOut, container.scaleX, -1, 1, true);
shrinkCardB.addEventListener(TweenEvent.MOTION_FIN ISH, flipGraphicB);
}
function clickNext(event:MouseEvent):void
{
shrinkFront();
expand();
}
function flipGraphic(e:TweenEvent):void { //this doesn't work either ... flipGraphic["onMotionFinished"] = function(){
trace("card shrunk");
c.nextFrame();
c.stop();
if(c.currentFrame == c.totalFrames){
c.gotoAndStop(1);
}
}
//flipGraphic["onMotionFinished"] = function(){
function clickPrev(event:MouseEvent):void{
shrinkBack();
expand();
}
function flipGraphicB(e:TweenEvent):void {
c.prevFrame();
trace("prev clicked");
}