Friday, August 24, 2007

Flex RemoteObject concurrency

We have just started using amfphp for our Flex projects. For a long time we held off because the PHP remoting options seemed a bit immature. Then we were in the middle of a large project and it wasn't a good time to make the change. During that time we were requesting PHP generated XML using HTTPService. Anyway here we are using amfphp (I plan to write a longer post about that soon). But as part of the change we've also been trialing ServiceCapture (also looked at Charles which is also looked very good). ServiceCapture is a web debugging proxy and it allows you to see all transactions between your machine and the web. It's particularly good for remoting as it shows exactly what the remote gateway is returning to your application.

One thing we noticed was that many of our remoting calls were happening twice. This seemed a bit odd . Turns out RemoteObject has a very useful property called concurrency. For example setting concurrency to 'single' means that only one RemoteObject call is made at a time. Exactly what we needed.

I eventually realised the reason the RemoteObject was getting called twice was that I had a group of RadioButtons with a change event. Selecting one RadioButton changes both buttons in the group and consequently triggers two RemoteObject calls. I changed my change events to click events and the problem was doubly solved.

This small problem highlighted for me how important tools like ServiceCapture and Charles are for Flex work.

2 comments:

KC Kuok said...

good find! btw CF8 has gateways included in the standard edition too, but the price is still prohibitive for most small companies and startups. I wonder whether the onChange events for radio buttons would work in similar fashion for all versions of Flash and javascript (or even in Flex though i would assume Flex and Flash would be the same type of objects, though that may be a dangerous assumption.)

coincidentally i have to write a function which calls a cfm page to update a session variable from javascript as a httprequest, triggered by radio buttons. I shall keep that in mind when i get it done at work tomorrow, you may have saved me some valuable time. ;)

See you soon

geekglue said...

Flash and Flex both compile into a swf. But the difference we are discussing here relates to components. Flex components generally have many more events than their Flash counterparts (if there is a Flash version).