COMMUNITY

Unkown Identifier :ClickPlay

can anyone help me with this? ive tried following the TurnBasedRPG tutorial and FOR SOME reason the function ClickPlay Doesn’t Work??
import flixel.FlxG;

import flixel.FlxState;

import flixel.ui.FlxButton;

import flixel.util.FlxColor;

class MenuState extends FlxState

{

var playButton:FlxButton;

override public function create()

{

    trace("IN MENU STATE.");

    super.create();

    playButton = new FlxButton(0, 0, "PLAY WITH ME!!", ClickPlay);
    playButton.x = (FlxG.width / 2) - 10 - playButton.width;
    playButton.y = FlxG.height - playButton.height - 10;
    add(playButton);

}

override public function update(elapsed:Float)

{

    super.update(elapsed);

    function ClickPlay() //PLEASE WORK

    {

        FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function()

        {

            FlxG.switchState(new PlayState());

        });

    }

}

}

wait im sorry forgot the ClickPlay function lol here it is

function ClickPlay()

    {

        FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function()

        {

            FlxG.switchState(new PlayState());

        });

I see you have the ClickPlay() function in update(). Move in out of update().

package;

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

class MenuState extends FlxState
{
	var playButton:FlxButton;

	override public function create()
	{
		trace("IN MENU STATE.");

		super.create();

		playButton = new FlxButton(0, 0, "PLAY WITH ME!!", ClickPlay);
		playButton.x = (FlxG.width / 2) - 10 - playButton.width;
		playButton.y = FlxG.height - playButton.height - 10;
		add(playButton);
	}

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

		/** REMOVE THIS
		function ClickPlay() //PLEASE WORK
		{
			FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function()
			{
				FlxG.switchState(new PlayState());
			});
		}
		*/
	}

	function ClickPlay()
	{
		FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function()
		{
			FlxG.switchState(new PlayState());
		});
	}
}