TextAsset
Asset type for loading text files.
Loads any text-based file format like:
- Plain text files (.txt)
- JSON files (.json)
- XML files (.xml)
- Configuration files (.cfg, .ini, etc.)
- Any UTF-8 encoded text content
Features:
- UTF-8 encoding support
- Hot reload for live content updates
- Suitable for loading game data, configurations, or localization files
var assets = new Assets();
assets.addText('config.json');
assets.addText('dialogue/intro.txt');
assets.load();
// Access loaded text
var configJson = assets.text('config');
var config = Json.parse(configJson);
Instance Members
text: String
The loaded text content. Observable property that updates when the text is loaded or reloaded. Null until the asset is successfully loaded.
invalidateText(): Void
load(): Void
Load the text file content. The file is loaded as UTF-8 encoded text. Emits complete event when finished.
destroy(): Void
new(name: String, ?variant: String, ?options: Null<AssetOptions>): Void
Create a new text asset.
Name | Type | Default | Description |
---|---|---|---|
name |
String | Text file name (with or without extension) | |
variant |
String | (optional) | Optional variant suffix |
options |
Null<AssetOptions> | (optional) | Loading options (backend-specific) |
Private Members
unobservedText: String
Event when text field changes.
Name | Type |
---|---|
current |
String |
previous |
String |
assetFilesDidChange(newFiles: ReadOnlyMap<String, Float>, previousFiles: ReadOnlyMap<String, Float>): Void
Handle file system changes for hot reload. Automatically reloads the text when the source file is modified.
Name | Type |
---|---|
newFiles |
ReadOnlyMap<String, Float> |
previousFiles |
ReadOnlyMap<String, Float> |
Metadata
Name | Parameters |
---|---|
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.ObservableMacro.build() |
:autoBuild |
tracker.macros.ObservableMacro.build() |