A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: PLEASE help - Motion_Finish problem

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    69

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

    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");
    }

  2. #2
    Member
    Join Date
    Jul 2009
    Posts
    69
    ... pretty please ... with sugar on top ...

  3. #3
    Member
    Join Date
    Jul 2009
    Posts
    69
    giving myself a bump ... still trying to solve this. Any help appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center