Search Flex Components Free

Custom Search

December 9, 2007

Hello World with Openamf

What is openamf?
Openamf is the Java open source implementation of Flash Remoting, and was released based on the amfphp port. If you don't know what Flash Remoting is, read the beginning of this tutorial Don't know exactly the status of the project as writing this (www.openamf.org seems to be not online) but you can find it at Sourceforge.net , also mentioned in osflash

If you're newbie to remoting area and are not specially involved with Java, I recommend to begin with an easier library like amfphp



Java and Flash developers

One of the cumbersome of using Java is the relatively complex setup of Java applications, with different steps based on the container. J2EE helps on this, exposing a more standard framework to follow for web developers. Also Java is not a common shared hosting offer, and this make sense because the power of java and his multithread run shines in big applications or when a lot of traffic is expected, due also to the live of servlets in memory. Usually little-medium applications fits fine in more straightforward languages like PHP. So freelancers developers not involved in big corporations are not usually faced to Java, and it's a shame, because it's a great language. But the grow of ActionScript from AS1 to AS2 force coders to write in a more Java-like (or should say OOP-like) way, so Java seems more familiar to them. And AS3 will reinforce this being a really truly class based language (in fact, not compatible with previous versions of the Flash Player) All of this make the jump to Java less heavy for actionscript coders, at least with Java in relationship with Flash.

Being Java a wide field, probably Flash developers will be faced first in data exchange with Java. This could be done in many faces, in example name/value pairs could be solved with some jsp file, but the really power of data exchange is exposed trough Flash Remoting. Even java can map ActionScript classes to Java classes whit out problem, something that arises as a problem in the first implementations of other Remoting libraries like amfphp (last versions solve this) Also since the gateway runs as a servlet, is really fast in doing his work (except the first time of course)

Last but not at least, there's hard to find tutorials about the topic. The openamf team did a great work with this library, but there's some lack of tutorials (for Java newbie's like me) and luckily I find some of my friend Carlos Rovira, one of the openamf very first adopters. Anyway most of the info for this tutorial is based on the excellent french site wiki-media (don't know the author) that you can read if french is more easy for you. My version have minor changes just to adjust to the other Hello World examples on this site

Requirements

To run this example you need

- Macromedia Flash MX 2004 or above
- Tomcat webserver (if you use other container, it's up to you to adapt the deployment) For developing locally in Windows, I recommend XAMPP Tomcat installer , specially if you're using the XAMPP distribution of Apache-PHP-MySQL
- Openamf distribution.
- Remoting AS2 classes from http://www.macromedia.com/software/flashremoting/downloads/components/.
- Not necessary but used here as the java editor for this tutorial, Eclipse

Here's our working example and the source files:

Related Flex Tutorials