什么是" @"做? [英] What does the "@" do?

查看:413
本文介绍了什么是" @"做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候,我在一个项目即时看到在工作时,以下内容:

 文本=@ {myVar的}
 

这是什么@怎么办?

编辑:文本的属性,例如,TextArea组件

解决方案

@符号用于双向绑定

。传统的绑定只有一个办法。所以,你有这样的事情在ActionScript:

  [可绑定]
公共变种myvalue的:字符串=测试;
 

和这MXML

 < S:的TextInput ID =myInput文本​​={} myvalue的/>
 

myvalue的是源,并在myInput文本属性是目标。

在myvalue的变量发生变化,TextInput的text属性会发生变化。但是,如果您键入到myInput; myvalue的值也不会改变。

这是一种方式的结合。改变源(myvalue的)变化的目的地(myInput.text),但改变目的地(myInput.text)不改变源(myvalue的)。

当您添加@它会创建一个双向绑定:

 < S:的TextInput ID =myInput文本​​=@ {} myvalue的/>
 

所以,现在每当myvalue的变化,TextInput的text属性会发生变化。 (由于previous样品中)。 每当myInput.text变化,myvalue的也将改变(区别于previous样品)。

在'@',基本上,使得这两个值(myvalue的和myInput.text)源和目标进行绑定。

您可以完成同样的事情没有@通过<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mxml/binding.html">Binding标签:

 &LT; FX:绑定源=myInput.text目标=myvalue的/&GT;
 

那是一个更深入的解释吗?

Sometimes I see in a project im working at, the following:

text="@{myVar}"

What does that @ do?

Edit: text is a property in, for example, a TextArea component.

解决方案

The @ symbol is used for two way binding. Traditional binding is only one way. So, you have something like this in ActionScript:

[Bindable]
public var myValue:String = 'test';

And this in MXML

<s:TextInput id="myInput" text="{myValue}" />

myValue is the source, and the text property on the myInput is the destination.

When the myValue variable changes, the text property of the TextInput will change. However, if you type into the myInput; the value of myValue will not change.

This is one way binding. Changing the source (myValue) changes the destination (myInput.text), but changing the destination (myInput.text) does not change the source (myValue).

When you add the '@' it creates a two way binding:

 <s:TextInput id="myInput" text="@{myValue}" />

So, now whenever myValue changes, the text property of TextInput will change. ( As in the previous sample). Whenever myInput.text changes, the myValue will also change (Different from the previous sample).

The '@', basically, makes both the values (myValue and myInput.text) a source and destination for binding.

You could accomplish the same thing without the '@' by using the Binding tag:

<fx:Binding source="myInput.text" destination="myValue " />

Is that a more in depth explanation for you?

这篇关于什么是&QUOT; @&QUOT;做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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