Legal
The views expressed in this blog are my own and do not necessarily reflect the views of Adobe Systems Incorporated.
Search
January 30, 2007
Flash, Flex and PHP Just Got A Huge Boost
Using Flash and Flex with a PHP backend just got a whole lot faster. Patrick Mineault, who runs the AMFPHP project, has released a new version of AMFPHP 1.9, beta 2 now. However, the real big news in his blog post was the news that there is now a C based AMF extension for PHP. According to his tests, this is up to 100% faster than using the PHP version of the AMFPHP library. In fact, his tests show that it takes less than 1 second to encode and send 100,000 array elements, each containing an object with 3 fields (7.3 MBs of data). Head over to his blog to read more about it.
January 23, 2007
Develop With PHP? Are you in the PHP Throwdown?
Do you develop applications with PHP? Have you entered in the PHP Throwdown? The PHP Throwdown is a contest where PHP developers have 24 hours to build an application, based on a concept or categories that have yet to be announced. The rules for the contest outline everything that you need to know. You only have 24 hours, you can code in teams, the app must be written primarily in PHP, but you can use Flex for the front end (if you're an experienced PHP developer then you know that Flex works great with PHP, can make your app look awesome and takes very little coding time, right? :) ).
Adobe is sponsoring the event, with a copy of Flex Builder with Charting to members of the winning teams. Check out the other prizes as well - pretty impressive!
There are a hundred teams entered already, if you haven't got your team ready, what are you waiting for? Sign up now. The PHP RIA SDK Mailing List is a good place to find other team members.
January 9, 2007
Updated PHP RIA SDK - Download Now
I have updated the PHP RIA SDK to include new releases of AMFPHP (v 1.9 beta) as well as the latest WebORB for PHP release from the Midnight Coders (1.3.2). The free (as in speech) SDK is available now from the Adobe Flex Developer Center. You can join the mailing list to ask questions about the SDK, or if you want more information on connecting PHP and Flex together.
There is a lot of exciting work going on in the world of PHP and Flex. I'm going to have some more great news to share with you later this month.
If you'd like to hear more about my thoughts on rich Internet applications, and what I think the future is for PHP, please come listen to me talk at one of the following conferences: Vancouver PHP Conference, PHP Quebec Conference, and PHP|Tek in Chicago.
As rich Internet applications start to blur the lines between desktop and web applications ( see my recently started blog RIApedia for great examples) , having a powerful client side tool that allows you to build attractive applications quickly will become even more important. Flex fits that bill perfectly. Add on a powerful, server side programming language with millions of developers, and you've got a very powerful and compelling solution.
I'm anxious to see applications that combine PHP and Flex. If you're building some, please comment in my blog or use the Contact Us page at RIApedia to let me know about it.
December 18, 2006
PHP and Flex Together in Portland
If you live in Portland, OR and would like to learn more about how PHP and Flex can work together, then you should check out the January Portland PHP user group meeting. Pete Mackie, who has contributed a ton of code, documentation and help for the PHP RIA SDK will be on hand to present how the two technologies can work together. Details for Pete's talk are available online. Rumors has it that he might have a few Flex / ActionScript posters to give out.December 13, 2006
Presenting Flex and RIAs at 2 PHP Conferences in early 07
In the past week I've received news that my proposals to speak at two PHP conferences have been accepted. I'll be speaking in March at the PHP Quebec Conference in Montreal and in May at the php|tek PHP Conference in Chicago. I'll be speaking about why PHP developers should be interested in building rich Internet applications, and how to build rich Internet applications with Flex and Ajax and PHP on the backend. The talks will be similar but not identical to the one I gave at the Zend PHP conference a few weeks ago.December 12, 2006
AMFPHP Adds AMF3 / Flex Support
The AMFPHP project, headed by Patrick Mineault, has added support for AMF3, the newest AMF protocol that's used by Adobe Flex and ActionScript 3. (There's a preview release of ActionScript 3 for Flash Professional on Adobe Labs.)
This means that developers now have 3 choices when choosing which PHP package to use for Flex remoting. AMFPHP, SabreAMF and WebORB from the Midnight Coders all offer AMF3 support. They are all open source projects, with the WebORB project being the only one backed by a commercial entity.
Remoting scripts like these allow PHP developers to write applications that can translate PHP objects directly into ActionScript objects in Flex and Flash projects. Without these projects, PHP developers can still build solutions that output XML (REST interfaces), and then read in that XML with Flex and ActionScript directly. However, using one of the above projects allows you to bypass serializing data into XML and then deserializing it on the client - you can transfer objects, arrays and other data types directly from the backend server to the Flex / Flash application.
What's this mean for developers? Although its more complicated to learn, its more powerful than transfering XML data... For example, when querying a MySQL database, you can transfer the mysql_result object back to the client directly: it will be available to you as an array, and you can access the items in the array directly, without having to decode any XML.
Developers interested in building RIA solutions with PHP should check out the PHP RIA SDK by Adobe. This open source project contains libraries and a number of samples that show PHP developers how to build rich Internet applications with Flex, Flash and the Spry Ajax framework. There's also a mailing list available.
technorati tags:php, flex, amfphp, sabreamf, midnightcoders, phpriasdk
November 8, 2006
Introduction to Adobe Flex Builder for PHP Developers
If you were listening to my talk last week at the Zend PHP Conference in San Jose, and were interested in Adobe Flex, here's how you can get started with Flex Builder and PHP.
1. Download Adobe Flex Builder. The trial is available for Windows, or for Mac.
2. Watch this episode of Flex TV, created by Ted Patrick. This is a great introduction to Flex Builder.
3. Download the PHP RIA SDK by Adobe. This SDK contains libraries and samples that help you develop Flex applications that connect to PHP backends. The SDK is actually an open source project that you can contribute to. The project is hosted at Google Code.
4. Join the PHP RIA SDK by Adobe mailing list at Google Groups. Participate in the group - ask questions, send feedback on the product etc...
5. Read articles on the Flex Developer Center, and in particular the PHP page of the Flex Developer Center.
6. Check out Flex.org, a great community site with many resources for Flex developers.
technorati tags:php, flex, flextv, phpriasdk, flexbuilder
November 7, 2006
Using Flex 2 and SabreAMF Together
If you attended my talk at the Zend Conference, then you know that one of my preferred methods of connecting Flex to PHP directly is through WebORB for PHP by the Midnight Coders. However, there are other solutions out there. Renaun Erickson has an article up on the Flex Developer Center that shows how to integrate Flex 2 with SabreAMF.
Renaun's example is in the PHP RIA SDK by Adobe project, hosted at Google Code. I need to update the .zip file to include the sample, but if you're connecting via SVN to that repository, his sample has been added. Subscribe to the PHP RIA SDK by Adobe mailing list if you have any questions about the samples included in that SDK.
If you would like to contribute articles and content to the Flex Developer Center, then please feel free to contact me by email, or by posting a comment in my blog.
October 4, 2006
Using Flex to browse a MySQL database using PHP - Updated PHP SDK
I have created a sample Flex application that lets you browse your MySQL databases and allows you to do simple filtering on that data. The application is part of the PHP RIA SDK by Adobe that I've updated today. It also includes some new samples and libraries, mostly done by community members. Pete Mackie contributed a sample using the WebORB for PHP library which is in the samples/flex/simple_weborb_php directory. The Weborb for PHP library is now also included in the SDK, under the libraries/weborb directory.
The Flex MySQL browser is not meant to be a replacement for PHPMyAdmin, but I find it faster for browsing data. PHPMyAdmin does much more than this simple application, but if you're looking for a piece of information in a database, you may find it faster to use tthis Flex application.
If you would like to extend the Flex MySQL browser, you can join the Google Code group for the PHP RIA SDK by Adobe and / or the Flex / PHP mailing list at Google Groups.
I'll be showing off this and more at the Zend / PHP Conference later this month in October.
Please post issues with the SDK in this blog.
September 13, 2006
Adobe Gold Sponsor of Zend / PHP Conference
I'm happy to announce that Adobe will be sponsoring the Zend / PHP Conference and Expo in San Jose in late October. I have a speaking session there on Rich Internet Applications, and we'll have a booth where we'll be showing off integrating Adobe Flex with PHP, using open source tools such as AMFPHP or WebORB from the Midnight Coders.
If you're planning on being in the San Jose area in October, you should consider attending the PHP conference. There are only 2 days left to take advantage of the early-bird discount and save $200.
technorati tags:adobe, php, flex, weborb, amfphp, zendcon, zendcon06
August 17, 2006
Updated (unofficial) Adobe PHP SDK
I've updated the (unofficial) Adobe PHP SDK to fix some problems after the initial release. Turns out a few files were missing from the .zip file, and some files were misnamed. I've fixed these problems and also added in a new, more simple sample to show how Flex can retrieve XML data from a PHP backend, without requiring the use of a MySQL database. Finally, I've also removed the .svn files from the .zip file, reducing its size to only 1.5 MB.
You can download the updated .zip file here.
If you would like to contribute to this project, please:
- Join the mailing list at Google Groups.
- Email me to request access to the SVN repository at Google Code (posting a reply in this blog will do the same thing).
August 14, 2006
Announcing the (unofficial) Adobe PHP SDK
Today I'm happy to announce that I've started a new project called the (unofficial) Adobe PHP SDK, which is intended to enable PHP developers to build solutions with Adobe RIA technologies quickly. The (unofficial) Adobe PHP SDK contains samples and libraries that show how to connect to a PHP backend system with either the Adobe Spry Framework (for Ajax applications) or Adobe Flex (for Flash based applications).
You can download the adobe_php_sdk.zip file immediately, extract it and explore the samples and demos immediately.
In true open source fashion, all the code in the project is currently available in various open source licenses, and the content for the HTML page is available under the Creative Commons license.
There is a project hosted at Google Code for the Adobe PHP SDK, and a mailing list at Google Groups as well. Developers are encouraged to participate in a number of ways:
- Test out the samples in the project.
- Develop cool new samples to include in the project.
- Add cool features to samples already in the project.
- Improve the look of samples already in the project.
- Add links to great resources for PHP developers.
technorati tags:adobe, ria, ajax, php, spry, flex
Blogged with Flock
July 25, 2006
Ajax, JSON, PHP, and Flex together to build a Flash-y Ajax site
In honor of the O'Reilly Open Source conference that I and other Adobe people at attending, I'm happy to show an example of building out a site that combines Ajax, JSON, PHP, and Flex into one application, with 90% of this being done with open source software (the only piece that is not open source, but is free (in terms of cost), is the Flex SDK). I've created a site that tries to mimics the experience of Google Finance, a great site that combines Ajax, and Flash together to provide a great user experience.
This tutorial, available online in PDF format with complete source code in this .zip file, shows how to take data from your Feedburner feed, and create an Ajax application that displays the dates and hits of your feed. It will then take that information and populate a graph that we've created with Flex and the Adobe Flex Charting components, using the Flex / Ajax bridge from Ely Greenfield and the JSON ActionScript library from Mike Chambers, Christian Cantrell, Daniel Dura, and Darron Schall.
A working example of this is available on our wickeddemo.com website. (Note that because of load, that example will load data from a static XML file, rather than PHP.)
If you have any questions about this example, please post there here in this blog.
Here is what I've learned in using the Spry Ajax framework and Flex together:
I found it easiest to modify the HTML that gets output by Flex Builder, rather than to reference the built swf file in my own HTML file that I create. If you do that, be sure to modify index.template.html in the html-template/ folder of your Flex project, rather than the .html files in the bin/ directory of your Flex project. The HTML files in bin/ get overwritten when you save and re-build your Flex application, and if you modify those, rather than index.template.html, you'll lose your changes to index.template.html.
I started building out the Flex graph using JavaScript and the Flex / Ajax bridge. I don't recommend that. Build out your entire Flex component in Flex Builder, then simply write functions to pass data to it from HTML. I think that's easier than trying to build Flex components using JavaScript.
Similarly, write functions that closely couple your Flex application to your HTML page. For instance, you'll notice that in my MXML file, I call the chartClicked JS function using:
if( ExternalInterface.available )
ExternalInterface.call("chartClicked",clickEvent.hitData.item);I could have attached an observer to the lineChart instead, using the Flex / Ajax bridge, but I find it easier to get the data items and debug the application in Flex Builder, rather than trying to do that in JavaScript on the HTML page.
The ActionScript 3 JSON library doesn't like new lines or carriage returns in the JSON data. You need to strip those out before sending data from JS to ActionScript over the Flex / Ajax bridge.
- I don't know of any other technologies that I could use in this tutorial to get a higher click through on MXNA. Well, maybe Web 2.0. :)
technorati tags:flex, ajax, php, web2.0, json, adobe, flash
Blogged with Flock
July 17, 2006
How to pass values from Flex to a PHP backend using AMFPHP
I received a comment last week on a previous post on how to connect Flex to a PHP backend using AMFPHP. Here's how you do that:
The commenter in question was trying the following:
gateway.call( "sample.getUsers(varArray)", new Responder(onResult, onFault));
The correct way to send data from Flex / ActionScript to PHP on the backend is by sending the variable to be sent back as the third parameter in the call function, like this:
gateway.call( "sample.getUsers", new Responder(onResult, onFault), varArray);
You should be able to send back arrays as well as more simple variables: integers, strings etc..
technorati tags:flex, php, amfphp, adobe
Blogged with Flock
July 12, 2006
PHP and Flex - JSON, XML or AMFPHP?
I've created a small performance study that shows time to load three different types of data from a PHP backend... Data transfered as PHP objects from AMFPHP, data transfered as XML and data transfered in JSON notation.
The two most popular ways of getting information from a PHP backend to a Flex front end are through the use of XML and AMFPHP. The use of XML requires you to serialize your data into XML formats, while the use of AMFPHP allows you to transfer objects directly from PHP to ActionScript, the Flex scripting language that is similar to JavaScript. I'm not too familiar with JSON, but it seems to be getting a lot of attention for web based applications.
In the tests, I use the AMFPHP library, which you'll need for the AMFPHP test. I use the Zend Framework for the JSON library, converting my PHP Array to JSON. JSON is handled in Flex with the use of the JSON library. The XML test is the simplest of all, simply printing out the XML without having to load any other library or files.
Here's the data (times are in ms):
| # of data | XML | AMFPHP | JSON |
| 5000 | 1903 | 2033 | 2814 |
| 10000 | 3625 | 3495 | 4747 |
| 15000 | 4326 | 4867 | 6830 |
| 20000 | 5939 | 6550 | 9094 |
| 25000 | 6570 | 7942 | 11838 |
| 30000 | 8473 | 10335 | 14512 |
| 35000 | 9594 | 12389 | 17716 |
| 40000 | 10885 | 14651 | 20480 |
As you can see, under 20000 items returned, AMFPHP and XML give you about the same performance, with JSON lagging behind considerably. Above 20000 items returned, XML appears to be a bit better than AMFPHP in terms of performance, with JSON really struggling. (Of course, once the data was in the Flex application, the data could be sorted and filtered with the same performance).
There's lots of things to consider when building out your PHP application with a Flex front end. First of all, you need to consider the fact that with XML, you're respondible for serializing all your data. That may or may not be difficult, depending on what your data type is. In this example, it was relatively easy. AMFPHP may provide some time advantages there for your development, and may be a reason to choose that over XML. As well, you should look at the amount of data that is being transferred. I did all my tests over a local connection. Over the Internet, lattency may be an issue for your application (AMF is a binary protocol, which should make things slightly faster than straight XML encoding).
My next tasks are to see what happens when I do this remotely, and to see what effects any of the PHP accelerators have on the performance
If you'd like to do the tests on your own, here is a .zip file that contains all the useful files: the .mxml application file, the PHP files for printing out JSON and XML data and the file to put in your AMFPHP services/ directory.
technorati tags:amfphp, json, flex
Blogged with Flock
July 4, 2006
PHP / Flex Integration on Pro::PHP Podcast
Last Friday I did an interview / podcast with the team at PHP Architect. You can listen to what I had to say about PHP / Flex integration and other topics, including Ajax integration, ActionScript 3, and other topics. Here is the mp3 file.
June 29, 2006
Why open source developers can be excited about Flex
The goal of open source software has always been to create software that can be free, not in price but in terms of restrictions for use. The availability of source code and the the ability to modify that source code, are important parts in the free / open source software movement.
There is lots of good news with respect to today's Flex launch for open source developers. First of all, the free Flex SDK includes the source code for the Flex components, and allows anyone to compile a Flex application at no cost. You are free to modify the Flex components as you need to. As a developer, you can now build a Flash application in VIM, run it through the compiler in the SDK, which works on Linux and Mac OS X, and build a .swf file. (In fact, if you're using VIM, you might want to check out actionscript.vim by Manish Jethani to highlight your ActionScript source code in VIM). For debugging, you can use fdb, part of the Flex SDK.
The Flex Builder tool is built on top of Eclipse, and we have published the source code for Flex Builder that is derived from Eclipse.
You can create open source Flex applications, and host them over at osflash.org. As a Flex developer, you can enable users to see your source code when they right click on your application ("View Source"). (To enable this, in Flex Builder, choose Project -> Publish Application Source...).
You Flex application will work well with a Java backend system or PHP backend system. For PHP integration, you'll want to download and use the open soure project AMFPHP. You can read my tutorials on how to integrate Flex and PHP on the Flex Developer Center.
Once you've built your application, you can then deploy the file as you would any other web application (likely to an Apache web server), and end users can interact with that application using the free Flash player. Now, the story would be much better if that Flash player was available on Linux (and if it were open source), but its not, at least not yet (available on Linux that is). However, there is a team of talented engineers working on Flash Player for Linux, and you can follow their progress on their blog. Apparently a beta version of Flash Player 9 for MacTel machines should be out soon, with a beta for Linux sometime later this year.
One of the benefits to web applications for Linux enthousiasts has always been the fact that web applications are not tied to a specific operating system - they simply need a web browser to work. The main problem to this model has been the the client: web applications today cannot replace desktop applications, there are too many limitations: local file access, no vector drawing APIs native in the browser, rich media integration isn't supported, JavaScript execution speed isn't the same as compiled code... Flex applications solve most of these problems (a drawing API is available in the Flash player, it can integrate rich media content easily, and it now has a JIT compiler for better performance), and we hope to have a better solution for local file access when we release Apollo (a beta version is expected later this year).
The development of more advanced web applications will continue to help adoption of operating sytems where the Flash Player is available, including Linux. And yes, some developers are working on an open source Flash player.
No, the story isn't perfect, but I think its pretty good. The Flex SDK includes the source code to Flex components, you can build and debug Flex applications on Linux, those applications can interact with an open source backend system (PHP), and end users can interact with those applications at no cost (and in a little while on a free operating system).
BTW: I'm always interested in your feedback on how Adobe can contribute to the open source community.
technorati tags:opensource, php, adobe, ria, flex, web2.0, flash, eclipse, flexbuilder
Blogged with Flock
June 28, 2006
Flex 2 and Future Web Application Development
Flex 2 has been released (CNET coverage here, TechCrunch coverage, Digg the story). You can buy it from the Adobe online store for $499, or $749 with the charting components included. The SDK for Flex is free, as in beer, and there's a free version for Flex Data Services included as well.
This release marks an important milestone for Adobe, as my colleague Bill McCoy has discussed in his blog. Some great web applications have been built with Ajax, but increasingly a number of them are using Flash in areas that the browser cannot handle: rich media integration (You Tube, Google Video and others use Flash to stream video), saving data locally (using the Flash Shared Object), applications that demand higher performance from the client (Flash code is compiled as opposed to Ajax / HTML code). Google Finance is a great example of using Flex and Ajax together, and using Flash where it makes sense (rich graphics drawn on the client).
Yes, you can do some very cool things with Flex right now. However, future development looks even brighter from an Adobe perspective. Apollo will provide additional APIs to web applications that will allow them to integrate into the operating system - users will launch web applications just as they would a regular desktop application (with icons on the desktop / dock / taskbar), the ability to save large amounts of data on the local machine (not limited to the 100K default for the shared object), and perhaps most importantly the ability to develop an application once and then have it run on multiple operating systems (we've committed to making Apollo cross platform). Watch a developer week session about Apollo.
Take that view of the future along with the ability to create mobile applications that run on FlashLite using the same set of technologies. Plus, unlike other languages, building a mobile application for FlashLite will work across a variety of devices - anywhere that the FlashLite player is installed. (Did you miss the announcement of the FlashLite deal with Verizon?) Can you see why JD was so excited about this deal earlier this year?
Here are a few other links about the release:
The source code derived from the Eclipse code is available for download.
A version of Flash Player 9 for Linux is underway. Follow the Penguin.swf blog for more information.
Flex.org is a new site that launched today as well, with resources for the community related to Flex.
FlexCoders.net has a list of Flex developers, if you're interested in building out a Flex project and need some help. If you need work, register there.
For historical Flash designers / developers, Adobe Labs now has a preview of Flash Professional 9 with ActionScript 3.
technorati tags:adobe, flex, ria, ajax, opensource, flashlite, mobile, apollo
Blogged with Flock
June 21, 2006
Download a Flex / PHP Framework, with Source Code
Digg This!When we were at the New York PHP Conference last week, one of the things that struck me was how hard it was to get started with Flex and PHP. You have to go to one site to download Flex Builder, then to another site to download AMFPHP, then build out your application, deploy it etc...
I thought I could help out, so I built a small framework that includes AMFPHP along with some sample files. The Flex application simply displays information from a MySQL database in a Flex application. Very simple. Here's how you, as a PHP developer, get started:
1. Download the Flex / PHP Framework .zip file.
2. Extract the .zip file in your website. The files must be put in a directory called flex_project in your web server's root directory (ie. /flex_project) (the .zip file should create the flex_project automatically, so you should just extract to the root dir.).
3. Create a database called sample, and populate it with the data from sample.mysql in the flex_project directory.
4. Modify the line $mysql = mysql_connect(...); in the file flex_project/amfphp/services/sample.php to be able to connect to your database.
5. Visit http://localhost/flex_project/amfphp/services/sample.php. (Change localhost if you haven't installed on a local machine). You should see some output.
6. Visit http://localhost/flex_project/bin/flex_project.html to see the Flex application in action. You will need Flash Player 9 for this to work properly.
To modify the backend PHP code, you'll want to change the file in flex_project/amfphp/services/sample.php
To modify the front end Flex code, you'll want to download Flex Builder, create a new Flex project with the source of it as the flex_project directory. Then, modify the flex_project/flex_project.mxml file. When you save that file, it will update the .swf file in the bin/ directory, so reloading http://localhost/flex_project/bin/flex_project.html should show you an updated application.
One thing to note that I've changed in this compared to other uses of Flex and AMFPHP. In AMFPHP, I commented out the following lines in amfphp/app/Filters.php:
$outHeader = new AMFHeader("AppendToGatewayUrl", false, "?" . ini_get('session.name') . "=" . $session_id);
$amf->addOutgoingHeader($outHeader);
I'm not too sure what that was doing, but it was calling an ActionScript function AppendToGatewayURL that was blank in my previous tutorials. Doing this removed the need to create a RemotingConnection.as file in your Flex Project. You'll notice this because the connection to gateway.php now looks like this:
gateway = new NetConnection();
gateway.objectEncoding = flash.net.ObjectEncoding.AMF0;
gateway.connect( "/flex_project/amfphp/gateway.php");
gateway.call( "sample.queryDatabase", new Responder( onResultQueryDatabase, onFault ) );
Hopefully this .zip file is helpful for PHP developers. It shouuld be relatively easy to extend this sample to include the ability to create, update and delete elements from the database. If you do that, please send me an updated .zip file to post on this site.
technorati tags:adobe, php, flex, amfphp, mysql, flash
Blogged with Flock
June 19, 2006
PHP Conference in New York - Wrap Up
Allen Seirafi and I attended the New York PHP conference last week, and had a great reception to Adobe Flex. We showed off demos of Flex front ends to Gallery, a new admin screen for Drupal and other cool looking components from Ely Greenfield.
Here are a few reminders for PHP developers:
1. The Flex SDK will be available for no charge. So, if you want to develop cool applications using ActionScript and code in VI or Notepad as opposed to Flex Builder, you can do so at no charge.
2. The graphing components will be not be bundled with Flex Builder, but will instead be sold seperately.
3. You can download Flex Builder, Flex Data Services, the SDK and the charting components right now from labs.adobe.com.
4. If you want to connect to a PHP backend, you'll want AMFPHP. Once you've got that, you'll want to read the tutorials that I wrote on how to integrate that with Flex.
There are already some companies doing cool things with PHP and Flex. Keep me posted on anything that you're developing.
technorati tags:amfphp, flex, adobe, php, nyphp, nyphpcon
Blogged with Flock
June 9, 2006
Record Video From Webcam and Post To Drupal (With Source Code)
For my talk to the Boston PHP user group last week, I built on Chritophe's sample that showed recording video from a webcam, and then publishing that to a Drupal based blog. Here is the code (MXML Format). To get this running, you'll need a copy of Flash Media Server (free developer version available) and a working webcam (I'm not really into error checking :) ). Once you download and install Flash Media Server, in C:\Program Files\Macromedia\Flash Media Server 2\applications\, create a directory called flex_videoconference. A few things to note:
In the source, you'll see:
nc = new NetConnection();
nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
nc.connect( "rtmp:/flex_videoconference");
You need the line ...=flash.net.ObjectEncoding.AMF0 because FMS doesn't do AMF3. The line nc.connect("rtmp:/flex_videoconference"); is equivalent to nc.connect("rtmp://localhost/flex_videoconference"); so if you're connecting to a remote server, you'll want to change localhost, obviously.
The line nsPublish.publish("christophe", "record"); tells FMS to record the stream so you can play it back. Valid values are "record", "append", and "live". The default value is "live". (Lookup NetStream in the Flex help for more information).
Nearly everything works in the publishing method, but I can't figure out how to properly encode the HTML string being sent to Drupal so that it will display the movie properly. I have also created a MediaPlayer.swf video player and put that in my Drupal theme directory, but because I can't get the encoding working properly, then it doesn't matter. If you have knowledge of the BlogAPI for Drupal, please help!
Regardless, even if you don't use it, you've got a way to record video to Flash Media Server and then to play it back in a simple example.
June 6, 2006
PHP Gallery Integration with Flex - With Source Code
Update: I've fixed the links in this to the Flex front end, sorry about that.
I have (finally!) got around to publishing the source code for my PHP Gallery / Flex integration. You can see it in action on WickedDemo.com. The PHP Gallery site is online, and the Flex / Flash front end to Gallery is here. The PHP code is here. When you visit the Flex front end to Gallery, right click on the Flex application and select "View Source" to see the code. Or, just click here to view the source. This is an example of using AMFPHP for integrating Flex and PHP.
May 29, 2006
Join me at the Boston PHP User Group This Week
I'm presenting Flex to the Boston PHP User Group on Thursday. Come on out and join us, I should have some prizes to give away, as well as some cool demos showing Flex / PHP integration. We're starting at 6:30, and it should last about 2 hours or so. Register (for free) here. The location for the meeting is the IBM/Lotus building on 1 Rogers Street in Cambridge , MA. Link to Yahoo Map here.
May 26, 2006
Drupal with Flex Using Flex / Ajax Bridge
I'm a big fan of Drupal, and one of the things that I've wanted to do lately is create a better UI to some of their elements. In particular, the watchdog module that shows you all the activity in your site really annoys me. To sort the elements you need to refresh every page.
Ever wonder what it would look like to use Flex components instead of an HTML table? Well, probably something like this:
May 15, 2006
Passing Parameters from Flex to AMFPHP
I had an email the other day from a developer who was wondering how to pass PHP parameters via ActionScript. The answer is very simple... Let's take a look at some sample code from my PHP Gallery / Flex project:
public function getPhotosForAlbum( AlbumID:int ) : void
{
gateway = new RemotingConnection( "http://localhost/amfphp/gateway.php" );
gateway.call( "embededGallery.getPhotos", new Responder(onResultGetPhotosForAlbum, onFault), AlbumID);
}
You can see in this ActionScript code that the AlbumID is being passed to the "getPhotos" AMFPHP call. So easy, just add the parameters to the end of the RemotingConnection call, as a 3rd parameter.
Hope that helps some of you out!
May 12, 2006
A Flash / Flex Front End to PHP Gallery
A while back, I posted a message on the Gallery forums that I was working on a Flex application that acted as a front end to Gallery. Well, I think I hit a nerve with some people, because I've gotten emails about this every day, asking where the code was, how to help, what it looked like etc...
Well, now that Flex Beta 3 is out, I figured I better spend some time updating the application to get it working. First off, this is a very simple example. If you don't know PHP or Flex, then this isn't for you. This is something to look at and then improve on or use an inspiration for a better solution. Its a very simple application: a drop down listbox that gets a list of Albums from Gallery, and then a datagrid that shows off thumbnails of the photos, depending on which album is selected. I chose to build a completely Flex based application. Others may choose to use the Flex / Ajax bridge to create a Flex theme for Gallery and build the Flash front end using JavaScript. Its up to you.
Here's a screenshot, showing an album with 2 pictures of my cats, Gus and George.

Here's the source files in a .zip file. Use them as you like. The only thing I ask is that if you build something cool with Gallery and Flex, let me know, because many people are interested in this.
Here's what you need to do (I'm assuming you have Apache, PHP and MySQL going already).
1. Download Flex Builder from Adobe Labs.
2. Download AMFPHP from AMFPHP.org.
3. Download and install Gallery from Gallery.
4. Add some albums and photos to Gallery.
5. Extract AMFPHP to your website. I put mine at http://localhost/amfphp/
6. Extract the .zip fileand put embededGallery.php into the services/ directory in your AMFPHP install. Mine was at http://localhost/amfphp/services/embededGallery.php
7. In embededGallery.php, change http://localhost/gallery2 to point to your install of Gallery (I don't understand the Gallery APIs very well... I thought that I could create a full URL to the Gallery images, but it didn't work for me).
8. Create a new Flex project. I called mine FlexGallery.
9. Add FlexGallery.mxml, RemotingConnection.as and Thumbnail.mxml to the root of your FlexGallery application.
10. In FlexGallery.mxml, change http://localhost/amfphp/gateway.php to point to your installation of AMFPHP.
11. Right click on FlexGallery.mxml, choose Build as Flex Application. It should launch a browser that will play your Flex app. It will connect to your local install of Gallery and get the list of albums. Select an album, then your photos should appear below.
12. Profit.
Hopefully this helps out a few people. Again, its very simple. You should use this as inspiration to build a better Flex front end to Gallery.
April 7, 2006
Presenting Flex and PHP to Boston PHP UG
For those of you near or in the Boston area, on June 1st I'll be presenting Adobe Flex and how it integrates with a PHP backend using AMFPHP to the Boston PHP User Group. I'll show off Adobe Flex Builder, the integration with a backend PHP system with AMFPHP, as well as demo the Adobe Flex / AJAX bridge. If I have time, I'll show off Adobe Flex Data Services as well. I had a great meeting with Mark Withington, who runs the group, yesterday at Linux World. I'm looking forward to the talk. If you're in the area, drop by. More details on the Boston PHP UG website.
February 28, 2006
Flex and PHP Using AMFPHP - A Simple Example
In a previous entry, I showed you how to connect Flex and PHP together using XML to transfer data from the server to the Flash client. (Here's the article in PDF format). A relatively simple example, but still useful to a bunch of people. When writing that sample, I thought, there must be a better way to transfer data than using XML. What if I wanted to send an array or an object from PHP through to ActionScript... Could that be done? Well, it turns out that it can be done, and its done using a project called AMFPHP. Using that code, it will convert data objects in PHP to data objects in ActionScript, so you can access them in your Flex projects. Sounds cool? Well, it is. Using that technology, and allowing a few hours for a small learning curve, I was able to build a Flash based front end to my Gallery website.
As a follow up to my first article, I've created a second article that shows how to connect AMFPHP to a Flex front end for development of Rich Internet Applications. The tutorial is extremely simple, but still shows the power of PHP and Flex. (The code is also available in a ZIP file). I'll post the files for my Gallery front end in a few days, once I've had a chance to clean it up a bit. I'm hoping to get this up on other PHP sites and our own developer centers, so I appreciate your feedback with this early draft of the article.
Please use this tutorial as a getting started guide to developing really cool things with Flex and PHP. If you're looking for suggestions, I think the best place to start is with existing PHP projects, and providing a Flex front end to them. Who wouldn't want a user admin application for Drupal written in Flex, rather than HTML? Or a Flash front end to PHPMyAdmin written in Flex (there's already one written in Flash). Get started, and let me know what you're up to.
Lastly, I'd like to thank some people who helped me create this sample. They're thanked in the PDF article, but here's some blog thanking:
Patrick Mineault - http://www.5etdemi.com/blog/ - AMFPHP guru.
Jesse Warden – http://www.jessewarden.com/ - Had some great samples up showing how to integrate Flex and AMFPHP.
http://www.tweenpix.net/blog - A blog in French where I got the ActionScript code for RemotingConnection from (http://www.tweenpix.net/blog/index.php?2006/01/03/543-hello-world-en-amfphp-avec-flex20)
(Links fixed to Gallery and FlashAdmin)