<mx:RemoteObject>标记允许使用AMF3访问远程服务类的方法,要知道在Flex中怎样使用Flash Remoting访问数据 ,应该先了解一下RemoteObject类。 要知道在Flex中怎样使用Flash Remoting访问数据 ,应该先了解一下RemoteObject类。 包 mx.rpc.remoting 类 public dynamic class RemoteObject 继承 RemoteObject→AbstractService→Proxy→Object 子类 RemoteObject 一、<mx:RemoteObject>标记 它允许使用AMF3访问远程服务类的方法。 1. <mx:RemoteObject>允许的标记属性有: <mx:RemoteObject Properties concurrency="multiple|single|last" destination="No default." id="No default." endpoint="No default." showBusyCursor="false|true" source="No default." (currently, Macromedia ColdFusion only) makeObjectsBindable="false|true" 事件 fault="No default." result="No default." /> 2. <mx:RemoteObject>标记可以包含多个 <mx:method> 标记,<mx:method>允许的标记属性有: <mx:method Properties concurrency="multiple|single|last" name="No default, required." makeObjectsBindable="false|true" 事件 fault="No default." result="No default." /> 3. <mx:RemoteObject>标记可以也只能包含一个<mx:arguments> 子标记 ,该子标记是一个序列数组对象。 二、公有属性 1. concurrency : String 表示对同一服务怎样进行多次调用。类似于XMLConnector/WebServiceConnector/RemotingConnector的multipleSimultaneousAllowed属性。它的默认值为multiple,允许下列值: Multiple:同一时间可以执行多个请求。已有的请求不会被取消; Single:同一时间调用只能执行一个请求,多个请求会报错; Last:最后一次请求会覆盖已有的请求。 2. endpoint: String 允许开发人员快速为RemoteObject destination(目标)指定endpoint(端点)。而该destination既没有在编译时,也没有在用代码新建ChannelSet(通道集)时参照services-config.xml。如果设定了该属性,它会覆盖已有的ChannelSet。 如果endpoint 的url 以 "https" 开关,将使用 SecureAMFChannel, 否则使用普通的AMFChannel。{server.name}和{server.port}标记,可以用在endpoint的url中,表明Channel应该使用用来加载SWF文件的服务名称和端口。 3. showBusyCursor : Boolean 表示服务正在执行时是否显示一个表示忙碌的鼠标指针。 三、公有方法 1. RemoteObject () 构造方法 创建一个新的RemoteObject对象。 参数 destination:String (默认为 null) —RemoteObject 的destination属性必须匹配 services-config.xml 中的destination的ID属性值。 2. initialized () public function initialized(document:Object, id:String):void 只要设定RemoteObject标记就会通过MXML编译器自动调用该方法。如果使用ActionScrip新建RemoteObject实例,则可以自行调用该方法,这对验证其参数很有用。 参数 document:Object —RemoteObject 所在的MXML文档 id:String —RemoteObjec在上述文档中的ID