12 useful as code (common as code) _flash as

Source: Internet
Author: User
Tags rtrim
1. Copy content to system Clipboard
Copy Code code as follows:

System.setclipboard (strcontent);

2. Copy a arraycollection
Copy Code code as follows:

Dummy solution (OK, 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);

3. Open a new browser window
Copy Code code as follows:

Navigatetourl (New URLRequest ("http://www.5ga.cn"), "_blank");

4. Refresh Browser
Copy Code code as follows:

Navigatetourl (New URLRequest ("Javascript:location.reload ();"), "_self");

5. Close the browser
Copy Code code as follows:

Navigatetourl (New URLRequest ("Javascript:window.close ()"), "_self");

6. Set the background of Alert window to transparent
Copy Code code as follows:

Alert {
modaltransparency:0.0;
modaltransparencyblur:0;
}

7. Take random Color
Copy Code code as follows:

Lbl.setstyle (' Color ', 0xffffff*math.random ());

8. Clear the left space of substring
Copy Code code as follows:

Public Function LTrim (s:string): String {
var i:number = 0;
while (s.charcodeat (i) = | | s.charcodeat (i) = = | | s.charcodeat (i) = 9 | | s.charcodeat
i++;
}
Return s.substring (i,s.length);
}

9. Clear String Right space
Copy Code code as follows:

Public Function RTrim (s:string): String {
var i:number = s.length-1;
while (s.charcodeat (i) = | | s.charcodeat (i) = = | | s.charcodeat (i) = = 10 | | S.charcodeat (i) = = 9) {
i--;
}
Return s.substring (0,i+1);
}

10. Clear the space around the string
Copy Code code as follows:

Public Function Trim (s:string): String {
Return LTrim (RTrim (s));
}

11. Get Data type
Copy Code code as follows:

Getqualifiedclassname (data);

12. Generate Random strings.
Copy Code code as follows:


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

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.