Search code examples
haxeflixel

FlxG.ui.FlxButton not working when I run code in haxeflixel?


I need major help in Haxeflixel with creating a simple button. My code is not working, "13: characters 2-5: Missing : ;"

package;

import flixel.FlxState;
import flixel.ui.FlxButton;
import flixel.FlxG;

class MenuState extends FlxState
{
    override public function create()
    {
    var hairOne:FlxButton;
    hairOne = new FlxButton(0, 0, "Hair #1", clickedHairOne)
    add(hairOne);
        super.create();
    }

    function clickedHairOne()
    {
        FlxG.switchState(new PlayState());
    }

    override public function update(elapsed:Float)
    {
        super.update(elapsed);
    }
}

I have spent over 30 minutes, help


Solution

  • The error means that on the end of the line 13 you are missing a semicolon (;).

    That is:

    hairOne = new FlxButton(0, 0, "Hair #1", clickedHairOne)

    should be

    hairOne = new FlxButton(0, 0, "Hair #1", clickedHairOne);