[color=darkred][size=medium]1、复制内容到系统剪贴板[/size][/color]
[size=medium]2、复制一个ArrayCollection[/size]
[size=medium]3、打开一个新浏览器窗口[/size]
[size=medium]4、刷新浏览器[/size]
[size=medium]5、关闭浏览器[/size]
[size=medium]6、 设置Alert 窗口的背景为透明[/size]
[size=medium]7、取随机颜色[/size]
[size=medium]8、 清除子串左侧空格[/size]
[size=medium]9、清除字串右侧空格[/size]
[size=medium]10、 清除字串左右的空格[/size]
[size=medium][color=darkred]11、获取数据类型[/color][/size]
12、生成随机字符串。
System.setClipboard(strContent);
[size=medium]2、复制一个ArrayCollection[/size]
//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 );
[size=medium]3、打开一个新浏览器窗口[/size]
navigateToURL(new URLRequest('http://ntt.cc'), '_blank');
[size=medium]4、刷新浏览器[/size]
navigateToURL(new URLRequest("javascript:location.reload();"),"_self")
[size=medium]5、关闭浏览器[/size]
navigateToURL(new URLRequest("javascript:window.close()"),"_self");
[size=medium]6、 设置Alert 窗口的背景为透明[/size]
Alert
{
modalTransparency:0.0;
modalTransparencyBlur:0;
}
[size=medium]7、取随机颜色[/size]
lbl.setStyle('color', 0xffffff*Math.random());
[size=medium]8、 清除子串左侧空格[/size]
public function LTrim(s : String):String
{
var i : Number = 0;
while(s.charCodeAt(i) == 32 || s.charCodeAt(i) == 13 || s.charCodeAt(i) == 10 || s.charCodeAt(i) == 9)
{
i++;
}
return s.substring(i,s.length);
}
[size=medium]9、清除字串右侧空格[/size]
public function RTrim(s : String):String
{
var i : Number = s.length - 1;
while(s.charCodeAt(i) == 32 || s.charCodeAt(i) == 13 || s.charCodeAt(i) == 10 ||s.charCodeAt(i) == 9)
{
i--;
}
return s.substring(0,i+1);
}
[size=medium]10、 清除字串左右的空格[/size]
public function Trim(s : String):String
{
return LTrim(RTrim(s));
}
[size=medium][color=darkred]11、获取数据类型[/color][/size]
getQualifiedClassName(data)
12、生成随机字符串。
private function GenerateCheckCode():String
{
//init
var ran:Number;
var number:Number;
var code:String;
var checkCode:String ="";
//get 4 radom
for(var i:int=0; i<4; i++)
{
ran=Math.random();
number =Math.round(ran*10000); //get result like 0.1234
if(number % 2 == 0)
code = String.fromCharCode(48+(number % 10)); //0's ASCII code is 48
else
code = String.fromCharCode(65+(number % 26)) ; // A's ASCII code is 65
checkCode += code;
}
return checkCode;
}