Archive for June, 2007

RubyAMF-0.9.8

K folks. One more huge bug fix. Plus a couple more helpers.

#Fix result set with Flash 9 issues. Result sets were being returned to Flash 9 as mx.remoting.RecordSet. Now it’s returned as fl.data.DataProvider. See this post for more info

#Added custom recordset_format header support. You can change the recordset format by adding the appropriate header to the netconnection. EX: service.addHeader(‘recordset_format:fl.data.DataProvider’,false,false); OR service.addHeader(‘recordset_format:mx.remoting.RecordSet’,false,false);

#Made sure the _explicitType member variable isn’t being written in the actionscript object when serializing AF3 or AMF0

#added db_error_logger helper class. Use for easily logging errors in services

#added error_notification class. Use for sending emails when errors happen, Note this is just stub code for now

Have a look at the code profiling that’s been going on to optimize RubyAMF. Finding bottlenecks, optimizing everything I can. There have been a number of requests for a C extension, and yes let me tell you that it will happen. But I figured before I put all my efforts into that I wanted to make the existing ruby code base bug free and as fast as possible. That way it will always be blazing fast.

I’ve got a few things left to do before considering this for a version 1.0 final release:

1. Mongrel Daemonizing. (Something wrong with mongrel daemon right now)
2. Windows services
3. Stress testing the crap out of each server

That’s it for now. Download it

Hiring at Crispin Porter + Bogusky

Crispin Porter + Bogusky is hiring Flash and Flex geeks. Here is a general job specification.

Flash Actionscript Programmer

Crispin Porter + Bogusky (CP+B) is looking for talented, innovative Actionscript programmers to develop sophisticated Flash-based web, mobile, and standalone applications. A candidate for this position thrives in a creative, idea-driven culture and has a passion for developing groundbreaking interactive work. It’s great opportunity to push the boundaries of Flash development with the creative minds behind subservientchicken.com, comeclean.com, vwfeatures.com, vw.com redesign and Burger King Xbox games, recent winner of the Titanium Grand Prix. And it’s a great opportunity to work on projects for leading brands, including: Volkswagen, Burger King, NIKE, Coke Zero, Sprite, Haggar, Geek Squad and Ask.com.

Requirements

-Expertise with OOP programming techniques and RIA/SOA architecture.

-An innovative, hacker mentality, and an interest in experimenting with new technologies.

-Experience developing games and data driven applications.

-Must work well in a team-oriented, collaborative environment.

-Meticulous attention to detail when working with designers on motion graphics, video, and sound assets.

-An obsession for high-quality, on-time deliveries.

-Experience with wide range of internet technologies, including, Flash Remoting, Flash communication server, XML, JavaScript and HTML.

-Knowledge of how to make things work across various OS and browser platforms.

Salary based on experience. Benefits include: 401K, Medical / Dental, and Relocation package.

Please send resumes and sample work to Monica Torres (mtorres at cpbgroup dot com).

Hope to hear from some friendly talented people.

Do You Have a Mustache?

I have to point this site out. Check out Burger King’s Pet Moustache.. This site is for their recent “Western Whopper” campaign. It’s really cool, and really funny.

I wanted to point this site out as it is a really good example of Flash Remoting in action. A few flash devs here at CP+B, plus myself built this site. Hang on, this isn’t a shameless plug. It’s really interesting the way it’s built.

I built the backend for moustache, using AMFPHP plus the C extension. What’s really cool is how you can “save” your mustache and come back later to edit it. We achieved this by serializing every hair follicle on the stache. That’s right, an average of 600 hairs on each stache with roughly 6 properties that define the follicle. For each hair there this an object ({color:…,curve:…}) that define it’s behavior. It’s pretty simple but a really creative way of creating persistence for your mustache so it’s editable later.

So when a mustache is saved, an array of 600 or so objects is sent to the server and serialized as PHP, then stored on the file system in a file. When you login or view a singing telegram, that mustache is retrieved from the server, sent to flash, and re-rendered with the drawing API.

The mustache is saved for you on the server at intervals of 2 minutes. We also implement shared objects so that if the shared object is newer than what is saved on the server, we grab the SO data and use that instead.

The site also has some tamagachi functionality. If you sign-up, then login a week later your mustache will have grown!

Here is a singing-telegram I set up. Pretty funny. Check it out: http://www.petmoustache.com/singing_telegram.html?hash=a4731ae&a=true

Go make yours and put your link in the comments. Let’s see those Mustache’s

RecordSets for Flash 8, Flash 9, and Flex Messaging. Slight Hiccup with Flash 9.

After doing some testing with Flash 8 / Flash 9 / Flex 2. I’ve found that there are three situations needed when handling result sets from a database and transforming them into their respective flash types.

With flash 8, mx.remoting.RecordSet is always used – simple. With Flash 9; if you’re using NetConnections the AMF version varies depending on the parameters you send in the request (even if you specify objectEncoding as 3, it will use AMF0 for some data types). Which creates a slight hickup for Flash 9 recordsets. Keep reading.

Take this for example:

import org.rubyamf.remoting.ssr.*;
var service = new RemotingService('http://localhost:8024/gateway.rb','org.rubyamf.amf.TestObject', 3)
service.passObjectThrough([""],onresult,onfault);

This example makes the request as AMF0 even though I specify AMF3 to the NetConnection#objectEncoding property. Not a huge deal. AMF0 is slightly faster anyway. I don’t mind.

Now test this:

import org.rubyamf.remoting.ssr.*;
var service = new RemotingService('http://localhost:8024/gateway.rb','org.rubyamf.amf.TestObject', 3)
var x:XML = new XML('someXML');
service.passObjectThrough([x],onresult,onfault);

This service call sends AMF3 to the gateway. Thats fine too.

Now test this:

import org.rubyamf.remoting.ssr.*;
var service = new RemotingService('http://localhost:8024/gateway.rb','org.rubyamf.amf.TestObject', 3)
service.getMysqlResult([],onresult,onfault);

This service call uses AMF0 to get a mysql result. This created a problem in RubyAMF but not anymore. Because it’s AMF0, the response is being cast as an mx.remoting.RecordSet. Which in Flash 9 doesn’t work. What it should be is fl.data.DataProvider. So the fix is to specify in the gateway what type of RecordSet you want to use with Flash (being Flash 8 or 9).

There is no way to sniff it and figure it out programatically because the information I have about the request is the content-type of x-amf. So the only solution is to manually set that recordset format. So that being said. There is now a way to set that property, in each respective gateway for webrick|lighttpd|mongrel.

I’ve tested this with AMFPHP and it is the same problem. If no one minds I’d fix it in 1.9 beta 2. Patrick?

Flex messaging with the RemoteObject tag doesn’t create a problem as it is always AMF3 and I can sniff when it is flex messaging – triggering mx.collections.ArrayCollection to be used for the return type. No problem there.

So with Flash 9, when you get a result set, you use the DataProvider class to populate a datagrid like so:

import fl.data.DataProvider;
mydg.dataProvider = new DataProvider(re.result);

With Flash 8, you still use RecordSet.

import mx.remoting.RecordSet;
mydg.dataProvider = RecordSet(re.result);

But you need to specify what recordset format you’re using in the gateway.

If you’re using Flex 2 and Messaging you would use an ArrayCollection. This is handled by default, no change is needed in any gateways.

import mx.collections.ArrayCollection;
mydg.dataProvider = ArrayCollection(re.result);

Note that with Flash 9 you have to actually create a new DataProvider instance and pass the results to it. With Flex 2 you can just cast the result into an ArrayCollection.

So, I’m not in any way saying there is a problem with NetConnection. It works as expected. But because most of the time with NetConnection the request will be AMF0 data, a special case has to be added to our remoting gateways to give Flash 9 a usable collection of objects to populate the DataProvider instance with.

As mentioned above, a fix in AMFPHP is needed so that returning mysql results work in Flash 9 using NetConnection. Not sure about any other remoting gateways. Give it a shot in yours if you’re developing one. If this somehow already work with AMFPHP, let me know.

RubyAMF-0.9.8 Will have this fix in it.

RubyAMF Forums and Lists

I just installed the Vanilla forum for RubyAMF. Also if you don’t follow this blog or rubyforge much you can subscribe to the mailing list.. I make announcements and answer questions anyone might have.

RubyAMF-0.9.7

Another release. I’ve been doing some code profiling and some of the delegation that was being used for reading and writing binary data was slowing things down ever so slightly. One call to read / write some amf was taking 3-5 method calls. I’ve re-factored the de/serializers so that each read / write operation takes one method call.

Release Notes:
#Fixed more object/array issues with AMF0 and AMF3

#Fixed AMF0 custom VO class mappings. VO class path: /rubyamf/services/vo (use Object.registerClass from Flash)

#Changed AMF0 objects into OpenStructs to match AMF3 objects

#Got rid of ASObject class, not needed anymore

#Took out heavy delegation to Binary Reader/Writer mix-ins. Was generally about 3-5 method calls before any actual write/read operation was happening. Performance Performance Performance! Now there is one read_write mixin in the de/serializers. One method call to perform the operation.

Download it and enjoy!

RubyAMF-0.9.6

Just released 0.9.6. This fixes 2 big issues I had come across tonight.

#Fixed an issue where AMF3 was being sent but it was being treated as Flex Messaging and should have been straight AMF3.

#Fixed an issue with reading / writing mixed AMF3 arrays and objects. Sending arrays with mixed keys was breaking it. Sending straight objects from Flash was breaking.

Download it

RubyAMF 0.9.5

I just released RubyAMF 0.9.5. Get it here. See the release log for release information.

RubyAMF is under a new license – MIT.

RubyAMF Facelift

Check out the new look on the homepage, and on the blog. The wiki skin is next.

Thanks to Othniel Hazle for helping me tweak the ideas I had. And thanks to Beau Bergeron for help with my logo.

SSR – Super Simple Remoting Updates.

I just put the latest release information on RIAForge and OSFlash. This new release has better exception handling internally, and adds one more remoting call meta property – returnArgs. If specified the arguments you sent with the request come back to your onResult and onFault handlers; could be useful. Also note the custom error object handling, read about it here. Next release I’m probably going to get asynchronous calls working. At this point I don’t think it’s a huge deal though.

http://ssr.riaforge.org/
http://osflash.org/projects/ssr/