Search code examples
checkboxhaxehaxeflixel

In HaxeFlixel, What is Box object and how to use it?


I'm trying to use FlxUICheckBox. In the official documentation, the constructor looks like this:

new(X:Float = 0, Y:Float = 0, ?Box:Dynamic, ..)

What is the Box object?

How should I send a Box object as a parameter to this constructor?


Solution

  • I should probably change it to BoxAsset. It's the image asset you want to use for the box part of the checkbox.

    A simple checkbox has three components, and looks a bit like this:

    [X] Checkbox
    
    1. Box means the box part, "[ ]"
    2. Check means the check part, "X"
    3. Label means the text that goes in the textfield next to the checkbox

    If you don't provide Box or Check, it will use default FlxUIAssets automatically to skin your checkbox. If you provide your own asset (such as "assets/mybox.png" for example), it will use that instead. It is expecting the same sort of thing you would pass into FlxSprite.loadGraphic() -- a String, a BitmapData, or a FlxGraphic.

    I should probably also update the type from :Dynamic to :FlxGraphicAsset, I originally wrote this code a long time ago before they added that new helper type.