`

12 very simple,basic but useful function source in Flex

    博客分类:
  • Flex
阅读更多

原文出自: 

http://ntt.cc/2008/04/19/12-very-simple-basic-but-useful-function-source-in-flex.html

 

No.1 Copy content to clipboard:

System.setClipboard(strContent);

 

No.2 Clone an ArrayCollection:

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

 

No.3 Open URL:

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

 

No.4 Page reload:

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

 

No.5 Close browse:

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

 

No.6 Set the background alpha to transparent on Alert window:

Alert
{
modalTransparency:0.0;
modalTransparencyBlur:0;
}

 

No.7 Set random color:

lbl.setStyle('color', 0xffffff*Math.random());

 

No.8 Trim left of white space

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

 

No.9 Trim right of white space

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

 

No.10 Trim left and right of white space

public function Trim(s : String):String
{
  return LTrim(RTrim(s));
}

 

No.11 get data type:

getQualifiedClassName(data)

 

No.12 Generate check digits

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;
}
 
分享到:
评论

相关推荐

    Learn Python the Hard Way: A Very Simple Introduction

    You Will Learn Python!

    a very simple tableview demo swift

    本项目"A very simple tableview demo swift"旨在展示如何在Swift中创建并操作基本的表格视图。下面将详细阐述相关知识点。 【描述】"一个非常简单的Swift表格视图演示" 这个Swift示例项目旨在帮助初学者理解如何...

    SP_source.zip_Myself And I_Splitter_splitter dialog

    Maybe, it s not useful for you, but if there s only one person who thinks it s useful, I will be very happy. Sometimes you don t need good skill, just a good idea, and by this simple way a useful ...

    very simple image gallery

    "very simple image gallery" 是一个专为 Joomla! 内容管理系统设计的相册管理插件。Joomla 是一款流行的开源 CMS(内容管理系统),它允许用户无需深入编程即可创建和管理网站。这款简单相册插件提供了方便快捷的...

    A SIMPLE MESH GENERATOR IN MATLAB

    We want to offer a short and simple MATLAB code, described in more detail than usual, so the reader can experiment (and add to the code) knowing the underlying principles. We find the node locations ...

    jOOR - Fluent Reflection in Java jOOR is a very simple flu.zip

    标题"jOOR - Fluent Reflection in Java jOOR is a very simple flu.zip"表明这个压缩包可能包含jOOR库的相关代码或文档,帮助用户了解和使用这个库。"Fluent Reflection in Java"强调了jOOR的主要特点,即提供了一...

    Very Simple Ad 1.0.4.3 20160503 unitypackage

    Very Simple Ad 1.0.4.3 20160503 unitypackage

    This example is a very simple solution to sending and receiv

    This example is a very simple solution to sending and receiving data to and from a Parallax Basic Stamp. This example requires a Basic Stamp and the MSComm control. Also included is an example Basic ...

    Very Simple Rating System.rar

    本压缩包"Very Simple Rating System.rar"很可能包含了一个基本的评分系统实现,可能是一个小型项目或示例代码,用于教学或快速原型设计。下面将详细探讨评分系统的概念、组成部分以及可能的设计方法。 1. 评分系统...

    Foundation Flex For Developers - Data-Driven Applications With Php, Asp.Net, Coldfusion

    No book can cover everything, but here you’ll learn some of the more useful tools for Flex application development. Most importantly, you’ll learn how to include external data within your ...

    Sybex - Mastering Visual Basic .NET (VBL).pdf

    who invested in Visual Basic 10 years ago are in demand today. In the world of computing, how- ever, things change very fast, including languages. At some point, they either die, or they evolve into ...

    Very Simple Instant Messenger X-PopUp

    《Very Simple Instant Messenger X-PopUp:简易即时通讯软件解析》 在当今信息化社会,即时通讯工具已经成为我们日常生活中不可或缺的一部分。"Very Simple Instant Messenger X-PopUp"(以下简称X-PopUp)作为一...

    A very simple .m file to read a .fig file and plot it in Octave

    在本主题中,我们讨论的是一个名为"A very simple .m file to read a .fig file and plot it in Octave"的程序,它的目的是在开源软件Octave中打开并显示一个`.fig`文件。 Octave是一个与MATLAB高度兼容的自由软件...

    very useful program

    This is a very useful program

    Very simple application which shows how to get your PC’s IP

    Very simple application which shows how to get your PC’s IP address using the VB Winsock control.

    very-very-basic-hapi-server

    安装步骤: 安装Nodejs- //nodejs.org/en/ 将仓库克隆到所需目录 在终端中,导航到Repo目录。 在终端中键入cd,在d后面加一个空格 将目录拖到终端窗口中,然后按Enter键。 输入npm install并按Enter ...

    Beginning Visual Basic 2010

    Web applications with ASP.NET, and Windows mobile and embedded CE apps with Visual Basic 2010, but you’ll also get a thorough grounding in the basic nuts-and-bolts of writing good code. You’ll be ...

    Android代码-支持展开的 TextView

    Using the library is very simple, look at the source code of the provided sample.  Step 1. In your layout xml: Step 2. In your activity: ((ExpandableTextView) findViewById(R.id.tv)).setText...

    A Simple JPEG Encoder in C#

    But, for a project, my friend 'anirban' required a JPEG encoder in C#. So, we started writing our own encoder. It turned out to be very complex and difficult. The one we wrote from scratch was really...

Global site tag (gtag.js) - Google Analytics