Flex一个RemoteObject调用JAVA对象里面的多个方法

1、FLEX集合PureMVC进行项目开发(FLEX+BlazeDS+PureMVC)
2、FLEX的持久层调用java层代码的时候,如果要调用一个对象里面的多个方法,做法如下

package com.wynlink.model
{
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.Operation;
	import mx.rpc.remoting.RemoteObject;
	
	import org.puremvc.as3.patterns.proxy.Proxy;
	
	public class MobilePhoneProxy extends Proxy
	{
		public static const NAME:String = "MobilePhoneProxy";
		public static const GET_PHONE_USER_CALLBACK:String = "getPhoneUserCallBack";
		public static const GET_PHONE_TEMPLATE_CALLBACK:String = "getPhoneTemplateCallBack";
		
		private var mobile:RemoteObject;
		public var op1:Operation;
		public var op2:Operation;
		
		public function MobilePhoneProxy(data:Object=null)
		{
			super(NAME, data);
			
			mobile = new RemoteObject();
			mobile.destination = "phone";
			mobile.endpoint = "/Project_ydq/messagebroker/amf";
			mobile.showBusyCursor = true;
			//操作定义
			op1 = new Operation();
			op1.addEventListener(ResultEvent.RESULT, getPhoneUserCallBack);//如果是此事件,则回调此方法
			op2 = new Operation();
			op2.addEventListener(ResultEvent.RESULT, getPhoneTemplateCallBack);
			//多个操作加入远程对象
			mobile.operations = {"getPhoneUser" : op1,"getPhoneTemplate" : op2};//JAVA对象里的方法
			//mobile.addEventListener(ResultEvent.RESULT, showSMSshowSMS);
		}
		
		private function getPhoneUserCallBack(event:ResultEvent):void {
			var re:ArrayCollection = event.message.body as ArrayCollection;
			if(re.length == 0){
				this.sendNotification(GET_PHONE_USER_CALLBACK,re);
			}
			this.sendNotification(GET_PHONE_USER_CALLBACK,null);
						
		} 
		
		private function getPhoneTemplateCallBack(event:ResultEvent):void {
			
		}
		
		/* 获取接收短信的所有用户 */
		public function getUserInfo():void {
			//mobile.getPhoneUser();
			op1.send();
		}
		
		/*  获取短信模板  */
		public function getPhoneTemplate():void {
			op2.send();
		}
		
		public function ShowMobilePhonePanel():void{
			
		}
	}
}

你可能感兴趣的:(java,Flex,mobile)