Skip to main content

FlxSave

Kindclass
Packageflixel.util
Full nameflixel.util.FlxSave
Sourcesource/source-haxelib-patches/flixel/util/FlxSave.hx
ImplementsIFlxDestroyable
Metadata@:allow(flixel.util.FlxSharedObject)

Public fields​

NameTypeStaticDefaultNotes
dataDynamicno—property (default, null) · Allows you to directly access the data container in the local shared object.
nameStringno—property (get, never) · The name of the local shared object.
pathStringno—property (get, never) · The path of the local shared object. @since 4.6.0
statusFlxSaveStatusnoEMPTYproperty (default, null) · The current status of the save. @since 5.0.0
isBoundBoolno—property (get, never) · Wether the save was successfully bound. @since 5.0.0

Public methods​

new (constructor)​

function new()

View source

destroy​

function destroy():Void

Clean up memory.

View source

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.

ParameterTypeDefault
nameString—
path (optional)String—

View source

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.

ParameterTypeDefault
nameString—
path (optional)String—
overwrite (optional)Dynamicfalse
eraseSave (optional)Dynamictrue
minFileSize (optional)Dynamic0

View source

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.

ParameterTypeDefault
sourceDataDynamic—
overwrite (optional)Dynamicfalse
minFileSize (optional)Dynamic0

View source

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).

ParameterTypeDefault
minFileSize (optional)Int0

View source

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.

ParameterTypeDefault
minFileSize (optional)Int0

View source

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.

View source

isEmpty​

function isEmpty()

Scans the data for any properties. @since 5.0.0

View source

Internals​

Private / internal members
FieldTypeStatic
invalidChars—yes
_sharedObjectSharedObjectno
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()