3 Replies Latest reply on May 21, 2007 2:41 PM by nudnic

    Dispose of a Tween

    Rothrock Level 5
      So I have a clip in my library set to export as "sample" and then this code. (AS2, published for Flash 8, although if there are differences in the AS3 Tween class I would like to hear about it.)

      There doesn't seem to be an explicit method for removing or deleting tweens. It seems that doing a Tween.stop(); and then delete scope.Tween; works.

      My guess is that internally tween is using the onEnterFrameBeacon and some addListener. When you stop, there is some removelistener, and while the tween instance still exists it will be removed with the removeMovieClip.

      Is that it? Is there anything more I should be aware of.
        • 1. Dispose of a Tween
          nudnic
          I tried this and it doesn't seem to work for me.

          I have a class that loads an image and resizes a masking movie clip to the size of the loaded image. I used the Tween class to animate the resizing.

          I have several buttons set up to load various images. Clicking a button to load a new image before the current Tween has finished resizing causes problems. The first Tween seems to continue and the image jumps to the size of the second image suddenly.

          It seems to me that the first Tween is continuing and does not get removed.

          I can post my class file if you are interested.
          • 2. Re: Dispose of a Tween
            injpix Level 3
            According to XRAY I am able to see the OnEnterFrameBeacon when the Tween instance is created. XRAY is giving its instance name “__OnEnterFrameBeacon”. So I am not sure if you explicitly delete that if it will help or be harmful. Perhaps you can ‘null’ your tween instance, ‘tween0’. But I would assume that the FlashPlayer’s garbage collector would remove it.
            • 3. Re: Dispose of a Tween
              nudnic Level 1
              I'm not sure what's happening, but it seems that when I create a second Tween both Tween's are still running. I can't seem to get rid of Tween.

              The onEnterFrameBeacon seems to be a movie clip in the _global layer that Tween subscribes to for onEnterFrame messages. Tween adds itself to it's own listener list and to the listener list of onEnterFrameBeacon. I'm guessing that a Tween would need to be removed from both listener lists.