Apr 29 2007
Extending Apollo with Ruby using RubyAMF
At the end of my last post about RubyAMF I mentioned that I was particularly interested in how it could be used to extend Apollo applications using Ruby in the same way that Artemis makes it possible to extend Apollo with Java.
Here’s why:
- It enables AMF3 communication between Flex and Ruby.
- It comes with its own webrick servlet, so deploying RubyAMF is dead simple (if you have Ruby installed).
- It’s small: less than 300k. So it’s a quick download.
Here’s an example:
I put together a very simple demo app that uses RubyAMF to extend Apollo. I am calling the app Clairify (because everything needs a name). Clairify allows you to take a screenshot of whatever is underneath it, mark it up with some simple drawing tools and text boxes, and then save it to disk. The concept behind Clairify is that you could use it to quickly provide feedback on an application’s UI.
It would take several steps and downloads for many people to run the app, so I’ve put together a short video.
Here is a quick overview of what is going on in the video:
- I launch Clairify.
- When Clairify launches all you see are the controls. The rest of the app is transparent.
- I then bring up the interface that I want to capture (the login screen of my simple issue tracker).
- I click the capture button. This calls code in Ruby (see below) that captures the screen and saves the image to a PNG that Apollo loads.
- I add some comments to screen.
- I click save, which uses Apollo’s File API to save the marked up image to my desktop as PNG.
- I open up the PNG in Fireworks.
If you want to take a look at the Apollo source code, click here. (If you really want to know how to run this on your own machine let me know and I will put together some instructions).
And, here is the Ruby code:
require 'win32screenshot'
require 'RMagick'
include Magick
class CaptureService
def screenCapture
width, height, bitmap = Win32::Screenshot.desktop
img_lst = ImageList.new
img_lst.from_blob(bitmap)
img_lst.write('public/screen.png')
true
end
end
Credits:
Clairify is based on the ScreenPlay app that is avalable on Adobe Labs.
