TwelvestoneFlash

AS3 Pratfalls: Tween doesn't finish sometimes


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
DontBogartMe
 
2008-12-08

if you find that your tweens sometimes don't finish, but sometimes they do, then the cause might be the automatic garbage collection. For instance if you're setting up the tween in a class method, and storing hte Tween in a local variable, or not storing it at all, then once that method finishes the garbage collector considers that tween to be done with and may well delete it - or not, sometimes.

So to prevent this from happening, store the tween in a class variable instead - that way it will always be in scope that the GC won't touch it, and it will be left alone to finish the tween.

lithium
 
2008-12-08

i don't see how this could be the case for an object that's on the display list. I'm positive that garbage collection would ignore anything that is visible to the user until such times as it (or its parent) is removed from the stage.

DontBogartMe
 
2008-12-09

it's certainly not what you expect to happen, but that's the way it seems to be - I found this out from other people's blogs and so on, so it's not just me.

lithium
 
2008-12-09

I would definitely maintain that the problem lies with the particular Tween class being used and not the garbage collection of the stage items.

DontBogartMe
 
2008-12-09

it's garbage collection of the tween I think that does it. e.g. here's my code that was having trouble:

    private function showContentCloseButton():void {            
        var mcCloseContentButton:MovieClip = MovieClip(ldrCloseContentButton.content);
        ldrCloseContentButton.visible = true;
        if (mcCloseContentButton.getChildByName("closeButton")) {
            mcCloseButton = MovieClip(mcCloseContentButton.getChildByName("closeButton"));

            mcCloseButton.buttonMode = true;
            mcCloseButton.addEventListener(MouseEvent.CLICK, handleCloseContentButtonClick);
            mcCloseButton.x = (ldrContent.x + ldrContent.width) - mcCloseButton.width;
            mcCloseButton.y = ldrContent.y - mcCloseButton.height;


            // ======================
            // Here's the Tween...

            var tempTween:Tween = new Tween(mcCloseButton, "y", Elastic.easeOut, mcCloseButton.y + 40, mcCloseButton.y, 1.5, true);
            // ======================
        }
    }

and to fix the problem I created a class property to store that Tween in, and it stopped canceling the tween - is there another explanation for my problem do you think?

DontBogartMe
 
2008-12-09
Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

AS3 Pratfalls: Tween doesn't finish sometimes