12 easy-to-use flex Functions

Source: Internet
Author: User

1. Copy the content to the clipboard:

System . Setclipboard (strcontent );

2. Clone an arraycollection:

VaR bar: arraycollection = new arraycollection ();
For each (var I: Object In ac ){
Bar. additem (I );
}
VaR bar: listcollectionview =
New listcollectionview (AC). List );

3. Open the URL:

NavigatetoURL (
New URLRequest ('HTTP: // NTT. CC'), '_ blank ');

4. page reload:

NavigatetoURL (
New URLRequest ("Javascript: location. Reload ();"), "_ Self ");

5. Close the browser:

NavigatetoURL (
New URLRequest ("Javascript: window. Close ()"), "_ Self ");

6. Get the alert window with transparent Background:

Alert {
Modaltransparency: 0.0;
Modaltransparencyblur: 0;
}

7. Set the random color:

LBL. setstyle ('color', 0xffffff * Math . Random ());

8. Remove spaces on the left side of the string:

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

9. Remove spaces on the right of the string:

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

10. Remove the Left and Right spaces of the string:

Public Function trim (s: String ): String {
Return ltrim (rtrim (s ));
}

11. Obtain the Data Type:

Getqualifiedclassname (data );

12. Four Verification codes are generated:

Private function generatecheckcode (): String {
// Initialization
VaR ran: Number ;
VaR Number: Number ;
VaR code: String ;
VaR checkcode: String = "";
// Obtain four random numbers
For (var I: Int = 0; I <4; I ++ ){
Ran = Math . Random ();
// The expected result is 0.1234.
Number = Math . Round (Ran * 10000 );
If (Number % 2 = 0)
// 0 ASCII code 48
Code = String . Fromcharcode (48 + (Number % 10 ));
Else
// A's ASCII code 65
Code = String . Fromcharcode (65 + (Number % 26 ));
Checkcode + = code;
}
Return checkcode;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.