Actionscript2.0 and Adobe Flash CS3 Study Notes 1

Source: Internet
Author: User

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.

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.