I need to do something about flash recently. I just got in touch with flash. The following lists some summary and experiences on flash learning. (In fact, they are all online. I just want to talk about flash ), hope you can give me more advice.
1. Solve the garbled Problem
Add:
System. usecodepage = true; this can solve the Garbled text problem. It is written on the Internet, but CS3 I used has not encountered this problem. Now I will wait for the problem to occur.
2. Two practical functions of the ComboBox or list component
(1) iscmbitemexists: checks whether an item already exists. Sometimes, you need to dynamically add items to the list or ComboBox component, but before adding the items, you must check whether the items already exist in advance to avoid repeated addition.
(2) selectcmbitem: select an item. Sometimes you need to useProgramSelect an item in the list or ComboBox component.
Code
// Check whether a specified item already exists
Function Iscmbitemexists (CMB, cmbdata)
{
VaR Len = CMB. length;
For ( VaR I = 0 ; I < Len; I ++ )
{
If (CMB. getitemat (I). Data = Cmbdata)
{
Return True ;
}
}
Return False ;
}
// Select an item
Function Cmbselectitem (CMB, cmbdata)
{
VaR Len = CMB. length;
VaR Index = 0 ;
For ( VaR I: Number = 0 ; I < Len; I ++ )
{
/*You can select the label value when only labels is set in ComboBox but no data is available,
For example, CMB. getitemat (I). Label = cmbdata (passed the ComboBox test)*/
If(CMB. getitemat (I). Data=Cmbdata)
{
Index=I;
Break;
}
}
CMB. selectedindex=Index;
}
3. Regular Expression (actionscript2.0)
ActionScript does not have the Regexp class ( ? ), So you need to import the Regexp. As file, which has been written online by a cool-man. Please search and download it if necessary.
Don't say I didn't tell you, The. Fla and Regexp. As files need to be placed in the same directory in the same folder (Microsoft Windows users, unknown to other platforms ).
(1) email address matching
VaR regstr = "Var regstr =" ^ [\ W-] + (\\. [\ W-] +) * @ [\ W-] + (\\. [\ W-] +) + $ ";
VaR pattern = new Regexp (regstr, "I ");
VaR flag: Boolean = pattern. Test (txtemail. Text); // return true or false
(2) Telephone matching
VaR regstr = "^ (\ D {3, 4}) | \ D {3, 4 }-)? \ D {6, 8} $ ";
VaR pattern = new Regexp (regstr, "I ");
VaR flag: Boolean = pattern. Test (txttelephone. Text); // return true or false
Write it here first, hoping to help you.