Packageorg.sepy.io
Classpublic class Serializer

Serializer enable you to pass and receive complex data type from/to PHP/Flash using the native PHP functions serialize and unserialize. Flash received data will be a native Flash object too.



Public Properties
 PropertyDefined by
  c : uint
[static]
Serializer
  pattern : RegExp
[static]
Serializer
Public Methods
 MethodDefined by
  
serialize(data:*):String
[static] Serialize an input data into a PHP readable string which can be send through get or post and deserialized into the starting object
Serializer
  
stringCLenght(data:String, from:uint = 0, len:uint = 0):int
[static]
Serializer
  
stringLength(data:String):uint
[static]
Serializer
  
unserialize(data:String):*
[static] unserialize PHP serialized string into a readable Flash object
Serializer
  
unserialize_internal(data:String):*
[static]
Serializer
Public Constants
 ConstantDefined by
  version : String = "3.0.0"
[static]
Serializer
Property detail
cproperty
public static var c:uint
patternproperty 
public static var pattern:RegExp
Method detail
serialize()method
public static function serialize(data:*):String

Serialize an input data into a PHP readable string which can be send through get or post and deserialized into the starting object

Parameters
data:*

Returns
String — the serialized string

Example
   var o:Object = {first:1, second:[1,2,3,4]};
   var result:String = Serializer.serialize(o);
   

stringCLenght()method 
public static function stringCLenght(data:String, from:uint = 0, len:uint = 0):intParameters
data:String
 
from:uint (default = 0)
 
len:uint (default = 0)

Returns
int
stringLength()method 
public static function stringLength(data:String):uintParameters
data:String

Returns
uint
unserialize()method 
public static function unserialize(data:String):*

unserialize PHP serialized string into a readable Flash object

Parameters
data:String — serialized string

Returns
* — type depends on the content of serialized string

Example
   import flash.net.
   import org.sepy.io.Serializer;
         
   private var req:URLRequest;
   private var loader:URLLoader;
         
   private function init():void
   {
    req = new URLRequest("http://localhost/serializer/unserializer.php?getvalue");
    loader = new URLLoader(req);
    loader.addEventListener(Event.COMPLETE, handler);
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handler);
   }
    
   private function handler(e:Event):void
   {
    if(e.type == Event.COMPLETE)
    {
     var res:String = URLLoader(e.target).data.result
     var data:= Serializer.unserialize(res);
     trace(data);
    }
   }
   
    init();
   
    

unserialize_internal()method 
public static function unserialize_internal(data:String):*Parameters
data:String

Returns
*
Constant detail
versionconstant
public static const version:String = "3.0.0"