Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me


Forum's topics

Latest Files


Top Rated


Photo Gallery

Flash - PHP Serializer Class

This Class enable you to pass and receive complex data type from and to PHP using the native PHP functions serialize and unserialize (this means that you can receive an array directly from PHP without making any kind of split to obtain your original array).
* More informations about serialize and unserialize PHP function can be found here

Added support for ActionScript 3

Project has moved on



Flash MX Example

PHP Code

class myclass {
    var $db = "resource";
    var $integer = 1;
// ****************************
// create the array to be
// passed to Flash unserializer
// ****************************
$testArray = array();
$testArray['intero'] = 1000;
$testArray['stringa'] = "nuova stringa";
$testArray['doubleval'] = doubleval(100.54);
$testArray['floatval'] = floatval(100.54);
$testArray['booleano'] = true;
array_push($testArray, "{Run to the hills!!!}");
$testArray['oggetto'] = new myclass();
$testArray['servertime'] = gmdate('D, d M Y H:i:s \G\M\T', time());

// ******************************
// send back the value serialized
// ******************************
print "flashVar=" . urlencode(utf8_encode(serialize($testArray)));

Flash Code

#include ""

MyVars = new LoadVars ();
MyVars.load ('http://localhost/sender.php');
MyVars.onLoad = function () {
    myUnserialized = new Serializer().unserialize(this.flashVar)

Flash MX 2004 Example


// once downloaded the mxp package
// a folder it/sephiroth will be created
import it.sephiroth.Serializer

var serial:Serializer = new Serializer();
MyVars = new LoadVars ();
MyVars.load ('http://localhost/sender.php');
MyVars.onLoad = function () {
    myUnserialized = serial.unserialize(this.flashVar)
// to create a serialized data string
testArray = new Array();
myData = serial.serialize( testArray ); 


Flash 9 Example


import org.sepy.Serializer

var fromString:String = 'a:5:{i:2;a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:3;}s:1:"k";d:23.440000000000001278976924368180334568023681640625;s:1:"i";i:-11;s:1:"o";b:1;s:5:"class";O:3:"foo":2:{s:3:"boo";s:5:"index";s:3:"foo";i:1;}}';
var result:* = Serializer.unserialize(fromString);


View the demonstration usage {made with Camtasia Studio}
Read the article on Macromedia™ developer using Serializer class

Alessandro Crugnola []
Makram Saleh []
Sunny Hong []
Emmanuel Ristord []
Che Allen []
Matt Tarbit []


Also checkout the SVN repository for latest updates.