flex 小知识2

1:var validatorErrorArray:Array = Validator.validateAll(validatorArr);// validatorArr去掉此数组里面的空值(在验证中)
2:textInput.setStyle("themeColor", "#ffffff");设置textInput的边框颜色
3: restrict="A-Z 0-9 \-+" 》》textInput里面的限制数据输入的属性

4:ArrayCollection 操作
var obj:Object=collection[0].children;//取得ArrayCollection的长度

Alert.show(obj.length.toString());

Alert.show(collection[0].children[0].children[0].name);
4,1,遍历
private function ergodicArrCollection(bool:Boolean):void
{
for(var i:int=0;i<collection.length;i++)
{
collection[i].selected=bool;

var obj:Object=collection[0].children;//取得ArrayCollection的长度

//Alert.show(collection.length.toString());
try
{
var ArrColI:Object=collection[i].children;
var lenI:int=ArrColI.length;
}catch(error:Error)
{
lenI=0;
}
//Alert.show(lenI.toString());

if(lenI>0)
{
for(var j:int=0;j<lenI;j++)
{
ArrColI[j].selected=bool;
try
{
var ArrColJ:Object=collection[i].children[j].children;
var lenJ:int=ArrColJ.length;
}catch(error:Error)
{
lenJ=0;
}
// Alert.show(lenJ.toString());
if(lenJ>0)
{
for(var k:int=0;k<lenJ;k++)
{
collection[i].children[j].children[k].selected=bool;
treeD1.dataProvider=collection;
//var ArrColEnd:ArrayCollection=collection[i].children[j].children[k];
}
}
}
}
}
}



5::tree操作,tree.getChildren(parent); //得到子节点,
      tree.getParentItem(item);//得到树的父节点

6:访问子组件this.activitycodeForm.sendDB(acd);(activitycodeForm 组件的ID,sendDB 组件的方法)

7:this.setChildIndex(event.currentTarget as DisplayObject,this.numChildren-1); //实现层的切换

8:flex 禁用tab,上级组件id.tabChildren=false;

9: 拖动::
dropEnabled="true" //是否可以将被拖动的物体放置进来
dragEnabled="true" //是否可以拖动子元素
dragMoveEnabled="true" //是否只是移动元素,而不是复制元素
allowMultipleSelection="true" //是否可以多项拖动元素
http://www.bhcode.net/article/20090115/4046.html


10. 解决按Tab键死机问题::把当前页面中所有不需要用的能接收tab的组件,设置 tabEnabled= "false"


11.DataGrid的刷新
     function orderDataGrid(datagrid:DataGrid,index:int):void
{
var len:int=datagrid.dataProvider.length;
var arr:ArrayCollection=datagrid.dataProvider as ArrayCollection;
    var sf0:String=datagrid.columns[index].dataField;
    var sf1:String=datagrid.columns[1].dataField;
    var m_sort:Sort = new Sort();
    //m_sort.fields=[new SortField(sf0,true),new SortField(sf1,false)];
    m_sort.fields=[new SortField(sf0,true)];
    arr.sort=m_sort;
    arr.refresh();
    datagrid.dataProvider=arr;
    }



11,DataGrid排序
     function orderDataGrid(datagrid:DataGrid,index:int):void
{
var len:int=datagrid.dataProvider.length;
var arr:ArrayCollection=datagrid.dataProvider as ArrayCollection;
    var sf0:String=datagrid.columns[index].dataField;
    var sf1:String=datagrid.columns[1].dataField;
    var m_sort:Sort = new Sort();
    //m_sort.fields=[new SortField(sf0,true),new SortField(sf1,false)];
    m_sort.fields=[new SortField(sf0,true)];
    arr.sort=m_sort;
    arr.refresh();
    datagrid.dataProvider=arr;
    }
12.verticalScrollPolicy="off"》》禁用滚动条

13, private function getAppointString(str:String,i:int):String
{
var s:String=str;
var  k:int=i;
do{
s=str.substr(0,i);
i--;
}while(s.replace(/[^\x00-\xff]/g,"**").length>k)
Alert.show(s.toString());
return s;
}//str:字符串,i:长度
14,日期格式转换
var dateFormatter:DateFormatter = new DateFormatter();
dateFormatter. formatString= "YYYY-MM-DD";
var str:String =dateFormatter.format(new Date());
Alert.show(str);


15.private function getXMLNodeProperty(xmlNode:XML,arrProperty:Array):Array//根据数组获取
xml的属性
{
var arr:Array=[];
var len:int=arrProperty.length;
for(var i:int=0;i<len;i++)
{
arr[i]=xmlNode.@*[i];
}
return arr;
}
private function onTest():void
{
var arr:Array=["state","label"];
getXMLNodeProperty(xmlNode,arr);
}



16:ToolTipManager.showDelay 提示条显示所用的时间。

17.<mx:Canvas mouseDown="this.startDrag()" mouseUp="this.stopDrag()" x="45" y="184" width="200" height="177" backgroundColor="#12BE42" >
</mx:Canvas>//sdk3.2以上,可以拖动canvas在容器里面跑
18.定义外部可以看到的事件,<mx:Metadata>
[Event(name="shareData",type="flash.events.TextEvent")]
</mx:Metadata>

19.button 的选中属性,toggle

你可能感兴趣的:(xml,Flex,Flash,J#)