日积月累--12个flex常用功能代码(转载)

做人要厚道,这篇文章来自: http://bbs.actionscript3.cn/thread-5978-1-1.html

1, 复制内容到系统剪贴板
System.setClipboard(strContent);

2, 复制一个ArrayCollection
复制代码
ExpandedBlockStart.gif
//dummy solution( well, it works )
var bar:ArrayCollection = new ArrayCollection();
for each ( var i:Object in ac ){
bar.addItem( i );
}
// fantastic ! //
var bar:ListCollectionView = new ListCollectionView( ListCollectionView( ac ).list );
复制代码
3, 打开一个新浏览器窗口
navigateToURL(new URLRequest('http://ntt.cc'), '_blank');

4,刷新浏览器
navigateToURL(new URLRequest("location.reload();"),"_self")< /span>
5, 关闭浏览器
navigateToURL(new URLRequest("javascript:window.close()"),"_self");
6, 设置Alert 窗口的背景为透明
Alert
{
modalTransparency:0.0;
modalTransparencyBlur:0;
}

7,取随机颜色
lbl.setStyle('color', 0xffffff*Math.random());

8,清除子串左侧空格
ContractedBlock.gif Code
9, 清除字串右侧空格
ContractedBlock.gif Code
10, 清除字串左右的空格
public function Trim(s : String):String
{
return LTrim(RTrim(s));
}
11, 获取数据类型
getQualifiedClassName(data)
12, 生成随机字符串
ContractedBlock.gif Code