Packageorg.flixel
Classpublic class FlxSave
InheritanceFlxSave Inheritance Object

A class to help automate and simplify save game functionality. Basicaly a wrapper for the Flash SharedObject thing, but handles some annoying storage request stuff too.



Public Properties
 PropertyDefined By
  data : Object
Allows you to directly access the data container in the local shared object.
FlxSave
  name : String
The name of the local shared object.
FlxSave
Protected Properties
 PropertyDefined By
  _closeRequested : Boolean
Internal tracker for save object close request.
FlxSave
  ERROR : uint = 2
[static]
FlxSave
  _onComplete : Function
Internal tracker for callback function in case save takes too long.
FlxSave
  PENDING : uint = 1
[static]
FlxSave
  _sharedObject : SharedObject
The local shared object itself.
FlxSave
  SUCCESS : uint = 0
[static]
FlxSave
Public Methods
 MethodDefined By
  
Blanks out the containers.
FlxSave
  
bind(Name:String):Boolean
Automatically creates or reconnects to locally saved data.
FlxSave
  
close(MinFileSize:uint = 0, OnComplete:Function = null):Boolean
A way to safely call flush() and destroy() on your save file.
FlxSave
  
destroy():void
Clean up memory.
FlxSave
  
erase():Boolean
Erases everything stored in the local shared object.
FlxSave
  
flush(MinFileSize:uint = 0, OnComplete:Function = null):Boolean
Writes the local shared object to disk immediately.
FlxSave
Protected Methods
 MethodDefined By
  
checkBinding():Boolean
Handy utility function for checking and warning if the shared object is bound yet or not.
FlxSave
  
onDone(Result:uint):Boolean
Event handler for special case storage requests.
FlxSave
  
onFlushStatus(E:NetStatusEvent):void
Event handler for special case storage requests.
FlxSave
Property Detail
_closeRequestedproperty
protected var _closeRequested:Boolean

Internal tracker for save object close request.

_onCompleteproperty 
protected var _onComplete:Function

Internal tracker for callback function in case save takes too long.

_sharedObjectproperty 
protected var _sharedObject:SharedObject

The local shared object itself.

The default value is null.

dataproperty 
public var data:Object

Allows you to directly access the data container in the local shared object.

The default value is null.

ERRORproperty 
protected static var ERROR:uint = 2

nameproperty 
public var name:String

The name of the local shared object.

The default value is null.

PENDINGproperty 
protected static var PENDING:uint = 1

SUCCESSproperty 
protected static var SUCCESS:uint = 0

Constructor Detail
FlxSave()Constructor
public function FlxSave()

Blanks out the containers.

Method Detail
bind()method
public function bind(Name:String):Boolean

Automatically creates or reconnects to locally saved data.

Parameters

Name:String — The name of the object (should be the same each time to access old data).

Returns
Boolean — Whether or not you successfully connected to the save data.
checkBinding()method 
protected function checkBinding():Boolean

Handy utility function for checking and warning if the shared object is bound yet or not.

Returns
Boolean — Whether the shared object was bound yet.
close()method 
public function close(MinFileSize:uint = 0, OnComplete:Function = null):Boolean

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.

Parameters

MinFileSize:uint (default = 0) — If you need X amount of space for your save, specify it here.
 
OnComplete:Function (default = null) — This callback will be triggered when the data is written successfully.

Returns
Boolean — The result of result of the flush() call (see below for more details).
destroy()method 
public function destroy():void

Clean up memory.

erase()method 
public function erase():Boolean

Erases everything stored in the local shared object. Data is immediately erased and the object is saved that way, so use with caution!

Returns
Boolean — Returns false if the save object is not bound yet.
flush()method 
public function flush(MinFileSize:uint = 0, OnComplete:Function = null):Boolean

Writes the local shared object to disk immediately. Leaves the object open in memory.

Parameters

MinFileSize:uint (default = 0) — If you need X amount of space for your save, specify it here.
 
OnComplete:Function (default = null) — This callback will be triggered when the data is written successfully.

Returns
Boolean — Whether or not the data was written immediately. False could be an error OR a storage request popup.
onDone()method 
protected function onDone(Result:uint):Boolean

Event handler for special case storage requests. Handles logging of errors and calling of callback.

Parameters

Result:uint — One of the result codes (PENDING, ERROR, or SUCCESS).

Returns
Boolean — Whether the operation was a success or not.
onFlushStatus()method 
protected function onFlushStatus(E:NetStatusEvent):void

Event handler for special case storage requests.

Parameters

E:NetStatusEvent — Flash net status event.