Table of contents
On Flash side Action Script will do your job.
On Flash side Action Script will do your job.
DrupalSite framework
So that's it! We’ve done everything we need to do for Drupal side. Let's make a Flash application.
I use Linux and, as the IDE for Flash applications, I use Eclipse + FDT plugin. All information about FDT can be found on their official site http://www.fdt.powerflasher.com. After all preparations I created a new Web Actionscript 3 Project. What form of application do we need? We need some kind of text field so the user will enter an email address and we will get information about the user from that address.
I found a simple framework for interfacing with Drupal 6.x. It's called Drupalsite. This framework lets us create a very simple connection with Drupal. Something like:
drupal = new DrupalSite(gatewayUrl, apiKey);
It also has some standard methods for getting the node or view. But we won't use it :) You can get it from http://thirdavedesign.com/drupalsite/. Drupal developers discuss it here http://groups.drupal.org/node/14333
Action Script code
This is our simple Flash application code :
package
{
import flash.text.TextFormat;
import flash.events.KeyboardEvent;
import flash.text.TextFieldType;
import flash.text.TextField;
import flash.display.Sprite;
import com.thirdavedesign.drupalSite.DrupalSite;
public class Main extends Sprite
{
private var textField : TextField;
private var textFieldResult : TextField;
private var drupalSite : DrupalSite;
private const host : String = "http://amfphp.dev/services/amfphp";
private const apiKey : String = "24cf0df508520cb32f7d6d7b3823bda1";
public function Main() {
init();
}
private function onSuccess(data : Object) : void {
this.textFieldResult.text = "";
for each (var value : String in data) {
this.textFieldResult.appendText(value + "\n");
}
}
private function onError() : void { }
private function sendData(event : Object) : void {
if (event.keyCode == 13) {
this.drupalSite = new DrupalSite(host, apiKey);
this.drupalSite.service(onSuccess, onError, "amfphp_test.get_user_information", this.textField.text);
}
}
private function init() : void {
var textFormat : TextFormat = new TextFormat();
textFormat.size = 12;
this.textField = new TextField();
this.textField.type = TextFieldType.INPUT;
this.textField.border = true;
this.textField.x = 10;
this.textField.y = 10;
this.textField.width = 200;
this.textField.height = 20;
this.textField.setTextFormat(textFormat);
this.textField.addEventListener(KeyboardEvent.KEY_DOWN, sendData);
this.textFieldResult = new TextField();
this.textFieldResult.type = TextFieldType.DYNAMIC;
this.textFieldResult.x = 10;
this.textFieldResult.y = 50;
this.textFieldResult.autoSize = "center";
this.textFieldResult.setTextFormat(textFormat);
addChild(textField);
addChild(textFieldResult);
}
}
}
I added two text fields: one for email input and another for results. By entering keydown I make the request to Drupal with the argument – value of text field. Actually the two main lines are:
this.drupalSite = new DrupalSite(host, apiKey); this.drupalSite.service(onSuccess, onError, "amfphp_test.get_user_information", this.textField.text);
In the first line, I established a connection with Drupal and in the second one I called our custom method. The API key is the key we generated before. It's really simple with Drupalsite framework.


