如何[为RemoteClass] Flex中的Actionscript工作,我可以用它的自定义数据绑定? [英] How does [RemoteClass] work in Flex Actionscript can I use it for custom data-binding?

查看:325
本文介绍了如何[为RemoteClass] Flex中的Actionscript工作,我可以用它的自定义数据绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ActionScript支持用于BlazeDS中提供的数据绑定的提示编组从Java AMF二进制对象为BlazeDS的一个[为RemoteClass]元数据标签。

Actionscript supports a [RemoteClass] metadata tag that is used in BlazeDS to provide data-binding hints for marshalling AMF binary objects from Java to BlazeDS.

例如:

Java的:     包样品;

Java: package sample;

public class UserInfo
{
    private String userName;

    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String value)
    {
        userName = value;
    }
}

的ActionScript:

[Bindable]
[RemoteClass(alias="sample.UserInfo")]
public class UserInfo
{
    public var userName:String="";
}

究竟是[为RemoteClass]实施BlazeDS的框架,你能重写该行为,并提供了一​​个自定义的数据绑定远程处理框架(如JSON消息传递系统),您可以绑定到的ActionScript [可绑定],[为RemoteClass]类?

How exactly is the [RemoteClass] implemented in the BlazeDS framework and could you override that behavior and provide a custom data-binding remoting framework (e.g. a JSON message passing system) that you could bind to the Actionscript [Bindable], [RemoteClass] class?

推荐答案

[为RemoteClass(别名为com.example.MyClass)是一个Flex简写叫<一href="http://livedocs.adobe.com/flex/3/langref/flash/net/package.html#registerClassAlias%28%29">flash.net.registerClassAlias()

[RemoteClass(alias="com.example.MyClass")] is a Flex shorthand for calling flash.net.registerClassAlias() :

public function registerClassAlias(aliasName:String, classObject:Class):void

要访问这些注册的别名类在运行时(编写自定义的JSON数据序列化框架),您可以拨打:

To access those registered alias classes at runtime (to write a custom JSON data serialization framework) you can call:

<一个href="http://livedocs.adobe.com/flex/3/langref/flash/net/package.html#getClassByAlias%28%29">getClassByAlias(aliasName:String):Class 查找该previously了一个别名通过调用registerClassAlias​​()方法。

getClassByAlias(aliasName:String):Class Looks up a class that previously had an alias registered through a call to the registerClassAlias() method.

有关从AS到Java您需要检索的别名的类名即将离任的编码,你可以通过调用<一href="http://livedocs.adobe.com/flex/3/langref/flash/utils/package.html#describeType%28%29">flash.utils.describeType()并使用您的ActionScript对象的类反思查询属性,属性,对象的方法。

For outgoing encoding from AS to Java you need to retrieve the aliased class name, you can do that by calling flash.utils.describeType() and use "reflection" on your Actionscript object's class to query attributes, properties, methods of the object.

例如下面的code代码片段<一个href="http://www.google.com/$c$csearch/p?hl=en&sa=N&cd=7&ct=rc#a2tKkY7STZE/trunk/ygg/encoding/amf/type/v3/Object$c$cc.as&q=lang%3Aactionscript%20describeType&exact%5Fpackage=http%3A//yggsaw.google$c$c.com/svn">Object$c$cc.as似乎通过检索别名属性@:

For example the following code snippet for ObjectCodec.as seems to retrieve the alias attribute by using "@":

override protected function encodeComplex(o:Object, b:IBinary, context:IContext=null):void
{
		var desc:XML = describeType(o);
		var classAlias:String = desc.@alias;
		//...
}

这篇关于如何[为RemoteClass] Flex中的Actionscript工作,我可以用它的自定义数据绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆