Sign In/My Account | View Cart  
advertisement

Article:
 Putting REST on Rails
Subject: Flash integration
Date: 2006-04-22 15:40:07
From: slipabuck

Hi. I'm building a Flash app that connects to mySQL. I've never done web scripting before, but I picked up enough PHP to do what I need pretty quickly. (Right now, I'm using php.serialize to pass into/out of Flash).


I recently heard about Rails, and though I'd give it a try. I created the library app per this tutorial and a basic Flash frontend tro test. When I POST to localhost:3000/books with xml.sendAndLoad in Flash, it keeps creating empty records. I tried using CURL as per your tutorial, and it worked fine.



Here is my log from CURL:


Processing BookController#collection (for 127.0.0.1 at 2006-04-22 15:22:20) [POST]
Session ID: 610946147ef5047edb648e39e0f8741a
Parameters: {"action"=>"collection", "controller"=>"book", "book"=>{"title"=>"losers", "description"=>"never win."}}
Book Load (0.000000) SELECT * FROM books 
Book Columns (0.016000) SHOW FIELDS FROM books
SQL (0.000000) BEGIN
SQL (0.015000) INSERT INTO books (`title`, `description`) VALUES('losers', 'never win.')
SQL (0.000000) COMMIT
Redirected to http://localhost:3000/book/by_id/8
Completed in 0.04700 (21 reqs/sec) | DB: 0.03100 (65%) | 201 Created [http://localhost/books/]



And from Flash:


Processing BookController#collection (for 127.0.0.1 at 2006-04-22 15:27:16) [POST]
Session ID: 7136b9261bffc44afad273ece4984952
Parameters: {"action"=>"collection", "<book><title>a title</title><description>a description</description></book>"=>"", "controller"=>"book"}
Book Load (0.000000) SELECT * FROM books 
Book Columns (0.031000) SHOW FIELDS FROM books
SQL (0.000000) BEGIN
SQL (0.000000) INSERT INTO books (`title`, `description`) VALUES('', NULL)
SQL (0.000000) COMMIT
Redirected to http://localhost:3000/book/by_id/9
Completed in 0.29700 (3 reqs/sec) | DB: 0.03100 (10%) | 201 Created [http://localhost/books/]



Do you know what would cause the script to recognize the XML from CURL but not from Flash? Any reccommendations? Is it worth doing this in RoR/XML rather than PHP/Serialize?


Thanks much!


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • Flash integration
    2006-04-22 16:05:36 slipabuck

    There's a rule about posting for help with Actionscript - you always find the answer immediately after you ask. I guess putting it in words helps me think of new ways to search for the answer - I don't know.


    Anyway, apparantly there is such an object as XML.contentType in Flash and it need to by "application/xml" for this to work. Sorry for my dumbassity, and I'll try to put together a tutorial after I flesh this out a bit further. =P


    In the mean time, if somebody wants to use this plugin to integrate Rails and Flash, try this actionscript (You need a titlebox and a descriptionbox text field, as well as a sendButton movieclip). Insert this code in the timeline:
    ~~~~~~~~~~~
    stop();
    sendButton.onRelease = function() {
    //send the XML formatted data to the server
    var bookXML:XML = new XML("<book><title>"+titlebox.text+"</title><description>"+descriptionbox.text+"</description></book>");
    trace(bookXML);
    bookXML.contentType="application/xml";
    bookXML.send("http://localhost:3000/books/");
    }


    • Flash integration
      2010-09-04 00:33:23 coco90

      Coach outlet (http://www.coachshandbags.com)


      coach bags (http://www.coachshandbags.com)


      coach outlet store online (http://www.coachshandbags.com)


      I wish you have a wonderful day!Thank you.

      cocokathy90

  • Flash integration
    2006-04-22 15:41:30 slipabuck

    Sorry for the ridiculous spacing. I didn't realize it would do that. =P


Sponsored By: