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 static var c:uint
public static var pattern:RegExp
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
Returns
| String — the serialized string
|
Example
var o:Object = {first:1, second:[1,2,3,4]};
var result:String = Serializer.serialize(o);
public static function stringCLenght(data:String, from:uint = 0, len:uint = 0):intParameters
| data:String |
| |
| from:uint (default = 0) |
| |
| len:uint (default = 0) |
Returns
public static function stringLength(data:String):uintParameters
Returns
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();
public static function unserialize_internal(data:String):*Parameters
Returns
public static const version:String = "3.0.0"
FlashMOG Client 0.2.4 Source