当前位置: 代码迷 >> 综合 >> flex small tips2
  详细解决方案

flex small tips2

热度:1   发布时间:2023-12-22 05:52:08.0

在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);