flex小技巧综合

flex 小技巧
1. 将组件放到最上层
父容器.setChildIndex(你要的TitleWindow,父容器.numChildren- 1);

2.array的赋值:
1.可以长度不一致
2.可以变量
3.可以push空数组 push([])
e.g.

var aa:int = 1;
var a:Array = [aa,2,3];
var b:Array = [2,3];
var c:Array = [1,2,3,4];
array.push(a);
array.push(b);
array.push(c);
array.push([aa,aa,aa]);
array.push([]);


3.禁止下拉框
verticalScrollPolicy="off" horizontalScrollPolicy="off"

4.变量的访问ArrayCollection中的值
ArrayCollection["name"]

5.画点
				var circle :Sprite = new Sprite();
var comp:UIComponent = new UIComponent();
circle.graphics.beginFill(0xDC143C);
circle.graphics.drawCircle(x,y,r);
comp.addChild(circle);
worldmap.addChild(comp);


6.画边界
    			var bounds:Sprite = new Sprite();
bounds.graphics.beginFill(0x000000);
bounds.graphics.drawRect(x1,y1,w1,h1);
bounds.graphics.drawRect(x2,y2,w2,h2);
bounds.graphics.endFill();
var comp:UIComponent = new UIComponent();
comp.addChild(bounds);
panel.addChild(comp);


7.arrayCollection排序
             import mx.collections.SortField;  
import mx.collections.Sort;
import mx.collections.ArrayCollection;
private var acSort:ArrayCollection=
new ArrayCollection([{id:0,userName:"zhangSan",age:21},
{id:2,userName:"liSi",age:24},
{id:1,userName:"wangWu",age:31}]);


private function sortAc():ArrayCollection{
var sort:Sort=new Sort();
//按照ID升序排序
sort.fields=[new SortField("id")];

//按照userName降序排序
sort.fields=[new SortField("userName",true,true)];

//先按ID升序,再按userName降序
sort.fields[new SortField("id"),new SortField("userName",true,true)];
acSort.sort=sort;
acSort.refresh();//更新
return acSort;
}


7.设置Alert的字体样式
    <mx:Style>
Alert{
titleStyleName: "alertTitle";
messageStyleName: "alertMessage";
buttonStyleName: "alertButton";
cornerRadius: 10;
embedFonts: true;
}
.alertTitle {
letterSpacing: 0;
fontSize: 14;
color: red;
}
.alertMessage {
letterSpacing: 2;
fontSize: 14;
fontWeight: bold;
color: #000000;
}
.alertButton {
letterSpacing: 0;
fontSize: 12;
fontWeight: normal;
color: black;
}
</mx:Style>


8.读JSON串的键值
                var obj:Object = JSON.decode(jsonString);
for each(var key:String in obj){
trace("key:"+key+" value:"+obj[key]);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值