FlxSave
| Kind | class |
| Package | flixel.util |
| Full name | flixel.util.FlxSave |
| Source | source/source-haxelib-patches/flixel/util/FlxSave.hx |
| Implements | IFlxDestroyable |
| Metadata | @:allow(flixel.util.FlxSharedObject) |
Public fields
| Name | Type | Static | Default | Notes |
|---|---|---|---|---|
data | Dynamic | no | — | property (default, null) · Allows you to directly access the data container in the local shared object. |
name | String | no | — | property (get, never) · The name of the local shared object. |
path | String | no | — | property (get, never) · The path of the local shared object. @since 4.6.0 |
status | FlxSaveStatus | no | EMPTY | property (default, null) · The current status of the save. @since 5.0.0 |
isBound | Bool | no | — | property (get, never) · Wether the save was successfully bound. @since 5.0.0 |
Public methods
new (constructor)
function new()
destroy
function destroy():Void
Clean up memory.
bind
function bind(name:String, ?path:String):Bool
Automatically creates or reconnects to locally saved data.
@param name The name of the save (should be the same each time to access old data).
May not contain spaces or any of the following characters:
~ % & \ ; : " ' , < > ? #
@param path The full or partial path to the file that created the shared object.
Mainly used to differentiate from other FlxSaves. If you do not specify
this parameter, the company name specified in your Project.xml is used.
@return Whether or not you successfully connected to the save data.
| Parameter | Type | Default |
|---|---|---|
name | String | — |
path (optional) | String | — |
mergeDataFrom
function mergeDataFrom(name:String, ?path:String, overwrite = false, eraseSave = true, minFileSize = 0):Bool
Creates a new FlxSave and copies the data from old to new, flushes the new save (if changed) and then optionally erases the old save.
@param name The name of the save. @param path The full or partial path to the file that created the save. @param overwrite Whether the data should overwrite, should the 2 saves share data fields. defaults to false. @param eraseSave Whether to erase the save after successfully migrating the data. defaults to true. @param minFileSize If you need X amount of space for your save, specify it here. @return Whether or not you successfully found, merged and flushed data.
| Parameter | Type | Default |
|---|---|---|
name | String | — |
path (optional) | String | — |
overwrite (optional) | Dynamic | false |
eraseSave (optional) | Dynamic | true |
minFileSize (optional) | Dynamic | 0 |
mergeData
function mergeData(sourceData:Dynamic, overwrite = false, minFileSize = 0)
Copies the given data over to this save and flushes (if changed).
@param sourceData The data to merge @param overwrite Whether the data should overwrite, should the 2 saves share data fields. defaults to false. @param minFileSize If you need X amount of space for your save, specify it here. @return Whether or not you successfully saved the data.
| Parameter | Type | Default |
|---|---|---|
sourceData | Dynamic | — |
overwrite (optional) | Dynamic | false |
minFileSize (optional) | Dynamic | 0 |
close
function close(minFileSize:Int = 0):Bool
A way to safely call flush() and destroy() on your save file. Will correctly handle storage size popups and all that good stuff. If you don't want to save your changes first, just call destroy() instead.
@param minFileSize If you need X amount of space for your save, specify it here. @return The result of result of the flush() call (see below for more details).
| Parameter | Type | Default |
|---|---|---|
minFileSize (optional) | Int | 0 |
flush
function flush(minFileSize:Int = 0):Bool
Writes the local shared object to disk immediately. Leaves the object open in memory.
@param minFileSize If you need X amount of space for your save, specify it here. @return Whether or not the data was written immediately. False could be an error OR a storage request popup.
| Parameter | Type | Default |
|---|---|---|
minFileSize (optional) | Int | 0 |
erase
function erase():Bool
Erases everything stored in the local shared object. Data is immediately erased and the object is saved that way, so use with caution!
@return Returns false if the save object is not bound yet.
isEmpty
function isEmpty()
Scans the data for any properties. @since 5.0.0
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
invalidChars | — | yes |
_sharedObject | SharedObject | no |
| Method |
|---|
static function hasInvalidChars(str:String) |
static function validate(str:String) |
static function validateAndWarn(str, fieldId:String) |
function checkStatus():Bool |
function get_name() |
function get_path() |
inline function get_isBound() |