Jump to content
Search Community

Massive use of TweenMax - Catastrophic Problems

Sephius test
Moderator Tag

Recommended Posts

I´m using a lot of features of TweenMax in flash game project like:

- Delay calls.

- Tween Proprieties and Variables.

- Tween call functions in onUpdate/onComplete/onStart feature

- Tween filters, color matrix and so on

- Scale around point

 

In some game features like:

- Apply/Remove/Animate effect

- Damage Controls Timers

- Auto Time Control in Status Effects

- Show/Hide/Animate Interfaces Arts

- Show/Animate Damage art Splashes and Damage Text

- Other Attributes Timers

- Other Object Animations

 

I have had huge problem that appear after i implement TweenMax for the animations in the game. The problem is:

 

- Tweens animations, delayed calls stop in the middle of the animation or do not call functions after time is complete (in case of delayed calls). Objects that are being animated simply stop with the last value before Tween freeze. There is no error shown in debug mode and the problem happen randomly making no distinction of witch Tween is being done. Generally, all Tweens that are going in a same particular time freezes together. After one or multiple Tweens freezes other tweens called after works normally. But objects they were being animated by a frozen tween never get updated again, some times even if a Tween is called again or other tween takes places.

 

Some examples:

   - Damage number appearing with damage splash stop in the middle of path and do no fade away with a code like that: 

 

TweenMax.to(spriteArt.container, 1, { startAt: { y:-30, dropShadowFilter:{color:0x000000, alpha:1, blurX:4, blurY:4, strength:5.5, distance:0} }, dropShadowFilter:{color:0x000000, alpha:1, blurX:4, blurY:4, strength:8.5, distance:0} , y:-105, alpha:0, ease:Back.easeIn, overwrite:false, onComplete:remove} );

 

- Yoyo animation of a filter (damage invulnerable effect) that make a object twinkle stop in a random value and never continue again with code like that:

DamageInvunerableTween = TweenMax.to(thisObjectArt, 0.15, { colorMatrixFilter: { colorize:"0xffcc66", amount:"0.3", contrast:"1.3", brightness:"1.3" }, ease:Quad.easeInOut, overwrite:false, repeat: -1, yoyo: true } );

 

- A interface element (like game over screen) do not appear or appear half transparent with code like that:

TweenMax.to (_movieClip, 2, {startAt: {alpha:0}, alpha:1, onUpdate:updateBitmap, onStart:setAnimating, onStartParams:[true], onComplete:setAnimating, onCompleteParams:[false]} );

 

- Some systems features stop to work when they use TweenMax for some reason (like delayedCalls):

 

applyStatus("ShieldDamaged", true);
TweenMax.delayedCall(time, removeStatus, ["ShieldDamaged", false]);

 

The big problem is the game simply do not work when player plays for more than few minutes because some of this freezes happen and broke the gameplay or some effect or some animation.

 

First, i though i was using TweenMax overly and then i reduce a lot the use and the creation of new tweens but make no difference. Some times there is a problem with other event Listners in the code like:

 

art.contentLoaderInfo.addEventListener(Event.COMPLETE, onSephiusArtLoaded); 

 

That make event.Complete or any other event not being dispatched and giving no error what so ever.

 

The most strange thing is there is no error appearing in debug when this things happen so there is no way to find what is happening. The Tween/Event simply stop or not happen.

 

I´m under lot of pressure because i should launch a demo for the project backers in 2 weeks and i still have no clue how to solve this catastrophic problem. 

 

I can give repository access if necessary to test and see in action the problem happening. 

 

Please help us!

Link to comment
Share on other sites

I can imagine how frustrating that is, after spending lots of time implementing TweenMax (which you probably heard was rock-solid) and then finding that things aren't working. I have good news and bad news...

 

First the good news (I think): TweenMax has been used in countless games including those from major brands (literally some of the biggest companies on the planet) with great success and I can't remember EVER coming across a case where it simply stopped working the way you're describing. Never. TweenMax has been hammered pretty hard by experts in memory management and it has been put under extreme pressure with many thousands of concurrent tweens and it came out rock solid (at least from everything I've heard). We're not aware of any bugs which doesn't mean none exist, but with SO many people using it usually bugs bubble to the surface quickly. 

 

Now the bad news: if TweenMax is pretty rock-solid (and again, that assumption could be faulty), it means the problem is somewhere in your code. More bad news: it's pretty much impossible for us to troubleshoot blind. If you could try to isolate the issue in a simplified FLA that we can publish on our end, that'd go a long way to helping us help you. We can't just dig into all your production code to do general troubleshooting because it takes a long time to read through all the code, figure out exactly what's happening, and isolate the issue(s). But if you can just create a separate FLA with only some basic code to reproduce the issue where things simply stop working, we'd LOVE to take a peek. Could you do that? 

 

Oh, and a few questions for you:

  1. What version of TweenMax are you using?
  2. Why are you setting overwrite:false so often? That can be a bit dangerous - TweenMax has a complex (and fast) overwriting algorithm built-in so that it helps avoid common problems where you create tweens that are competing with each other, trying to control the same property of the same object. That still wouldn't cause things to just stop working (especially delayedCalls), but I'm curious about the logic behind overwrite:false in your particular case. 
  3. Are you loading external assets at the time that things stop working? I wonder if there's an error related to the loading that's causing issus. 
Link to comment
Share on other sites

I indeed found a error in the code, that in some cases call a function that in some cases call a TweenMax.KillAll().

I believe this TweenMax function stops and kills ALL tweens running in the system altogether right? I solve this issue but i need more testing to make sure the problem was gone.

About your the questions:

- I fist used the V11 and then the V12. In both versions the problem occurred.

- I using overwrite:false because i need to multiple Tweens to control multiple filters in a same object. For example: A certain status (damaged) applies a colorMatrixFilter when active and other status (frozen) apply a bevelFilter. A object could be frozen and take damage same time, so it need to be animated by both Tweens at same time. Some status apply a same kind of filter at same time (like color effects). The problem i had is when a status actives, a animation from other Tween used to be stopped or replaced by the most recent one. I know that is a complicated issue, i´m trying now to not use a same filter or proprieties for status that can be activated same time in the game.

- The game loads external assets constantly. But is hard to see if when a problem happen a asset was loaded at the very same time. Some times, there is a problem related with a Event.Complete no be dispatched even if a asset was fully loaded (all bytes loaded), with no error happening whatsoever. This stop to happen when i reduce the volume of tweens created and start to call Carbage Collection in some key times. Because that, i thought the problem could be about the number of listeners existing in the system at a same time. Is there a know flash limitation about that? I mean, when there is a lot of event listeners existing same time and flash loose the ability to deal with then? A important aspect is the game use a lot of memory. Assets are very memory expensive. Lot of animations loaded and unloaded frequently.


Some other questions:

- What is best? Create TweenMax vars and call then to restart/play/pause or simply call TweenMax tweens functions when i need a tween to happen (consequently creating a new tween every time the function is called).

- There is a simply way to remove a filter applied by a endless yoyo tween when i call this tween to stop or reverse? (I want the filter to be applied when tween start and be removed when code says to stop). As there is a lot of different tweens instances going on in the game is kind annoying control then individually. In the other logic used, tweens was created every time a status actives (not using instances), in that way was easier to call a remove propriety when status goes out. One of the problems with persistent filters is that flash does not render blending modes inside a movieclip when this movieclip has a filter applied to it.

- It is possible to create a instance of a tween but the tween´s target be a dynamic var? I mean, i have a same tween instance and use this instance to animate multiple targets in different times. Or i always need to have a single tween for a single object? I don´t mean cases when there is multiples objects animated same time, but objects animated independently.

Well, that is...

Link to comment
Share on other sites

You shouldn't have to set overwrite:false based on what you're describing (unless you're only using v11 TweenLite, haven't loaded TweenMax, and haven't set OverwriteManager's mode to "auto", but it looks like you're using TweenMax so it shouldn't be an issue). In v12 (and in v11 TweenMax), the default overwrite mode is "auto" which means that ONLY the specific overlapping properties are killed (not the entire tween). So, for example, if you're doing a blurFilter tween and then halfway through you start a colorMatrixFilter tween, it won't kill/overwrite the first one. My advice would be not to set overwrite:false in the VAST majority of cases. 

 

 

What is best? Create TweenMax vars and call then to restart/play/pause or simply call TweenMax tweens functions when i need a tween to happen (consequently creating a new tween every time the function is called).

Typically it's easiest to just create a new tween each time. The engine is very good at cleaning up after itself and new instances aren't very expensive. However, if you're talking strictly about pure performance, it's probably SLIGHTLY faster to reuse instances. I doubt you'd see any real-world difference unless you're literally managing thousands of simultaneous tweens. 

 

 

There is a simply way to remove a filter applied by a endless yoyo tween when i call this tween to stop or reverse? (I want the filter to be applied when tween start and be removed when code says to stop). As there is a lot of different tweens instances going on in the game is kind annoying control then individually. In the other logic used, tweens was created every time a status actives (not using instances), in that way was easier to call a remove propriety when status goes out. One of the problems with persistent filters is that flash does not render blending modes inside a movieclip when this movieclip has a filter applied to it.

Sure, you can set remove:true inside the filter vars to have it removed at the end of the tween, like:

 

 

TweenMax.to(... {blurFilter:{blurX:10, remove:true}});

 

And if you want to remove them all immediately, you can either manually set the filters array to a blank array or use TweenMax like this:

 

 

//fastest/easiest way to remove all filters
myDisplayObject.filters = [];
 
//to target individual ones:
TweenMax.set(myDisplayObject, {blurFilter:{remove:true}, colorMatrixFilter:{remove:true}});

 

 

 

It is possible to create a instance of a tween but the tween´s target be a dynamic var? I mean, i have a same tween instance and use this instance to animate multiple targets in different times. Or i always need to have a single tween for a single object? I don´t mean cases when there is multiples objects animated same time, but objects animated independently.

No, you cannot alter the tween's target because things get recorded internally that are very specific to that target (like starting values and registering the tween to that target for overwriting lookup purposes, etc.) 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...