<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" pageTitle="Database Administration Tool" width="679" height="256" layout="absolute" creationComplete="init()" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.rpc.remoting.RemoteObject; [Bindable] private var eyeColors:Array = ["Blue", "Brown", "Green", "Transparent", "Red"]; private var identityService:RemoteObject; private var invokeTime:Number; private function init():void { identityService = new RemoteObject( "GenericDestination" ); identityService.source = "Weborb.Examples.IdentityService"; identityService.HideIdentity.addEventListener( FaultEvent.FAULT, gotError ); identityService.HideIdentity.addEventListener( ResultEvent.RESULT, gotNewIdentity ); } private function invokeService():void { var myIdentity:Object = new Object(); myIdentity.name = nameFieldClient.text; myIdentity.age = ageClient.value; myIdentity.sex = genderGroup.selectedValue; myIdentity.eyeColor = eyeColorClient.selectedItem; invokeTime = new Date().getTime(); identityService.HideIdentity( myIdentity ); } private function gotError( fault:FaultEvent ):void { Alert.show( "Server reported an error - " + fault.fault.faultString ); } private function gotNewIdentity( result:ResultEvent ):void { invTime.text = (new Date().getTime() - invokeTime) + " ms"; var myNewIdentity:Object = result.result; nameField.text = myNewIdentity.name; ageField.text = myNewIdentity.age; sexField.text = myNewIdentity.sex; eyeColor.text = myNewIdentity.eyeColor; } ]]> </mx:Script> <mx:Panel width="657" height="232" layout="absolute" title="Send and Receive ActionScript Object" cornerRadius="0" backgroundColor="#ffffff" x="10" y="10"> <mx:Label x="292" y="-23" text="Flex Remoting with WebORB"/> <mx:Button x="138" y="160" label="Server, Hide My Identity!" click="invokeService()"/> <mx:Canvas x="329" y="18" width="297" height="134" borderStyle="solid" cornerRadius="10"> <mx:Label text="Name" fontSize="13" fontWeight="bold" y="19" x="16"/> <mx:Label x="15" y="45" text="Age" fontSize="13" fontWeight="bold"/> <mx:Label x="15" y="71" text="Sex" fontSize="13" fontWeight="bold"/> <mx:Label x="15" y="97" text="Eye color" fontSize="13" fontWeight="bold"/> <mx:TextInput x="102" y="20" editable="false" width="180" backgroundColor="#a5beb9" color="#000000" id="nameField"/> <mx:TextInput x="102" y="46" editable="false" width="180" backgroundColor="#a5beb9" color="#000000" id="ageField"/> <mx:TextInput x="102" y="72" editable="false" width="180" backgroundColor="#a5beb9" color="#000000" id="sexField"/> <mx:TextInput x="102" y="98" editable="false" width="180" backgroundColor="#a5beb9" color="#000000" id="eyeColor"/> </mx:Canvas> <mx:Text x="341" y="10" text="Server response" opaqueBackground="0xffffff"/> <mx:Canvas x="10" y="18" width="297" height="134" borderStyle="solid" cornerRadius="10"> <mx:Label text="Name" fontSize="13" fontWeight="bold" y="19" x="16"/> <mx:Label x="15" y="45" text="Age" fontSize="13" fontWeight="bold"/> <mx:Label x="15" y="71" text="Sex" fontSize="13" fontWeight="bold"/> <mx:Label x="15" y="97" text="Eye color" fontSize="13" fontWeight="bold"/> <mx:TextInput x="102" y="20" editable="true" width="180" backgroundColor="#a5beb9" color="#000000" id="nameFieldClient" text="James Bond"/> <mx:RadioButtonGroup id="genderGroup"/> <mx:RadioButton x="102" y="75" label="Male" groupName="genderGroup" selected="true"/> <mx:RadioButton x="162" y="75" label="Female" groupName="genderGroup"/> <mx:ComboBox x="102" y="98" id="eyeColorClient" dataProvider="{eyeColors}"></mx:ComboBox> <mx:NumericStepper x="102" y="47" width="80" id="ageClient" value="30" minimum="16" maximum="120" stepSize="2"/> </mx:Canvas> <mx:Text x="22" y="10" text="Client object" opaqueBackground="0xffffff"/> <mx:Text x="329" y="164" text="Invocation time:"/> <mx:Label x="434" y="164" id="invTime"/> </mx:Panel> </mx:Application>