flex small tips2

在flex裏註釋mxml標籤的快捷鍵:Ctrl+Shift+C

註釋AS的快捷鍵是 Ctrl+/

    navigateToURL(new URLRequest("javascript:location.reload();"),"_self")

     navigateToURL(new URLRequest("javascript:window.close()"),"_self");

     navigateToURL(new URLRequest('http://ntt.cc'), '_blank');

    System.setClipboard(strContent);

   System.totalMemory * 0.000000954

   System.gc()

.複製一個ArrayCollection

  //dummy solution( well, it works )
  var bar:ArrayCollection = new ArrayCollection();
  for each ( var i:Object in ac ){
  bar.addItem( i );
  }


      var bar:ArrayCollction=new ArrayArrayCollction(ac.source);

  // fantastic !
  var bar:ListCollectionView = new ListCollectionView( ListCollectionView( ac ).list );


   獲取數據類型  getQualifiedClassName(data)

   i is int   int 與NUmber還是不一樣的

       清除子串左側空格  StringUtil.trim()

  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);
  }
 
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);
  }
public function Trim(s : String):String{
  return LTrim(RTrim(s));
}

設置Alert 窗口的背景爲透明
  Alert{
  modalTransparency:0.0;
  modalTransparencyBlur:0;}

<mx:Style>
Alert{ font-size: 12}
</mx:Style>

<mx:Style>
Alert {
titleStyleName: "alertTitle";
messageStyleName: "alertMessage";
buttonStyleName: "alertButton";
}

.alertTitle {
letterSpacing: 0;//各字符之間顯示的附加像素數
fontSize: 18;
fontWeight: normal;//bold 加粗, normal 正常
color: red;
textAlign: left;//文本對齊方式center,justify,left,right
}
</mx:Style>


xml的NameSpace
var xml:XML = <root>
    <h:table xmlns:h="http://www.w3.org/TR/html4/">
      <h:tr>
        <h:td>Apples</h:td>
        <h:td>Bananas</h:td>
      </h:tr>
    </h:table>
 
    <f:table xmlns:f="http://www.w3schools.com/furniture">
      <f:name>African Coffee Table</f:name>
      <f:width>80</f:width>
      <f:length>120</f:length>
    </f:table>
 
</root>
 
trace("Not using a namespace");
trace(xml.table); // Nothing
 
var trNs:Namespace = new Namespace("http://www.w3.org/TR/html4/");
var furnitureNs:Namespace = new Namespace("http://www.w3schools.com/furniture");
 
trace("Using a namespace");
trace(xml.trNs::table);
trace(xml.furnitureNs::table);
 
 
// You can also set the default xml namespace if you are repeatedly using the same namespace.
default xml namespace = new Namespace("http://www.w3.org/TR/html4/");
//trace("Using a namespace");
//trace(xml.table);  


獲取取隨機顏色 0xffffff*Math.random() 

生成隨機字符串.
  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;

  }


在Flex裏的Image組件,默認加載的內容是按等比縮放的,如果希望所加載的內容填充滿整個Image內容,則應該設置其屬性 maintainAspectRatio=false(默認值爲true);


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章