1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.controls.*;
import mx.rpc.events.*;
import mx.utils.ArrayUtil;
import mx.collections.ArrayCollection;
public function addContact():void {
drupalUser.login( 'usrLogin', 'usrPasswd' );
}
public function loContact():void {
User.logout();
}
public function userLogin(event:ResultEvent):void {
Alert.show('Logged in');
}
public function userLogout(event:ResultEvent):void {
Alert.show('Good Bye !');
}
public function onFault(event:FaultEvent):void{
Alert.show(event.fault.faultString, "Error");
}
]]>
</fx:Script>
<fx:Declarations>
<mx:RemoteObject endpoint="http://localhost/drupal-6.17/services/amfphp" showBusyCursor="true" destination="amfphp" source="user" id="drupalUser">
<mx:method name="login" result="userLogin(event)" fault="onFault(event)"/>
</mx:RemoteObject>
<mx:RemoteObject endpoint="http://localhost/drupal-6.17/services/amfphp" showBusyCursor="true" destination="amfphp" source="user" id="User">
<mx:method name="logout" result="userLogout(event)" fault="onFault(event)"/>
</mx:RemoteObject>
</fx:Declarations>
<mx:Form paddingLeft="0" paddingRight="0" paddingTop="0" paddingBottom="0">
<mx:FormItem label="Name">
<mx:TextInput id="txtName" />
</mx:FormItem>
<mx:FormItem label="Email">
<mx:TextInput id="txtEmail" />
</mx:FormItem>
<mx:FormItem label="Phone">
<mx:TextInput id="txtPhone" />
</mx:FormItem>
<mx:Button label="Add Contact" click="addContact()"/>
<mx:Button label="Logout" click="loContact()"/>
</mx:Form>
</s:Application> |