A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Why are my tweens sticking?

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    9

    Why are my tweens sticking?

    Hi there,

    I have a file with tweens created in the code. The file worked fine most of the time. But sometimes for no apparent reason the tween would stick at some random point through its execution. It was a small problem at first. But the more content my file has, the more it's happening and now I'm lucky if it doesn't stick!

    I'm loading a lot of images in externally (not with xml just with the loader class for now). I thought this would ease the problem but if anything it's becoming worse with the extra content that's added.

    What causes code tweens to stick part way through? Can anyone help?

    I've attached a test .fla so you can see what's going on. The test is sticking far less than my real file but it does still do it and it's exactly the same code.

    I'm totally baffled by this - Thanks for any help in advance!
    Attached Files Attached Files
    Last edited by rawtiger; 07-20-2009 at 06:39 AM.

  2. #2
    i am here
    Join Date
    Jan 2009
    Posts
    17
    Hey man your fla does not open on my machine.

    xshanky

  3. #3
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Without even looking at the file or any code, I can guarantee you're using the built in Tween class, and calling it like so:

    new Tween(...);

    That right there, is the problem. The Tween object isn't assigned to a variable, so it's marked for garbage collection right away. Your tween ends when garbage collection has thrown it away, which happens randomly.

    First remedy is to assign the tween to a variable like:

    var t:Tween = new Tween(...);

    The second, and better way, is to use a different tweening engine all together. My suggestion is TweenLite. http://tweenlite.com

  4. #4
    Junior Member
    Join Date
    Jun 2009
    Posts
    9

    re-upload of file...

    Hi,

    Sorry about that, the .fla was corrupted somehow - that's why it was so small.. I can't get it to below 300kb so I'll post the code instead

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

    import flash.events.TimerEvent;
    import flash.utils.Timer;


    //-----------Set up a timer to disable the clicks while the movieclip is in motion-------------------------------------------



    var inMotion:Boolean = false;
    var minuteTimer:Timer = new Timer(1000, 1);

    minuteTimer.addEventListener(TimerEvent.TIMER_COMP LETE, onTimerComplete);


    function onTimerComplete(event:TimerEvent):void
    {
    inMotion = false;
    }


    //-----------Cross Pad Code for moving from item to item----------------------------------------------------------------------



    xPad_mc.btnDown.addEventListener(MouseEvent.CLICK, onDownClick);



    function onDownClick(event:MouseEvent):void
    {
    if(inMotion == false && collection_mc.y >= 120)
    {
    var tweenDown:Tween = new Tween
    (collection_mc, "y", Strong.easeOut, collection_mc.y, collection_mc.y -=190, 1, true);
    highlight_mc.gotoAndPlay("down");
    minuteTimer.start();
    inMotion = true;
    }
    }



    MyFriendIsATaco - thanks for the reply! Yes I am using the tween class like that. I'm still learning AS3 and I'm not up to scratch on the best ways to go about things yet.

    I'm gonna give that a go & let you know how I get on!

    Thanks

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