class FlxUI
package flixel.addons.ui
extends FlxTypedUIGroup › FlxTypedSpriteContainer › FlxTypedSpriteGroup › FlxSprite › FlxObject › FlxBasic
implements IEventGetter
A simple xml-driven user interface
Usage example:
_ui = new FlxUI(U.xml("save_slot"),this);
add(_ui);
Static methods
staticconsolidateData(data:Access, definition:Access, combineUniqueChildren:Bool = false):Access
Takes two XML files and combines them, with "data" overriding duplicate attributes found in "definition" @return
Parameters:
data | the local data tag |
---|---|
definition | the base definition you are extending |
combineUniqueChildren | if true, will combine child tags if they are unique. If false, inserts child tags as new ones. |
staticevent(name:String, sender:IFlxUIWidget, data:Dynamic, ?params:Array<Dynamic>):Void
Broadcasts an event to the current FlxUIState/FlxUISubState
Parameters:
name | string identifier of the event -- each IFlxUIWidget has a set of string constants |
---|---|
sender | the IFlxUIWidget that sent this event |
data | non-array data (boolean for a checkbox, string for a radiogroup, etc) |
params | (optional) user-specified array of arbitrary data |
staticfont(str:String, style:String = "", extension:String = ".ttf"):String
Given something like "verdana", "bold", ".ttf", returns "assets/fonts/verdanab.ttf" Also: checks Firetongue (if available) for font replacement rules
Parameters:
str | |
---|---|
style | |
extension |
2.1.0
.staticfontSize(str:String, size:Int):Int
Given a font name & size, returns the correct size for that font in the current locale (Only really useful if you're using Firetongue with font replacement rules)
Parameters:
str | |
---|---|
size |
2.1.0
.staticinlinefontStr(str:String, style:String = ""):String
Given something like "verdana" and "bold" returns "assets/fonts/verdanab" Also: checks Firetongue (if available) for font replacement rules
Parameters:
str | |
---|---|
style |
2.1.0
.staticforceFocus(b:Bool, thing:IFlxUIWidget):Void
Static-level function used to force giving a certain widget focus (useful for e.g. enforcing overlap logic)
Parameters:
b | |
---|---|
null | thing |
staticrequest(name:String, sender:IFlxUIWidget, data:Dynamic, ?params:Array<Dynamic>):Dynamic
Broadcasts an event to the current FlxUIState/FlxUISubState, and expects data in return
Parameters:
name | string identifier of the event -- each IFlxUIWidget has a set of string constants |
---|---|
sender | the IFlxUIWidget that sent this event |
data | non-array data (boolean for a checkbox, string for a radiogroup, etc) |
params | (optional) user-specified array of arbitrary data |
Returns:
some sort of arbitrary data from the recipient
Constructor
new(?data:Access, ?ptr:IEventGetter, ?superIndex_:FlxUI, ?tongue_:IFireTongue, liveFilePath_:String = "", ?uiVars_:Map<String, String>)
Creates a new FlxUI object
Parameters:
data | the xml layout for this UI |
---|---|
ptr | the object that receives events |
superIndex_ | (optional) another FlxUI object to search if assets are not found locally |
tongue_ | (optional) Firetongue object for localization |
liveFilePath_ | (optional) The path for live file loading (only works if debug && sys flags are true) |
uiVars_ | (optional) Any variables you want to pre-load the UI with |
Variables
read onlycursorLists:Array<Array<IFlxUIWidget>> = null
A useful hierarchical grouping of widgets for the FlxUICursor, null by default, populated during loading via xml:
Methods
addAsset(asset:IFlxUIWidget, key:String, group_name:String = "", recursive:Bool = false):Bool
Adds an asset to this UI, and optionally puts it in a group
Parameters:
asset | the IFlxUIWidget asset you want to add |
---|---|
key | unique key for this asset. If it already exists, this fails. |
group_name | string name of group inside this FlxUI you want to add it to. |
recursive | whether to recursively search through sub-ui's |
checkVariable(key:String, otherValue:String, type:String, op:String = "==", recursive:Bool = true):Bool
getAssetGroup(?key:String, ?thing:IFlxUIWidget):FlxUIGroup
Get the group that contains a given IFlxUIWidget @return
Parameters:
key | the asset key of the IFlxUIWidget |
---|---|
thing | the IFlxUIWidget itself |
getText(flag:String, context:String = "data", safe:Bool = true, code:String = ""):String
UTILITY FUNCTIONS
load(data:Access):Void
Main setup function - pass in a Access(xml) object to set up your FlxUI
Parameters:
null | data |
---|
loadThing(type:String, data:Access):IFlxUIWidget
Load an individual flixel-ui widget from a snippet of xml @return
Parameters:
type | |
---|---|
data |
onFocusLost(widget:IFlxUIWidget):Void
This causes FlxUI to respond to a specific widget losing focus
Parameters:
null | widget |
---|
removeAsset(key:String, destroy:Bool = true):IFlxUIWidget
Removes an asset
Parameters:
key | the asset to remove |
---|---|
destroy | whether to destroy it |
Returns:
the asset, or null if destroy=true
replaceAsset(key:String, replace:IFlxUIWidget, center_x:Bool = true, center_y:Bool = true, destroy_old:Bool = true):IFlxUIWidget
Replaces an asset, both in terms of location & group position
Parameters:
key | the string name of the original |
---|---|
replace | the replacement object |
destroy_old | kills the original if true |
Returns:
the old asset, or null if destroy_old=true
sendToBack(name:String, recursive:Bool = true):Void
Send an asset to either the back of the member list that it's in
Parameters:
name | string identifier of the asset |
---|---|
recursive | whether to check superIndex if not found |
sendToFront(name:String, recursive:Bool = true):Void
Send an asset to the front of the member list that it's in
Parameters:
name | string identifier of the asset |
---|---|
recursive | whether to check superIndex if not found |
setMode(mode_name:String, target_name:String = ""):Void
Set a mode for this UI. This lets you show/hide stuff basically.
Parameters:
mode_name | The mode you want, say, "empty" or "play" for a save slot |
---|---|
target_name | UI element to target - "" for the UI itself, otherwise the name of an element that is itself a FlxUI |
setSuperIndex(flxUI:FlxUI):Void
Set a pointer to another FlxUI for the purposes of indexing
Parameters:
null | flxUI |
---|