flex Bindable使用讲解
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Panel width="392" height="300" layout="absolute">
<mx:Label x="19" y="10" text="{user}" width="171" height="20"/>
<mx:Button x="216" y="8" label="测试Bindable" click="bind()" width="105"/>
<mx:DataGrid x="19" y="58" dataProvider="{arr}">
<mx:columns>
<mx:DataGridColumn headerText="year" dataField="year"/>
<mx:DataGridColumn headerText="city" dataField="city"/>
<mx:DataGridColumn headerText="provice" dataField="provice"/>
<mx:DataGridColumn headerText="total" dataField="total"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
[Bindable]
private var user:String="HELLO";
[Bindable]
private var arr:ArrayCollection=new ArrayCollection([
{year:2009,city:"Shanghai",provice:"上海",total:580000},
{year:2009,city:"Beijing",provice:"河北省",total:7852020},
{year:2009,city:"Nanjing",provice:"江苏省",total:895145},
{year:2009,city:"Hangzhou",provice:"浙江省",total:4132415}]);
//修改了绑定的user和arr,并没有修改label和datagrid
private function bind():void{
this.user="HEllo22";
arr.removeItemAt(3);
}
]]>
</mx:Script>
</mx:Application>
相关文档:
1、如果要设置Validator验证组件里面提示字的大小,可以在mxml中加入
<mx:Style>
<!--[CDATA[
.errorTip
{
fontSize: 12;
}
]]-->
</mx:Style>
2、设置tooltip中的样式(如字体大小,颜色)可在mxml中的creationComplete的initApp()加入
......
在Flex里,一般的弹出窗口(除了Alert以外)都可以用TitleWindow组件完成,主窗口和TitleWindow的数据传输可以用以下方法:
假设TitleWindow的实例文件为titleWin.mxml,则要在Application中用PopUpManager创建一个titleWin的引用
private var popWin:titleWin = titleWin(PopUpManager.createPopUp(this,titleWin,true)) ......
利用Socket实现C++与Flex通信
一、C++服务器端
(用的是Visual Studio 2008(05,03的应该也可以,VC++的可能需要稍微改动))
代码如下:
#include <winsock2.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(lib,"ws2_32.lib ......