Closed DigiEggz closed 3 years ago
What's the use case for that, does a TransitionEffect
finish multiple times?
What's the use case for that, does a
TransitionEffect
finish multiple times?
If you try to chain another finishCallback after its first callback, it won't execute because it's been nulled. As a pseudo-code example:
transition.finishCallback = firstFunction;
function firstFunction()
{
// ...
// This callback will not be executed
transition.finishCallback = secondFunction;
transition.start();
}
function secondFunction()
{
// ...
}
Hm, I see, so you're actually using this class directly. I assume the vast majority of people only use it via FlxTransitionableState
.
In any case, the behavior still seems a bit odd, what if you want to use the same function as a callback again? Setting the field to null before invoking the function (and temp-var-ing it so you can still call it) would solve that.
Hm, I see, so you're actually using this class directly. I assume the vast majority of people only use it via
FlxTransitionableState
.In any case, the behavior still seems a bit odd, what if you want to use the same function as a callback again?
I was having trouble thinking of a reason someone might set a callback to the same callback function. Another solution that worked was to only null
if the _endStatus
is FULL
(i.e. the transition is no longer visible).
In my scenario, I fade in to black, run some code and set finishCallback
to a cleanup function and then fade out, but the cleanup isn't called once the fade out completes.
Could you give an example of your suggestion? That may solve my particular problem.
I was talking about an alternative implementation of the PR, something like:
var callback = finishCallback;
finishCallback = null;
callback();
Ahh, I misunderstood. I tested your suggestion and that was also working well.
When changing finishCallback within an initial callback function, the new callback is set to
null
and erased on execution. This prevents that scenario by checking if the current callback is the same as the previously executed callback.