在ActionScript中实现绑定
这种方法是使用mx.binding.utils.BindingUtils类来实现的。
如:
BindingUtils.bindProperty(textarea, "text", textinput, "text");
就是直接绑定了两个输入框的text属性,还可以用bindSetter来绑定一个数据源和一个set函数。如:
public function mySetterBinding(event:FlexEvent):void {
var watcherSetter:ChangeWatcher = BindingUtils.bindSetter(setMyString, textInput2, "text");
}
这里就是将textInput2的text属性setter函数和setMyString函数绑定起来,
一旦textInput2的text被修改,那么将会触发setMyString函数。
banding整个类的用法:
[SWF(backgroundColor='0xffffff',frameRate='30')]
public class Main extends Sprite{
......
绑定资源
声音
[Embed(source="sound1.mp3")]
public var soundCls:Class;
可伸缩矢量图
[Embed(source="logo.svg")]
[Bindable]
public var imgCls:Class;
图片jpg png gif
[Embed(source="logo.gif")]
[Bindable]
public var imgCls:Class;
九宫格图片
[Embed(source="slice_9_grid.gif",
scaleGridTop="25", scaleGridBottom="125",
scaleGridLeft="25", scaleGridRight="125")]
[Bindable]
public var imgCls:Class;
SWF
[Embed(source="icon.swf")]
[Bindable]
public var imgCls:Class;
元件
[Embed(source='SWFFileName.swf', symbol='symbolName')]
public var ClassicName:Class;
这种方法是使用mx.binding.utils.BindingUtils类来实现的。
如:
BindingUtils.bindProperty(textarea, "text", textinput, "text");
就是直接绑定了两个输入框的text属性,还可以用bindSetter来绑定一个数据源和一个set函数。如:
public function mySetterBinding(event:FlexEvent):void {
var watcherSetter:ChangeWatcher = BindingUtils.bindSetter(setMyString, textInput2, "text");
}
这里就是将textInput2的text属性setter函数和setMyString函数绑定起来,
一旦textInput2的text被修改,那么将会触发setMyString函数。
banding整个类的用法:
[SWF(backgroundColor='0xffffff',frameRate='30')]
public class Main extends Sprite{
......
绑定资源
声音
[Embed(source="sound1.mp3")]
public var soundCls:Class;
可伸缩矢量图
[Embed(source="logo.svg")]
[Bindable]
public var imgCls:Class;
图片jpg png gif
[Embed(source="logo.gif")]
[Bindable]
public var imgCls:Class;
九宫格图片
[Embed(source="slice_9_grid.gif",
scaleGridTop="25", scaleGridBottom="125",
scaleGridLeft="25", scaleGridRight="125")]
[Bindable]
public var imgCls:Class;
SWF
[Embed(source="icon.swf")]
[Bindable]
public var imgCls:Class;
元件
[Embed(source='SWFFileName.swf', symbol='symbolName')]
public var ClassicName:Class;