flex简单数据绑定
[Bindable]
Bindable可以用来绑定简单数据类型、类、复杂数据类型以及函数。绑定数据的时候,你必须先使用元数据标签定义一下数据。
<mx:Script>
<![CDATA[
[Bindable] private var value:String="Hello World";
]]>
</mx:Script>
<mx:Panel title="My Application" layout="absolute" width="300" height="130">
<mx:Label text="{value}"/>
</mx:Panel>
[Embed]
[Embed]元数据标签用来导入图片到程序。可以通过两种方式使用[Embed]。你可以将图片嵌入到ActionScript中并将其指派给一个变量,或者你 也可以将图片直接指派给组件的属性。
方式一:
<mx:Script>
<![CDATA[
[Embed(source="face_pic.gif")][Bindable] private var logo:Class;
]]>
</mx:Script>
<mx:Panel title="My Application" layout="absolute" width="300" height="230">
<mx:Button icon="{logo}"/>
</mx:Panel>
方式二:
<mx:Panel title="My Application" layout="absolute" width="300" height="230">
<mx:Image source="@Embed('face_pic.gif')" right="1"/>
</mx:Panel>
浙公网安备 33010602011771号