[main.hx]
myAnim.playAnim(); //Anim.hx
//when done, ie after playAnim returned:
myMenu.Show(); //or addChild(myMenu);, etc
Actuate.tween(fadeBMP, 1, { alpha: 0 });
Actuate.tween(fadeBMP, 1, { alpha: 1 }).repeat(1).reflect(); //fade in, fade out
Actuate.....
Actuate.....onComplete(setDoneFlag);
while (!animOver) {
doEvents();
}
return; //playAnim() function is over, ie animation is done. playAnim() gives back
//control to parent, "myMenu.Show();" get's executed there
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
[main.hx]
myAnim.playAnim(); //Anim.hx
//when done, ie after playAnim returned:
myMenu.Show(); //or addChild(myMenu);, etc
why not code properly from the beginning?
On Fri, Sep 26, 2014 at 1:41 PM, wighawag <wigh...@gmail.com> wrote:
You could have a look at the following library : https://github.com/Atry/haxe-continuationI did not use it myself but it basically allow you to do what you want (using some metadata) and internally it will convert your code to use callbacks via macros)
On Fri, Sep 26, 2014 at 11:30 AM, Mark <markk...@gmail.com> wrote:
like I wrote, I want to use it like this:
[main.hx]
myAnim.playAnim(); //Anim.hx
//when done, ie after playAnim returned:
myMenu.Show(); //or addChild(myMenu);, etc
instead of having an onComplete callback, I want to wait for the animation to finish, and do nothing in the mean time
Just to provide another
perspective.
I do the following:
I like to use Furtures (from tink_core). So I have a “monax”
monad for Futures, that does exactly this:
Wait for a future to finish, than call the function that returns
the next one wait for it to finish e.t.c.
This has the advantage, that when of the “time taking” actions return a value, I can pass it to others in a convenient way.
Why futures? Because I
think they are more convenient, but it could also be done with
callbacks. Of course, all tween elements must be converted to
Futures, so if you only have tweens than I would use callbacks
(or in case of actuate IGeneralActuator) as it removes this
extra step.
So in kind of pseudo-code it looks like this:
FutureUtils.hx:
class FutureUtils {
static public function toFuture(actuator : IGeneralActuator) : Future<Noise> {
...
}
}
Then I do:
FutureMonad.Do({
doSomeAnimation().toFuture();
value <= someOtherFutureReturningAction():
doMoreAnimation().toFuture();
doValueDependingAnimation(value).toFuture();
...
});
Now, this might overkill
for your case. Just wanted to throw it in.
And of course I am happy to provide more detail if needed …
Regards,
Nathan