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!
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
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!