What the hell is AMF?

I am currently working on a series of tutorials on using AMFPHP and I thought it would be a good idea to write a post explaining what AMF actually is. AMF is an acronym that stands for Action Message Format. Here is the official definition that I got directly from the AMF specification document:

“Action Message Format (AMF) is a compact binary format that is used to serialize ActionScript object graphs. Once serialized an AMF encoded object graph may be used to persist and retrieve the public state of an application across sessions or allow two endpoints to communicate through the exchange of strongly typed data.”

While that description is helpful, it is still a little confusing in my opinion. The easiest way to think of AMF is that it is the fastest way to send and receive data between your Flash movie and a web server. The reason that it is so fast is that the data is compressed and is in binary format. Most Flashers are very familiar with the methods of exchanging data with a server using XML. This is still a good approach for a lot of situations, but when large amounts of data are involved, AMF is far superior.

AMF is actually used internally by the Flash Player is many situations. One example is that Flash uses AMF to represent the binary data stored using the ByteArray class. But the main thing that Flash developers need to be concerned with is how to use AMF to send and receive data with their web server. As with most things in Flash, there are many different methods of accomplishing this. Which method you use is primarily determined by which server-side platform you are using. Let’s quickly take a look at some of the most popular options:

ColdFusion
One the most robust solutions for working with AMF is ColdFusion. This is not surprising as ColdFusion is an Adobe product and has built-in support for AMF throughout the technology. The main roadblock to using ColdFusion is that you need to have a web hosting provider that supports it. If you are about to choose a web host and you plan on doing a lot of Flash work, ColdFusion is definitely something that you should be looking in to.

BlazeDS
Adobe recently open-sourced the AMF specification along with BlazeDS, which is a free Java server-side technology for using AMF. Again, since this is an official Adobe technology, you can be sure that the AMF implementation is rock solid. Using BlazeDS requires a Java server, so if you have a typical LAMP setup, you will not be able to play with it.

LiveCycle Data Services
This is the most robust, scalable way of using AMF for Flash and Flex applications. This is the option to choose if you are building large enterprise applications. LiveCycle is very pricey however, and also needs to run on a Java server. These reasons put it out of reach for most non-enterprise applications.

AMFPHP
AMFPHP is a free open-source PHP implementation of AMF. The major benefit of AMFPHP is that it can run on the vast majority of web servers as the only requirement is that PHP is supported. There are actually other PHP implementations of AMF, but AMFPHP is by far the most popular. This will be the subject of my next couple of tutorials at gotoAndLearn().

Other Technologies
There are many other technologies out there that have implemented AMF. AMF.NET is an open source .NET AMF solution for Flash. Rubyamf is a Ruby implementation of AMF. Similar projects have sprouted up for Python and other languages.

AMF is far too large a topic for a single blog post. But the main thing to know is that it is a fast, binary protocol for exchanging data between your Flash movies and a server. Look for my tutorials on AMFPHP in the next week for some real-world examples. For those AMF geeks out there, please correct or add to my post in the comments :)

Lee


Commentary

  1. Erik says:

    Nice article :)

    Might be easy to say that AMF is a translator between native ActionScript data types and bytes. AMF determines how an ActionScript variable is represented in bytes.

    LocalConnection and SharedObject both use AMF to convert their data to bytes.

    Greetz Erik

  2. vol says:

    Hi, Lee. But if I use C++ socket server, how can I use it with AMF?

    Thanks.

    Andrew.

  3. ChromeD says:

    Thumbs up … Can’t await the Tutorial :)

    cheers

  4. Aj says:

    I have been thinking of using AMF with Asp.Net but always go back to webservices approach. Is there any resource which compares AMF with Windows Communication Foundation?

  5. hi lee,
    recently I also posted a tutorial about AMFPHP/AS3 and setting this up on OS X with MAMP: http://soenkerohde.com/2008/06/amfphp-on-air-tutorial-with-mamp/
    One solution is flat (one MXML) and the other uses the Caingorm approach with ServiceLocator, Delegates etc.

  6. pedrovalentim says:

    Nice article Lee, looking forward for those tutorials :)

  7. creacog says:

    Possibly worth mentioning James Ward’s BlazeBench which demonstrates and compares performance of AMF against other methods.

    chttp://www.jamesward.com/wordpress/2007/12/12/blazebench-why-you-want-amf-and-blazeds/

  8. Alrevez says:

    I’m so exited for this tutorial, thanks in andvance for this introductorial post, i’ll be wating!

  9. oliver_l1 says:

    Thanks for the info.

  10. tom says:

    WebOrb is another nice app that supports AMF for Flash/Flex. The product runs on Java, PHP and they even have a native .NET option.

    http://www.themidnightcoders.com/weborb/

  11. Zak says:

    Sounds interesting… Can’t wait for the tutorials!

  12. T_bo says:

    WebOrb is also very good for remoting php. Take a look at it if haven’t yet.
    Have a nice day and thx a lot for all your tutorials

  13. Saqo says:

    I use FluorineFx open source .NET AMF solution for Flash,
    I think it’s best

  14. peter says:

    big tutorial, i know this allready, and looking forward

    as you wrote, i am a big fan of xml especially now with AS 3

    but still, many tools, many trades

    big up!

  15. Phil says:

    Yes, Lee! This has been a big question mark in my mind for a while. I’m looking forward to your tutorials to help clear it up. Thank you!

  16. Robert says:

    Awesome! Looking forward to those tutorials!

  17. christian says:

    And I always thought it stood for Apache/MySQL/Flash/PHP.

    Live and learn.

  18. Ricardo says:

    Hi Lee, I´ve always heard about it, but never found a good and simple (as always you make) tutorial to go deep inside it. So thanks in advance :)

  19. nicolas says:

    lee you rock!!!!

  20. Jarred says:

    for django/python there’s also djangoAMF (djangoamf.sourceforge.jp) and pyAMF (pyamf.org)

    looking forward to the article.

  21. mathias says:

    oh, i am so looking forward to it!

  22. Chris says:

    How about serialisation vs. AMFPHP? I’m using a simple AS3 serialisation class und do it the other around on the php side. It’s quick and simple. Until now I have not found any advantages of AMFPHP which cannot be used with simple serialisation or am I wrong?

  23. Arul says:

    No wonder, I become a good designer with out going to the extra class. The informations given in the blogs is much enough to know designing.
    You man have done a wonderful job…
    cheer up>>>

  24. Abdulaziz says:

    Great lee.

    powerful explanation

    thanks lee.

  25. hell rider says:

    Lee i’ve been searching info about it…it’s good to know you’re on the way. greetings from ecuador

  26. Hi Lee
    Following the advice you gave me at the Adobe onAir tour I started working with the AMF format and have to say I’m pretty happy with the results. The speed boost is incredible and now I can really use all the data I have.
    The demo is almost finished and let’s hope that soon a brand new Adobe AIR app will be released in the wild.

    Thanks again

    ps. I’ll send you an email with the demo as soon as I have a RC

  27. I wish you would do your tutorials around Blaze DS, since I have yet to see one that uses flash and not flex.

    I have been in love with AMFPHP for over the three years, But the project has been at a stand still for over the last year in a half with the last version still in beta for over a year.

    I would take the time to learn java so I could use blaze but I’m not sure if it works well with flash since I can’t seem to get to work right and all the current examples use flex only. We need some good “Blaze DS + Flash CS3″ tutorials. Even then I can’t wait to see what you have made since I know I will learn something new.

    Thanks lee your the man!

    PS: one thing to note that is GREAT about AMFPHP is that you can return a Recordset directly from an SQL query and send it directly to a dataprovider of a Datagrid or what ever else you want

  28. bob says:

    Thank you for this tutorial!

  29. Rob says:

    I’d also like to throw in a vote for Fluorine (.NET-only). Compared to Adobe’s version of Flash Remoting, it’s less buggy, easier to use, and much better supported. And free.

    Btw, I followed the link to LiveCycle and after reading the product description, I still have no idea what it is.

  30. Chris says:

    Sorry about the misapprehension in my other post. I didn’t notice that you allready answered. I guess I have to test it myself, because I’m sending all my requestdata like one information and so I don’t have this big overhead shown in the comparison.

  31. Stankiewicz says:

    Great! I had hear about AMFPHP before but I hadn’t used it.

  32. Mark says:

    Hi,

    Has anyone successfully used AMF.NET? More importanty with AS3? the documentation on the AMF.NET page is no help (http://amfnet.openmymind.net/howto/default.aspx) as it uses a class called ‘Service’ which doesn’t appear to be in the AS2 or AS3 documentation.

    It seems that although they’re called a similar thing (AMFPHP & AMF.NET) the way you communicate to their interface within Flash is competely different. Does anyone know of a better alternative for .NET?

    It looks like we may stick with webservices….

    Mark

  33. Marc says:

    Hi all,

    In case anyone is interested, I’ve started to work on a portable C implementation of the AMF0/3 formats, based on my partial AMF0 implementation for the FLVmeta tool (http://code.google.com/p/flvmeta/).
    I’ve created a project on sourceforge, please visit http://libamf.sourceforge.net/ and don’t hesitate to leave comments in the public forums of the project page.
    I haven’t committed code yet, but I think I’ll have a beta available for testing by the end of august.

  34. This is a great way to set and get cookies w/ flash.

  35. Greg says:

    What am I missing here??? AMF is just object serialization/deserialization. What call it “Action Message Format”. Is that simply to give some marketing jack-hole the opportunity to monetize something that should be inherent in the platform?

  36. lee says:

    @Greg Yes that is exactly why we called it that. Please don’t tell anyone.

  37. AMF is a good solution if you want to get the best performance, but I prefer when possible to use webservice for client to server comunication.

    a server interface that comunicates thru AMF isn’t reusable with other technologies.

    I write about interaction between flash and java analizing AMF, blazeDS, Flex+Flash and webservice.

    If interested go to
    http://programmaremobile.blogspot.com/

  1. [... I am currently working on a series of tutorials on using AMFPHP and I thought it would be a good idea to write a post explaining what AMF actually is. ...]

  2. [... I am currently working on a series of tutorials on using AMFPHP and I thought it would be a good idea to write a post explaining what AMF actually is. ...]

  3. [... I am currently working on a series of tutorials on using AMFPHP and I thought it would be a good idea to write a post explaining what AMF actually is. ...]

  4. [... I am currently working on a series of tutorials on using AMFPHP and I thought it would be a good idea to write a post explaining what AMF actually is. ...]

Leave a Comment