FlxUICheckBox usage
-
How do I use the checkbox? I don't understand how to use the params array. I want to be able to get the checked value in the callback function when it's changed.
var chkVibrate = new FlxUICheckBox(0, 0, null, null, "Vibrate", 100, [], vibrateChanged); add(chkVibrate);
function called
private function vibrateChanged():Void { // I want to use the checkbox checked value }
-
I can do this, but is there a way to pass the checked value to the function?
private var _chkVibrate:FlxUICheckBox;
_chkVibrate = new FlxUICheckBox(16, 144, null, null, "Vibrate", 100, [], vibrateChanged); add(_chkVibrate);
private function vibrateChanged():Void { trace("vibrateChanged = " + _chkVibrate.checked); }
-
Maybe you can
bind()
_chkVibrate = new FlxUICheckBox(16, 144, null, null, "Vibrate", 100, [], vibrateChanged.bind(_chkVibrate); add(_chkVibrate);
private function vibrateChanged(chkVibrate:FlxUICheckBox):Void { trace("vibrateChanged = " + chkVibrate.checked); }
-
Thank you! I didn't know about bind.
Actually, it didn't work in one line, but this works
_chkVibrate = new FlxUICheckBox(0, 0, null, null, "Vibrate"); _chkVibrate.callback = vibrateChanged.bind(_chkVibrate);