Text Input from User help?

  • Hi everyone,

    I'm a newbie in programming in general, and in haxeflixel in particular. I need users to input text (just their names) by typing. I know that both FlxUIInputText and openfl.text.Textfield can be used for this purpose, but I'm completely lost as to how to proceed. I can create the text field alright with FlxUIInputText, but I can't seem to be able to do anything else beyond that. I was wondering if there are any tutorials or examples I can use to guide me in how to do it, because I'm completely new to this, and I've been unable to find any examples. I assume it's really simple, but I'm really new to programming and need a lot of help.
    Thanks in advance!

  • administrators

    Here's a simple example of a PlayState that "does something" with the text that has been entered. It traces it to the console when the "Submit" button is pressed (I'd assume you'd have a button like that on an "enter name" screen).

    import flixel.FlxState;
    import flixel.addons.ui.FlxUIInputText;
    import flixel.ui.FlxButton;
    class PlayState extends FlxState
    	override public function create():Void
    		var inputText = new FlxUIInputText();
    		var submitButton = new FlxButton(0, 0, "Submit", function() {
    			trace("Text is " + inputText.text);
    		submitButton.y += 25;

  • @Gama11 Thanks a lot, this is very helpful!!

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.