Posted by Fixdit on April 6, 2008 at 12:03am
I followed the Flash8 tutorial and wanted to get the SWF I outputted originally calling the node.load service to pick up the custom recipes service instead. Below is my stab at it, but it's not working. How would I access a custom service, or take this Flash example further?
// Picking up a Drupal node with flash remoting
// Drupal must be set up with Services module enabled
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.debug.NetDebug;
// expose debugging info to clientside "NetConnection debugger" utility
mx.remoting.debug.NetDebug.initialize();
// create, position, and set params on three dynamic text fields: status, node-title, and node-body
var tf:TextField = this.createTextField("status", 10, 0, 0, 200, 200);
var ntitle:TextField = this.createTextField("nodetitle", 11, 0, 50, 200, 200);
var nbody:TextField = this.createTextField("nodebody", 12, 0, 100, 200, 400);
ntitle.html = true;
ntitle.multiline = true;
nbody.html = true;
nbody.multiline = true;
nbody.wordWrap = true;
// establish connection with remote service gateway in Drupal and specify service
// - /services/amfphp is AMFPHP in Services gateway
// - node is one of the two default, exposed services in Services module. The other is view.
var recipe:Service = new Service("http://localhost:8888/drupal-5.7Test/services/amfphp", new Log(), "recipe", null, null);
// call service method
// - load is one of three methods on the default node service
// - pass in which node to load (hard coded "1" here for node 1)
// - optional additonal param to node.load is what fields to return (like in a view?).
// -- array of field names: node.load(1, ['title', 'body']);
// -- default is to send the entire node. This example does that.
var pc:PendingCall = recipe.all(1);
// set up response handler functions
pc.responder = new RelayResponder(this, "getData_Result", "getData_Fault");
// set default status text
tf.text = "no response from server yet.";
// success result handler
function getData_Result( re:ResultEvent ):Void {
// re is the object containing the response
// two properties you can count on being populated for any node are re.result.title and re.result.body
tf.text = "response:";
ntitle.htmlText = "<b>Node Title:</b><br/>" + re.result;
//nbody.htmlText = "<b>Node Body:</b><br/>" + re.result.body;
}
// failure result handler
function getData_Fault( fe:FaultEvent ):Void {
tf.text = "error";
}Please Help! :O

Comments
No response from server
I can't seem to debug this becuse there isn't a response from the server. No errors, but nothing happens?
Custom Service set up, too?
Have you written a Custom Service called recipe that defines a method called 'all'? Did you try testing your service method (recipe.all) in the Services Browser bundled with the Services module? Do you have your site set up to allow anonymous users to access Services (in the permissions settings)?
If you are getting the response you want in the Services Browser, the next step is to make sure that you are able to connect Flash to your Drupal installation (try using the standard node.load method to test).
B.McMurray
B.McMurray
I had access for anonymous,
I had access for anonymous, and tested the service in the bundled services browser. I also got the node.load to work fine. It should just really be a modified version of the "Flash 8 tutorial" example, but with node replaced with recipe.