|
Users Developers Wiki help. |
gtd-php v0.8 interface in Flex BuilderThis is a crude first attempt to build an interface to gtd-php v0.8 in Flex Builder. There are quite a few gotchas with Flex Builder, particularly if you might be using a proxy, or https. Anyway, I got this to work in some installations, but not all: if anyone else wants to run with it, here's what I've got so far - a working interface to create an inbox item. Note that if you run the flash file from a different server to where your gtd-php installation is, you'll need a file called crossdomain.xml in the root of the server on which gtd-php is installed: it should look like this:
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
My skeleton Flex source code, which I got to work on some installations (running on a local pc, accessing a remote server via http, not https).
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
styleName="plain" layout="absolute" width="350" height="300" creationComplete="fOnStart()">
<mx:Form id="tCreate" label="Create" width="100%" height="100%">
<mx:FormItem label="T">
<mx:TextInput id="tiTitle" tabIndex="1" width="284"/>
</mx:FormItem>
<mx:FormItem label="D" width="317">
<mx:TextArea id="taDescription" tabIndex="2" wordWrap="true" height="100" width="284"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button id="bCreate" tabIndex="3" label="Create" click="bCreate_click()"/>
</mx:FormItem>
<mx:FormItem label="U" >
<mx:TextArea id="tURL" tabIndex="4" height="40" width="284" />
</mx:FormItem>
<mx:Text id="tOut" text="Ready" height="60" width="315"/>
</mx:Form>
<mx:HTTPService
id="hPost"
concurrency="single"
contentType="application/x-www-form-urlencoded"
fault="hFailed()"
method="POST"
requestTimeout="60"
result="hSucceeded()"
resultFormat="xml"
showBusyCursor="true"
/>
<mx:Script><![CDATA[
// ---------------------------------------------------------------
import flash.net.SharedObject;
private var soConfig:SharedObject;
// ---------------------------------------------------------------
public function fOnStart() : void {
soConfig = SharedObject.getLocal("application-name");
fOptLoad();
}
// ---------------------------------------------------------------
public function fOptLoad() : void {
if (soConfig.data.hasOwnProperty('url'))
tURL.text = soConfig.data.url;
else {
soConfig.data.url='';
soConfig.flush();
}
}
// ---------------------------------------------------------------
public function fOptSave() : void {
soConfig.data.url = tURL.text;
soConfig.flush();
}
// ---------------------------------------------------------------
public function bCreate_click() : void {
var params:Object = new Object();
var rootURL:String;
bCreate.enabled=false;
fOptSave();
rootURL=soConfig.data.url;
if (rootURL.slice(-1,1)!='/')rootURL+='/';
if (rootURL.substr(0,4)=="https") hPost.destination="DefaultHTTPS";
hPost.url=rootURL+"processItems.php";
params.title= tiTitle.text;
params.description=taDescription.text;
params.action="create";
params.type="i";
params.output="xml";
hPost.send(params); // parameters in object containing name-value pairs
taDescription.text='';
tiTitle.text='';
}
// ---------------------------------------------------------------
public function hFailed() : void {
tOut.text="request failed - ";
}
// ---------------------------------------------------------------
public function hSucceeded() : void {
var xTxt:XMLNode;
xTxt=hPost.lastResult as XMLNode;
tOut.text=xTxt.childNodes[0].childNodes[0].childNodes[0].nodeValue;
// loop throught gtdphp -> result -> line - get nodeValue
tiTitle.setFocus();
bCreate.enabled=true;
}
// ---------------------------------------------------------------
]]></mx:Script>
</mx:Application>
|