ascb.util包下载与ascb.util.DateFormat、ascb.util.NumberUtilities使用

 ascb包下载:http://rightactionscript.com/ascb/AS3CBLibrary.zip

 

ascb.util.DateFormat

数据格式化

帮助文档:http://www.person13.com/ascblibrary/documentation/ascb/util/DateFormat/Class.htm

 

package { import ascb.util.DateFormat; import flash.display.Sprite; public class Sample0616 extends Sprite { public function Sample0616() { var date:Date = new Date(); trace(date);//Tue Jun 16 16:35:29 GMT+0800 2009 trace(new DateFormat("Y").format(date));//2009 trace(new DateFormat("y").format(date));//09 trace(new DateFormat("m").format(date));//06 trace(new DateFormat("d").format(date));//16 trace(new DateFormat("H:i:s").format(date));//16:35:29 trace(new DateFormat("h:i:s").format(date));//04:35:29 trace(new DateFormat("h:i:s a").format(date));//04:35:29 pm trace(new DateFormat("Y-m-d 'at' h:i:s a").format(date));//2009-06-16 at 04:48:45 pm } } }

 

ascb.util.NumberUtilities

生成随机数

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#14528B, #3095F2]"> <mx:Script> <!--[CDATA[ import ascb.util.NumberUtilities; public function doStartRandom():void { var iFrom:int=0; var iTo:int=0; var iStep:int =1; iFrom=(int)(inputFrom.text==""?"0":inputFrom.text) ; iTo=(int)(inputTo.text==""?"0": inputTo.text); iStep=(int)(inputStep.text==""?"0": inputStep.text); txtRandom.text= NumberUtilities.random(iFrom,iTo,iStep).toString(); } public function doClose():void { var urlRequest:URLRequest=new URLRequest("javascript:window.opener=null;window.close();"); navigateToURL(urlRequest,"_self"); } ]]--> </mx:Script> <mx:Label x="344" y="239" text="产生随机数是:" enabled="true" fontSize="14"/> <mx:Label x="344" y="139" text="随机数范围从:" enabled="true" fontSize="14"/> <mx:TextInput x="447" y="139" width="47" textAlign="right" id="inputFrom" text="-10"/> <mx:Label x="502" y="137" text="至" enabled="true" fontSize="14" width="24"/> <mx:TextInput x="534" y="139" width="47" textAlign="right" id="inputTo" text="10"/> <mx:Label x="344" y="185" text="间隔数值应为:" enabled="true" fontSize="14"/> <mx:TextInput x="447" y="187" width="47" id="inputStep" text="1" textAlign="right"/> <mx:Text x="447" y="243" width="124" color="#FAF9F3" fontWeight="bold" fontSize="12" enabled="true" alpha="0.0" id="txtRandom" text="0"/> <mx:Button x="344" y="296" label="生成随机数" click="doStartRandom();" fontSize="13"/> <mx:Button x="494" y="296" label="关闭" width="77" click="doClose()" fontSize="13"/> </mx:Application>

你可能感兴趣的:(ascb.util包下载与ascb.util.DateFormat、ascb.util.NumberUtilities使用)