'onComplete' callback [solved]
-
Hi, I must be doing something wrong here. I'm trying to add a callback to a FlxSound's loadEmbedded:
var introSound:FlxSound = new FlxSound(); introSound.loadEmbedded(introName, false, false, onCompleteIntro(player)); introSound.play(); [....] private function onCompleteIntro(player:FlxSprite):Void { [...] }
But it's giving me this error, and I don't understand why:
Void should be Null<Void -> Void>
Void should be Void -> Void
For optional function argument 'OnComplete'Anybody knows what am I doing wrong?
Thanks!
-
You're supposed to
bind()
, you were calling the function henceVoid
introSound.loadEmbedded(introName, false, false, onCompleteIntro.bind(player));
-
Thanks! It's working now!
Here is some more information I found, if somebody is having the same problem:
http://haxedev.wikidot.com/article:function-types
-
It's also documented in the official Haxe manual: Function Bindings