Adobe proposes AMF support for Zend Framework

Since my last couple of posts and tutorials have been focused on PHP, it is good timing to tell you that AMF will soon be coming to the Zend Framework. Much like AMFPHP, the proposed Zend_Amf component will make communication between Flash and PHP lightening fast. What’s even better news is that the guy Zend has advising them on implementing AMF is none other than Wade Arnold, who runs the AMFPHP project. Look for a lot more news on this as it becomes available. This is an exciting step towards solidifying the relationship between PHP and Flash.

Lee


New video tutorial on using AMFPHP

As promised, here is the first in a series of tutorials on using AMFPHP. In the tutorial I show you how to download and install AMFPHP on your web server. From there we build a simple PHP service class that sends email. Finally we go into Flash and write the ActionScript code needed to call the the AMFPHP service. Go and check it out at http://www.gotoandlearn.com and let me know what you think.

Lee

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


Proximity Menu Example and Source

This is an effect that I have seen on some Flash sites so I thought I would deconstruct it. To be honest, I’m not sure I like the effect, but with some tweaking it could be useful. Basically you have a menu of images or icons that react to the proximity of the mouse. If the mouse is close enough to a particular menu item, that menu item will snap to the mouse and follow it. When the mouse gets too far away the item will snap back into its original position.

In this example I created a nice rollover effect using blend modes. You can see how I created it by looking at the FLA file. All the ActionScript code is located in an external Document Class for easy viewing. I was planing on doing a tutorial on this but have decided to instead work on a multi-part tutorial on using AMFPHP. Look for that very soon!

You can download a ZIP file containing the FLA and the external AS file. If you just want to see the ActionScript, then you can view it below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package
{
    // Import Flash classes
    import flash.display.*;
    import flash.events.*;

    public class ProximityMenu extends MovieClip
    {
        private var ia:Array;
       
        public function ProximityMenu():void
        {
            ia = [im1, im2, im3, im4];
            for(var i:uint = 0; i < 4; i++)
            {
                ia[i].buttonMode = true;
                ia[i].ox = ia[i].x;
                ia[i].oy = ia[i].y;
                ia[i].tx = ia[i].ox;
                ia[i].ty = ia[i].oy;
                ia[i].addEventListener(MouseEvent.ROLL_OVER, onOver);
            }
            stage.addEventListener(Event.ENTER_FRAME, onMove);
        }
       
        private function onOver(e:MouseEvent):void
        {
            e.target.gotoAndPlay("over");
            addChild(MovieClip(e.target));
        }
       
        private function onMove(e:Event):void
        {
            for(var i:uint = 0; i < 4; i++)
            {
                var dist:Number =  getDist(mouseX, mouseY, ia[i].ox, ia[i].oy);
                if(dist < 70)
                {
                    ia[i].tx = mouseX;
                    ia[i].ty = mouseY;
                }
                else
                {
                    ia[i].tx = ia[i].ox;
                    ia[i].ty = ia[i].oy;
                }
                ia[i].x += Math.round((ia[i].tx - ia[i].x) * 0.3);
                ia[i].y += Math.round((ia[i].ty - ia[i].y) * 0.3);
            }
        }
       
        private function getDist(x1:Number, y1:Number, x2:Number, y2:Number):Number
        {
            var dx:Number = x2 - x1;
            var dy:Number = y2 - y1;
            return Math.sqrt(dx*dx + dy*dy);
        }
    }
}

Hope you enjoy it!
Lee


Video From Richmond Flash User Group

Last night I had the pleasure of speaking to the Richmond Flash User Group (FDUG). There was a great turnout and the crowd included both beginner and expert Flash users. I covered the all the new features in Flash Player 10 and then showed a sneak peek at Flash CS4. Both those things combined made for an entertaining talk.

The FDUG is run by Lou Barber and Brandon Ellis. After the meeting I got a chance to sit down with Lou to do an interview. He has a very interesting past and he definitely didn’t follow the traditional path most people take to become a Flash professional. Check out the interview below:

If you are in the Richmond area you can visit the user group every 3rd Thursday of the month. Get more information on the FDUG website.

Lee


1 - 5 of 9 Prev 5Next 5