On the code below, after “shrinkCard” tween is complete (MOTION_FINISH), the “flipGraphic” event should be executed before the next function “expandCard”. That way the switching of the image wouldn’t be visible. Currently, “flipCard” is not happening until after the second tween is completed (instead of after the first). What am I doing wrong?
next_btn.addEventListener(MouseEvent.CLICK, clickNext);
prev_btn.addEventListener(MouseEvent.CLICK, clickPrev);
stage.addEventListener(KeyboardEvent.KEY_UP, pressNext);
var shrinkCard:Tween;
var expandCard:Tween;
var shrinkCardP: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_FINISH, flipGraphic);
}
function expand():void{
var expandCard:Tween = new Tween(container, “scaleX”, Strong.easeOut, -1, 1, 1, true);
}
function shrinkPrev():void{
var shrinkCardP:Tween = new Tween(container, “scaleX”, Strong.easeOut, container.scaleX, -1, 1, true);
shrinkCardP.addEventListener(TweenEvent.MOTION_FINISH, flipGraphicP);
}
function clickNext(event:MouseEvent):void
{
shrinkFront();
expand();
}
[COLOR=Gray][/COLOR] function flipGraphic(e:TweenEvent):void {
trace(“card shrunk”);
c.nextFrame();
c.stop();
if(c.currentFrame == c.totalFrames){
c.gotoAndStop(1);
}
}
function clickPrev(event:MouseEvent):void{
shrinkPrev();
expand();
}
function flipGraphicP(e:TweenEvent):void {
c.prevFrame();
trace(“prev clicked”);
}
function pressNext(event:KeyboardEvent):void
{
shrinkFront();
expand();
}