Skip to content
ClassUI & Typography@public

FlxButton

Deterministic Flixel button with optional toggle and native accessibility hooks.

ts
export declare class FlxButton extends FlxSprite

Constructors

ts
constructor(x?: number, y?: number, label?: string | null, onClick?: FlxButtonCallback | null)

Constructs a new instance of the FlxButton class

ParameterTypeDescription
xnumber-
ynumber-
labelstring | null-
onClickFlxButtonCallback | null-

Properties

PropertyModifiersTypeDescription
accessibleLabel-string | nullNative accessibility name. Defaults to current text; null omits the DOM control.
allowSwiping-booleanWhen true, a press started elsewhere can activate the button if the pointer is released while hovering over it.
DISABLEDstatic readonly``-
enabled-booleanWhether pointer and accessibility activation are accepted.
focusedreadonlyboolean-
HIGHLIGHTstatic readonly``-
label-FlxText | null-
labelAlphasreadonlynumber[]Label alpha multipliers for normal, highlight, pressed, and disabled states.
labelOffsetreadonlyFlxPoint | undefinedPrimary label offset used by legacy AS3 callers.
labelOffsetsreadonlyFlxPoint[]Label offsets for normal, highlight, pressed, and disabled states.
NORMALstatic readonly``-
on-boolean-
onDown-FlxButtonCallback | null-
onOut-FlxButtonCallback | null-
onOver-FlxButtonCallback | null-
onUp-FlxButtonCallback | null-
PRESSEDstatic readonly``-
soundDown-FlxButtonSound | null-
soundOut-FlxButtonSound | null-
soundOver-FlxButtonSound | null-
soundUp-FlxButtonSound | null-
status-number-
tabIndex-numberNative keyboard tab order used by the browser accessibility bridge.
text-stringHuman-visible label text, independent from the accessibility override.

Methods

activate()

ts
activate(): boolean

Activate the button through the same callback/sound path as pointer input.

Returns: boolean

createRenderHandle()

ts
createRenderHandle(): FlxRenderHandle

Returns: FlxRenderHandle

destroy()

ts
destroy(): void

Returns: void

setSounds()

ts
setSounds(soundOver?: FlxButtonSound | null, soundOut?: FlxButtonSound | null, soundDown?: FlxButtonSound | null, soundUp?: FlxButtonSound | null): this

Parameters:

ParameterTypeDescription
soundOverFlxButtonSound | null-
soundOutFlxButtonSound | null-
soundDownFlxButtonSound | null-
soundUpFlxButtonSound | null-

Returns: this

update()

ts
update(): void

Returns: void

Released under the MIT License.