Flash And Drupal With XML-PRC (Communicating from Flash Actionscript to Drupal)

Dealing with Flash And Drupal With XMLprc. You firstly need to turn on the server and "node" service for the service module, and turn off api key, sid, etc, grant permissions, in the service settings. You need to install XML-PRC client of flash which can be downloaded from:- http://sourceforge.net/projects/xmlrpcflash XML-RPC Client for ActionScript and following xml methods can be easily used:
- node.load
- node.save
- user.login - system.connect

The flash app supports api_key and sessid, please make sure that they are enabled in you drupal xmlrpc service.Following code will go in action script part of flash.

Setup Instructions:-

Step 1)Flash Setup
1. Create an empty folder on your computer entitled "example". This folder will house the working Flash and library files needed to connect to the Drupal XML-RPC interface.
2. Visit: http://sourceforge.net/projects/xmlrpcflash and download the "XML-RPC Client for ActionScript 2" (xmlrpcflash_0.9.3.zip). The current version is 0.9.3.
3. Uncompress xmlrpcflash_0.9.3.zip. This will result in a folder entitled "com". Move the "com" folder to your "example" folder. The "com" folder provides the XML-RPC libraries which Flash will use to communicate with the Drupal XML-RPC interface.
4. Create a new Flash file named "test.fla" and save it in the "example" folder.

Flash ActionScript Code:

The "XML-RPC Client for Actionscript" isn"t a terribly complicated beast to tame. To get started, here"s a very simple example. Place the following ActionScript code on the first frame of your timeline. Remember to alter the "url" accordingly.


import com.mattism.http.xmlrpc.Connection; import com.mattism.http.xmlrpc.ConnectionImpl; onLoadListing = function (r:Array) { for (var i = 0; i<r.length; i++) { trace("method: "+r[i]); } }; // the complete url/path to your xmlrpc interface. var url:String = "http://indersingh.com/xmlrpc.php";//PHP site services server var c:Connection = new ConnectionImpl(); c.setUrl(url); c.onLoad = onLoadListing; c.call("system.listMethods");


The end result is a simple list of public methods, returned for posterity sake. What you do with the information is up to you and outside the scope of this document.

To Create a new node:

var node:Object = {title:"Some node",body:"The node body" }; c.addParam(node,XMLRPCDataTypes.STRUCT); c.call("node.save");


Load an existing node from flash action script:- var nid = 100; var fields :Array = ["title","body"]; c.addParam( nid , "int" ); c.addParam( fields , XMLRPCDataTypes.ARRAY ); c.call("node.load");