1。 將主場景左上角對齊,并禁止縮放: m_Element.stage.align = StageAlign.TOP_LEFT;
-------------------------------------------------------------------------------- 2。flashz中ComboBox中 List的字體樣式設(shè)置: ComboBox_.dropdown.setRendererStyle("textFormat",TxtFormat); -------------------------------------------------------------------------------- var myArry:Array = new Array();//定義兩個(gè)數(shù)組; for (var i:uint =1; i<=100; i++) for (var j:uint=0; j<=9; j++) -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- 5.動(dòng)態(tài)改變MC注冊點(diǎn)的方法: import flash.geom.Point; mc.addEventListener (MouseEvent.MOUSE_DOWN,fun); function fun (events:MouseEvent)
-------------------------------------------------------------------------------- 6.判斷語句的幾種“另類”寫法: var i:uint = 100; trace(funs()); function funs():*
-------------------------------------------------------------------------------- 7. 消除亂碼的方法: import flash.system.System; //這個(gè)代碼放在類上在導(dǎo)入,就不用說了。 -------------------------------------------------------------------------------- 8.數(shù)組排序 var arr1:Array=[[5,2],[8,1],[6,8]]; 方法1:自定義排序方法 arr1.sort(sortfun); for each(var i:String in arr1) { trace(i); //測試結(jié)果[8,1],[5,2],[6,8] } function sortfun (left:*,right:*):int { if (left[1] < right[1]) { return -1; } else if (left[1] == right[1]) { return 0; } else { return 1; } }
方法2:用類置的方法 arr1.sortOn("1",2|16); -------------------------------------------------------------------------------- 9.偵聽按下的鍵盤并區(qū)分大小寫的方法~~~~~~~~ function reportKeyDown (event:KeyboardEvent):void ode + ")"); -------------------------------------------------------------------------------- 10.角度和弧度轉(zhuǎn)換公式 radians = degrees * Math.PI / 180 -------------------------------------------------------------------------------- 11.不讀緩存的方法: url + "?date=" + new Date() 在要加載的url地址后面加上時(shí)間“標(biāo)簽”。 -------------------------------------------------------------------------------- 12.數(shù)組中 除去相同的成員的方法
var arr:Array=["aa","bb","cc","dd","bb","cc","aa","bb","gg","aa","cc"]; function formatX(arr:Array):Array { var obj:Object={}; return arr.filter(function(item:*, index:int, array:Array):Boolean{ return !obj[item]?obj[item]=true:false }); } trace(formatX(arr)) //該方法的實(shí)現(xiàn)過程是 對于"aa"來講 obj["aa"]的值為undefined 而!undefined為true,就會(huì)返回該成員,然后 將obj["aa"]的值設(shè)為true,下一次遇到obj["aa"]時(shí),obj["aa"]的值為true,!obj["aa"]的值就為false,就不返回該成員。 很新穎哦. -------------------------------------------------------------------------------- 13.html 錨標(biāo)簽 中的事件 var text:Text = new Text(); text.htmlText = "<a href='event:myEvent'>[oliwen's博客]</a><font color='#33CC00'>"; private function myEvent(e:Event):void 單擊該文本就會(huì)調(diào)用myEvent事件函數(shù) |
|