views:

223

answers:

2

I've got the following issue with a actionscript3 project.

I have a group of buttons setup via a class sitting in a holder sprite.

When I rollover one of these buttons I loop through all the buttons in the holder and run tweenlite to tween the alpha to .4 except when the name matches the currently active button.

When I rollout I reset all the buttons back to alpha 1 again via a tweenlite tween.

This works fine in most of the time. the issues i have are as follows:

  • when i roll from one button straight to another there is a lot of flickering
  • sometimes when i roll to another button it fades in then out again
  • i have a case when instead of returning all the buttons to alpha 1 i need to return them to an initial state alpha.

i have tried using tweengroup but this doesn't seem to help either.

let me know if you need any more details. the code is intergrated into a lot of other stuff which is why i haven't posted it but if needed i can put something together.

thanks.

Josh

+1  A: 

IMO, you should create a class for those buttons, that maintains the state internally ... so from outside, you only call two methods, let's say fadeDown and fadeUp, on the Buttons ... the Buttons themselves know, what their alhpa is, if there is a tween running etc. ... the will always kill their own tween (or simply continue, if it is the right tween) ... and then start the right animation to get to the right visual representation of their internal state ... you might consider using the state pattern for that matter ... to keep your code clean ... (simply use private classes not to end up having too many files) ...

also, a good thing about this is, that the animation is seperated from the logics, so you can easily reuse the button outside of the context of the logic, and/or change the animation concept (e.g. blur the buttons instead of fading them down) withouth any influence on the logic ...

hope this helps ... ;)

back2dos
A: 

To avoid the flickering, you can use a little delay on the tweens and let them overwrite each other (check on TweenLite page)

To the problem to returning them to an initial alpha, a simple if wouldn't work?

kajyr