View Full Version : tween execution problem
lope
January 8th, 2009, 04:52 PM
why does sometimes some tweens stop in the middle of their execution and how to manage that?
thank you!
GrndMasterFlash
January 8th, 2009, 05:13 PM
are you using more than one tween on the same tween instance?
if you assign the tween to multiple objects you can confuse it, instead make a copy every time and point your object to it.
creatify
January 8th, 2009, 05:13 PM
why does sometimes some tweens stop in the middle of their execution and how to manage that?
thank you!
short answer, avoid Adobe's Tween class and use TweenLite instead - can google it. That is a known issue with the Adobe Tweens, I don't believe it's really a bug, but just the way they tend to work in relation to the Event system. Search the AS3 forum here for things like "tweens stop", "tween problem" etc.
Hope this helps.
lope
January 9th, 2009, 06:11 AM
are you using more than one tween on the same tween instance?
i dont realy know :D
part of my code looks like this:
http://pastie.org/356443
i have heard of tweenLite and will start using it as sonn as i learn how to :P
but aside from that i was thinking the problem why some tweens stop and some URLLoaders wont execute was due to "garbage collection"
i definitely have to learn more about that :D
efos
January 9th, 2009, 02:21 PM
I've used a similar setup, where
function fnTween(target,n1,n2,n3){
var twnName1:Tween = new Tween (target, "blah",blah,blah+n1,5,false)
var twnName2:Tween = new Tween (target, "prop",prop,prop+n2,5,false)
var twnName3:Tween = new Tween (target, "stuff",stuff,stuff+n3,5,false)
}
this action was looped, when the target stopped moving, it would get new instructions and move again, and I had multiple tweens on many targets. Now, these targets could go tweening all over place for a while, but occaisionally one or several or all of them would randomly stop.
I resolved the issue by classing it out and making the tween an inherent property of that object, instead of creating in the function and just releasing it into the aether. It worked because as far as I can tell, while floating around the AS3 aether waiting for garbage day, these little "twnName"s would sometimes bump into each other and get their references crossed; or get pulled back to earth and reassigned to a new target, halting whatever they were previously doing.
Whatever the reason, making the tweens internal to the object they were tweening resolved my issues.
greensock
January 11th, 2009, 06:19 PM
It worked because as far as I can tell, while floating around the AS3 aether waiting for garbage day, these little "twnName"s would sometimes bump into each other and get their references crossed; or get pulled back to earth and reassigned to a new target, halting whatever they were previously doing.
No, the issue actually had to do with the fact that when you declare a variable inside a function (starting with "var"), you're creating a local variable. Local variables inside functions are only available inside that function, but when the function finishes running, they become eligible for garbage collection, a process which disposes of unreferenced objects/variables at unpredictable intervals. When garbage collection occurs, it looks for objects that don't have references "pointing at" them, and if it finds any, it removes them from memory. If you store references to your Tweens from inside a class (or on the timeline or somewhere that's still "plugged in" to the application), it'll protect them from getting garbage collected.
TweenLite maintains references to active tweens internally, so you don't have to worry about that issue.
GrndMasterFlash
January 12th, 2009, 03:06 PM
greensock!!!
you rule!
dail
January 12th, 2009, 03:59 PM
Yes, the main issue with the Adobe Tween Class is local references to any tween instance are garbage collected.
If I'm using that Tween Class, and am likely to use lots of local tween instances I push each instance into an array which has been declared at a more 'global' scope. Then simply add a complete listener to each tween, and when it completes, remove the instance reference from the array. Works well. I also wrote a "tweenManager" class to get around it.
But, in the end, tweenlite is a hell of a lot better.
Wonder if Grant Skinners new tween engine will end up in CS5, his classes, products etc have a habit of ending up in Flash.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.