2
votes

I'm trying to build a game that sends game play data to a rails app. I've built it in javascript but it's quite obvious that Flash is going to do a better job so now I am about to build it in Flash. Using projects sprouts which is a ruby wrapper to build as3 projects if anyone is interested.

I've done a lot of research on connecting Rails apps with Flash. I actually don't need to use flex but that is the os sdk that sprouts uses. There is WebORB. The turotrials for that are a mess and are really complicated. Then Ruby AMF which has multiple gems and plugins. I'm really not quite sure what to use.

After all, I just want to get something up and running. I just need a .swf to get an array in ruby and then send back a yes or no response that being if the user passed the level or not.

So again I'm looking for a way to connect Flash/Flex with my Rails App. A method that is both easy and going to be around for Rails 3.

1

1 Answers

1
votes

I think that the best way is to have either a simple Rails action that is called via a simple API call. For example (rails):

https://whatever.com/games/new?parameter1=something&parameter2=something&apk=3423aad23h234h2827237322373232234234

where the apk is an api key that you assign to users that are api enabled (in your users controller, for instance). This would keep out casual hacks of your app on the Rails side. Since you're programming both sides of it (the Flash and Rails sides), you could extra security with another hash based on date or something.

For the Ruby array to return to the Flash app, just do something like this to either get back XML or JSON and parse it on the Flash side (simple create action below):

            format.json  { render :json => @this_entry, :status => :created, :location => @this_entry }
            format.xml  { render :xml => @this_entry, :status => :created, :location => @this_entry }