Flash, Flex, & AMFPHP: RSS Reader Example

Wanted to not only learn bindings in Flex, but see how they compared to Flash in terms of actually using them and seeing their benefits side-by-side to Flash. The fact you can bind any property to any property of a GUI component rocks the mic!

So, since both of these RSS reader’s hit the same AMFPHP webservice, I figured I’d just upload the source so you could see how to use Flash & Flex with AMFPHP since there aren’t many examples around on using either, ecspecially for using RemoteObject with something other than Java, in this case PHP via AMFPHP without using the Flex server. Additionally, this is a simple enough example in Flex to see how the bindings work.

You’ll have to setup AMFPHP yourself as the SWF’s are not using the Flex server as a proxy, and thus will not work unless hosted on www.jessewarden.com because of the security sandbox. Unless you spoof this, or use AMFPHP to actually forward the request (which is easy I believe), or just setup and run localhost.

Here’s how they work:
– Flash or Flex hits the AMFPHP gateway via Flash Remoting, and calls the getRSS1Feed method in a PHP class called RSSReader.
– The RSSReader class’ method, getRSS1Feed takes 1 parameter, the URL to an RSS feed, and uses Magpie to parse it into a usable object. It then returns this object in the function.
– AMFPHP sends the object back to Flash or Flex.
– Flash or Flex then displays the RSS feeds and allows you to cycle through the blog entries.

Needless to say, the Flex one was faster to build, and more fun!

The Flash One

The Flex One

Files & Links

Source Files

Magpie PHP RSS Parser (his files need to be next to RSSReader.php in the AMFPHP “services” folder)




10 Replies to “Flash, Flex, & AMFPHP: RSS Reader Example”

  1. Have you played around with complex objects in AMFPHP? I have had little luck with things like circular references. However works like a charm in flex (too bad it costs so damn much!)

  2. Mark: The thing is 1) PHP’s object orientation features are weak, and 2) the unserializer and serializer are the bottleneck in AMFPHP. So if I’m going to add support for circular references in AMFPHP, that means I will have to check each object you add to the return stack against a stack of already serialized objects which will slow the thing down; and that will probably only work correctly with PHP5. I can’t add circular references from Flash either because the current implementation involves associative arrays for legacy reasons and that just wouldn’t make any sense. Why you would want to send objects that reference themselves over the wire is beyond me anyways.

    jesse: I’m not so sure about the sandbox thing. To my knowledge, since it runs on NetConnection, it has the same sandbox as FlashCom, ie. none.

  3. Flashcom’s security sandbox is controlled server-side, not client side (unfortunately; I’d prefer to have both).

    I’ll have to upload these SWF’s to one of her majesty’s domains and see what happens.

  4. Yeah man, just tested, it dosn’t work at all when the SWF’s, both of them, are hosted on another domain when I delete my crossdomain.xml file on dev.jessewarden.com.

    <?xml version="1.0"?>
    <allow-access-from domain="*" />

    As soon as I put that file back up there, it works fine. So again, they are affected by the security sandbox without a policy file. Since I have one up on my site, anyone can hit my service, so I was wrong you couldn’t, hehe, because I forgot my policy file allows everyone to do so. That’s ok, though, I want it to be easy for people to play with.

  5. Hi Jesse,

    This maybe a dumb question, but where’d you get those AS2 remoting classes – I thought I had the necessary, but have just reinstalled and still don’t



  6. Hi,
    I have a couple questions for you about your Flex RSS Reader example. I am trying to simulate the Flex demo, but my SWF doesn’t display anything. Might this have something to do with the security sandbox you mention in the post? Is a Cross Policy file needed for this app to work? Will I have to configure AMFPHP to forward the request? Will JesterXL reply to this post before Gotham City is destroyed? jk

    My service is working fine in the service browser, and the path to my gateway is specified as my RemoteObject correctly in the mxml, but the swf does not load anything.

    Here is my swf: http://masonbrown.us/funplace/RSSreader_flex/flex_rssreader.swf
    Here is my source: http://masonbrown.us/funplace/RSSreader_flex/srcview/index.html

    thanks in advance!

Comments are closed.