Menu:

Sponsor

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

Follow Me

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

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 SourceForge.net

 

Examples

Flash MX Example

PHP Code

<?php
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 "SerializerClass.as"

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

Flash MX 2004 Example

Actionscript

// 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();
testArray.push("hello");
testArray.push(12345);
myData = serial.serialize( testArray ); 

 

Flash 9 Example

Actionscript3

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 [alessandro@sephiroth.it]
Makram Saleh [msaleh@abeo.com]
Sunny Hong [sunny@ghostwire.com]
Emmanuel Ristord [emmanuel.ristord@ashita-studio.com]
Che Allen [che@jemeni.com]
Matt Tarbit [matt@sense.co.uk]

Download

http://sourceforge.net/projects/serializerclass/

Also checkout the SVN repository for latest updates.