Some commonly used clipboard operations, window operation strings, and so on.
1. Copy the content to the system clipboard
| 1 |
System. setclipboard (strcontent ); |
2. Copy an arraycollection
1 2 3 4 5 6 7 |
// 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 (AC). List ); |
3. Open a new browser window
| 1 |
NavigatetoURL (New URLRequest ("http://www.5ga.cn"), "_ blank "); |
4. Refresh the browser
| 1 |
NavigatetoURL (New URLRequest ("javascript: location. Reload ();"), "_ Self "); |
5. Close the browser
| 1 |
NavigatetoURL (New URLRequest ("javascript: window. Close ()"), "_ Self "); |
6. Set the background of the alert window to transparent
1 2 3 4 |
Alert { Modaltransparency: 0.0; Modaltransparencyblur: 0; } |
7. Random color
| 1 |
LBL. setstyle ('color', 0xffffff * Math. Random ()); |
8. Clear the left space of the substring
1 2 3 4 5 6 7 |
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. Clear spaces on the right of the string
1 2 3 4 5 6 7 |
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. Clear spaces around the string
1 2 3 |
Public Function trim (S: string): String { Return ltrim (rtrim (s )); } |
11. Obtain the Data Type
| 1 |
Getqualifiedclassname (data ); |
12. Generate a random string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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; } |