Error with the "Hello World" tutorial.

  • @dean Yeah, even when setting it to a file in my documents folder, it still has the error of "'code' is not recognized as an internal or external command, operable program or batch file."

    And yes, I do have a Main.hx, which is located in the source file.

  • @dean You know what, dean, I think the problem is me taking an impact to the head a few years ago. Literally checked the tutorial and missed a key detail. Goes in PlayState.hx, instead of Main.hx (I'm used to C++ and Java, which allows me to put large amounts in the Main class.) (...and for some reason those two files didn't generate anyways. :s)

    While it doesn't answer the weird error of 'code' not being recognized, it does work now.

    (Oddly enough, some of the demos are non-functional, with errors such as "source/PlayState.hx:3: characters 7-41 : Type not found : flixel.addons.ui.FlxUIButton", and "source/Main.hx:6: lines 6-13 : Defined in this class")

  • @vulpicula

    At least you got it working. If it helps, you can download all the demos from github and they all have the flashdevelop.hxproj file.
    and you should be able to open the .hxproj file.

  • administrators

    @vulpicula Don't worry about the 'code' not being recognized error. That's flixel-tools trying to launch Visual Studio Code via the code command after creating the template. You can tell flixel-tools which IDE to use during setup (run flixel setup). There also won't be a FlashDevelop .hxproj file if you have the default configuration (which defaults to VSCode).

  • administrators

    @vulpicula I just released flixel-tools 1.4.1 on haxelib, which adds some output that should make it more obvious what flixel-tools is doing when running template or create commands. :)

  • Odd. Even after setting it to use FlashDevelop via the setup, it still insists on running it for Visual Studio Code. (Or more specifically, it defaults to that every time I restart the CMD.)

  • This post is deleted!

  • Aside from that, everything seems to be working. Thank you so much. ^^

    Also, on the "Groundwork" tutorial, I think you forgot to mention that you need to add 'import flixel.FlxG;"
    I know it's supposed to do it automatically, but for some reason it's not doing that on my PC.

    I do have a few other questions, but they're mainly just "How do I do this?" rather than something not working.

  • @vulpicula

    This cheat-sheet has a few examples of common things.

    I found it helpful to check out the demos and try things with the code to see how things work.

  • @dean I've been doing that so far. A bit of splicing code in and out as well has helped a ton. I don't quite understand some of the code behind it, but I'm starting to understand what does what.

    Only question I'm struggling with, is "How do I add a text field so the user can type something in, that then gets saved to a string?"

  • @vulpicula

    You'll need to use flixel-addons for that.

    enable flixel-addons in Project.xml

    <haxelib name="flixel-addons" />

    Then import this in the class you want to use it in.

    import flixel.addons.ui.FlxInputText; 

    Define the input textbox as private var so you can use it in other functions in the class.

    private var _inputText:FlxInputText;

    Create and add it in create()

    _inputText = new FlxInputText();

    Now whatever gets typed in the box is accessed with
    _inputText.text which is a string that you can use or save in some other function.

  • @dean Thank you! I would've been unable to figure that out on my own most likely.

    Only thing I'm confused about, is why things like enter won't get it to save the string or so.

  • @vulpicula

    Here's some example.

    _inputText = new FlxInputText(10, 10, 100, "Test", 10, 0xFF00FFFF, 0xFF333333);
    _inputText.setFormat(null, 8, 0xFF00FFFF);
    _inputText.setPosition(100, 100);
    _inputText.maxLength = 16;
    _inputText.fieldBorderColor = 0xFFFFFF00;
    _inputText.backgroundColor = 0xFF333333;
    _inputText.fieldBorderThickness = 3;
    _inputText.fieldWidth = 200;
    _inputText.caretColor = 0xFFFF9900;
    _inputText.scrollFactor.set(); // keep it from scrolling with the camera
    // use the callback to save the text when ENTER is pressed
    _inputText.callback = inputTextCallback;

    use the callback function to save, etc.

    private function inputTextCallback(text:String, action:String):Void
    	// this is called when the text changes or ENTER is pressed.
    	// text is the text in the textbox
    	// action is one of these: "input" "delete" "backspace" "enter"
    	// when enter is pressed you can save
    	if (action == "enter")

  • @dean

    Got it. I assume I can then take the trace text and write that to a string.

  • @vulpicula

    text is a string and you can do whatever you want with it :) But that's how you get it with the callback.

  • @dean Awesome! One question, though.

    This is actually something I've never been able to do in 'any' programming language. I've always been pretty horrid when it comes to multi-class objects, (in C++ I did the horrible thing and used global ints.)

    How would I, be able to take the string that was generated via the input in that class, and use it in another?
    First attempt revolved around trying something like "private var charName:NameSelectState;" but that doesn't seem to work. Searching around results in nothing. >.<

    If it's impossible, I'll just see if I can find a weird way around it.

  • @vulpicula

    You can define it public static var myVar:String and it will be available in other classes. Or you can pass it to another class as an argument through the new() constructor.

    public static var myInputText:String;

    Whatever class you define it in, let's say you define it in PlayState, you access from other classes with


    Usually I keep these static vars in Reg.hx and then access them anywhere with


    public static function myFunction() works the same way. Use it in other classes with


    If you want to pass it as an argument to a class it won't need to be public static.

    private var _inputString:String;
    public function new(inputString:String) 
    	_inputString = inputString;

    and _inputString is available in the class you passed it to.

  • @dean Awesome. And I assume, in theory, if I wanted to at one point change the string, I could just drop the "static" part from the variable creation thing?

    Got it. ^^

    Hopefully this doesn't have the same error as C++, where it'd behave strangely.

    (Such as in, if I set an integer like this to 5 in one class, it'd only show 5 in the class I changed it to, and not show the change in any of the other classes, if that makes any sense.)

  • @vulpicula

    well, static allows access with MyClass.myVar and it is static.

    If you make it public var myVar:String without static, then you access it with

    var myObject = new MyClass();
    var objString = myObject.myVar;

Log in to reply

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