Page 1 of 1

Pass complex data from PHP to Flash Flash MX 2004, PHP, SerializerClass - #1 Rate Topic: -----

#1 Broly   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 16-December 04

Posted 17 December 2004 - 04:27 PM

1 ) Prefaction

In this tutorial we’ll see how to pass complex data from php to flash, without using AmfPhp but also without the “classic” format readable by flash…this can bea n intermediate solution: AmfPhp is for large amount of data, and the classic “var=value&var2=value2&…” is for small/simple data-types…what can we do when we have a little amount of complex data, or a medium amount of simple/complex data ? Well…we can use the serializer class!

1b) What we need

a) Serializer Class (downloadable at http://sourceforge.n...rializerclass/) – An excellent class, a Sephiroth’s ( ) idea that became an useful realty :D
As said before, this class allows to pass complex dates from php to flash without the “classic” format


that with a medium amont of data can be very very boring and hard to use, but it allows to pass directly more complex objects (eg Arrays)
This is the official class description

“Serializer Class enable (For Macromedia Flash) you to pass and receive complex data type from and to PHP and Flash using the native PHP functions serialize and unserialize. Flash received data will be a native Flash object”

B) Flash mx 2004 (I think you know it :D, if you haven’t it you can find a trial on

c) A local webserver, or an hosting, where test our little example (it must have PHP support)

d) Macromedia Extension Manager (free, downloadable from, wich we’ll use for install the Serializer Class Extension

1c) Last notes before start

In this tutorial, we see simply how the data-passage works, we won’t use database, .txt files and other, but only a .php files with “fixed” data….obviously you can take data wherever you want, but I thought that use a data-source (eg a database) in this tutorial hadn’t a practice utility, it’d only make the tutorial more complex and longer…I preferred made things simple :)…it will your work make it harder :D

2) Let’s go!

Well, before start, I created the files (serializer.fla and serializer .php). I’ve also downloaded the .mxp file.

NOTE: Obviously you can also create .fla and .php during the tutorial, and not immediately…I preferred create now the files for show how they’ll be :D

2a) Serializer Class installation

Now, first thing to do is install the Serializer class.
Double click on .mxp file … follow the video instructions you find at the URL

As you see, after the installation, you’ll have a “Serializer” name into the Extension Manager (ehm..I’ve a lot of extension installed now, but if you have less caos then me you found it immediately :D). Selecting the Serializer into the Extension Manager you can see a little sample-ActionScript code. You can see with your eyes, it’s very easy. Now I’ll explain you pass-by-pass how to try if the class works correctly, with a small example.

2b) The PHP file

For class testing, we need a php file that have to pass to flash some complex data (array, objects, etc). Let’s write, into “Serializer.php”, some simple code-lines with an array containing different object types…

Now, we can see if it really pass data urlencoded and serialized…then we can put the .php on our webspace (or into our local test directory) and visit it in a brower.

The browser’d show this



2c) The flash side

After the PHP code, it’s time to open Flash 
Create Serializer.fla (or open it), and in the first frame write this code

(change the path into lV.load to your. Php file)

See the video at URL.

As you see, after inserted the code, if you test your flash movie, you’ll have a variable that have the same values that where in the PHP array…simple, true? :)

3) Bye…and a preview 

In this tutorial we saw how to receive serialized data from php…but if we’d do the vice-versa, send serialized data from flash to php? Well, it’s that we’ll see in next tutorial, friends 
I hope you like this tutorials with video inserts that show some passages ;), tell me if you like them!!!
(please note: I haven't insert the .swf videos into the thread because they were too large, if I publish it at less than that size they became incomprensible :))

This post has been edited by Broly: 17 December 2004 - 05:15 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Pass complex data from PHP to Flash

#2 skyhawk133   User is offline

  • Head DIC Head
  • member icon

Reputation: 1973
  • View blog
  • Posts: 20,430
  • Joined: 17-March 01

Posted 17 December 2004 - 05:32 PM

Very cool, love the flash videos!!!
Was This Post Helpful? 0
  • +
  • -

#3 mullwaden   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-November 05

Posted 18 November 2005 - 05:38 PM

uhh now that i have som numbers in some serialize thing, ofcourse risking sounding very stupid, how do i use them, say put them in an array in flash =) I have an array called nums how do i get the numbers into it ? :P


p.s. while im at it, how do i see the amount of values in an array, is it something like array'last ? (thats the ADA version) :S
Was This Post Helpful? 0
  • +
  • -

#4 nexx   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-December 05

Posted 01 December 2005 - 02:34 PM

The script does not work for me, I must admit I'm new to action script.

I'm sure on PHP side everything works ok
in AS it gives me error

Error opening URL "localhost/images/pics/undefined"

I'm passing array to url

import it.sephiroth.Serializer

var serial:Serializer = new Serializer();
// import from PHP
lV = new LoadVars();
lV.onload = function(){
unserialized = serial.unserialize(this.ToFlash);


this.pathToPics = "images/pics/";
// fill array with pics
this.pArray = unserialized; // if you just declare this here as an array it
// it works fine e.g. ["image0.jpg", "image1.jpg", "image2.jpg", "image3.jpg"];

Could anyone help pls

This post has been edited by nexx: 01 December 2005 - 02:36 PM

Was This Post Helpful? 0
  • +
  • -

#5 ercherry   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-December 05

Posted 12 December 2005 - 12:53 PM

I found this to be very helpful. For the person looking to put the data back into an array once you get it into flash, go to the source:


Scroll to the bottom and check out the code.

I'm still figuring it out myself.
Was This Post Helpful? 0
  • +
  • -

#6 r1card0   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 21-November 08

Posted 21 November 2008 - 11:50 AM

I did not find the serializer mxp in the package downloaded from sourceforge. anyone shed any light on this?

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1