6 Replies Latest reply on Jun 11, 2007 12:00 PM by Damon Edwards

    Tween Class acting up

    smazr123
      Im getting some very odd effects with the Tween class, particularly with alpha tweens. Alpha tweens seem to be freezing up sometimes, but they won't always. When I put in the tween:

      function ani():void{
      var holderTween:Tween = new Tween(holder, "alpha", Strong.easeOut, 0, 1, 20, false);
      }

      It would often freeze, and then several of my other Tweens started to freeze. I thought maybe it was cause I was redeclaring the tween with the same variable name over and over (in the example above rerunning ani() before the first tween finished), the old tweens were being marked for garbage collection as they no longer had a referrence. Is this possible??? If so is there an easy way around that? Still doesnt explain why it would effect my other Tweens though. Is it cause im redeclaring the variable? would declaring the variable outside the function make a difference?
        • 1. Re: Tween Class acting up
          SymTsb Level 2
          Have you check the memory on the computer? Sounds to me like you've got one too many tweens on and because you are declaring them with the same name, you aren't able to kill them after the tween is finished. Memory Leak issue?
          • 2. Re: Tween Class acting up
            Damon Edwards Level 3
            in your code, however im not familiar with AS3, it looks like your alpha tweening from 0 (see through) to 1 (basically see through), maybe its a typo and you think it's freezing when its on it way to 100......
            if not, use below to start a new tween when one has finished
            function ani():void{
            var holderTween:Tween = new Tween(holder, "_alpha", Strong.easeOut, 0, 1, 20, false);
            holderTween.onMotionFinished = function() { //this is AS2, not familiar with AS3
            // new tween here ex: holder2Tween:Tween = new Tween( blah blah blah);
            }
            }
            • 3. Re: Tween Class acting up
              smazr123 Level 1
              in AS3 its from 0 to 1
              • 4. Tween Class acting up
                Damon Edwards Level 3
                ah, i see, quick question, what if you want 54% transparency. did you try only starting the new tweens once the original has finished with the onMotionFinished technique. btw, always use unique names.
                • 5. Re: Tween Class acting up
                  smazr123 Level 1
                  yeah, if you want 54% you put .54

                  I appear to have found a solution the the problem. I could have used whenMotionFinished, but I dont want to have to wait till then. If I use an array to keep track of the variouse tweens then I can stop the old ones before redeclaring new ones. I think I should be able to just delete them as well, but im just stopping them for the moment. I guess the garbage collection doesnt happen fast enouph... or it misses it cause they had the same name. It only seemed to happen when you repeated the same Tween class very quickly.
                  • 6. Re: Tween Class acting up
                    Damon Edwards Level 3
                    well, thanks for clearing that up.

                    im sure you were confusing flash by not giving unique names.. but it sounds like youre headed in the right direction. Good Luck!