InProgramDuring development, it is necessary to have a good standard for variable naming. It not only helps developers but also readsCode. You can add a proper prefix before the variable name to make it clear what type of data the variable can store. This article describes how to useActionScriptA standard for naming variables during encoding.ActionScriptThe Hungarian naming method.
Before introducing this standard, let's talk about it first.ActionScriptVariable naming rules in:
1. The first character must be an underscore.(_)Dollar sign($)Or letters. The first character cannot be a number. AlthoughWith underlines and dollar characters
Number is the first character, but in practice, a variable name should usually start with a letter.
2. The following characters must be underscores (_).(_)Dollar sign($), Letters or numbers.
3. The variable name cannot contain spaces.
4. The name cannot be a keyword or otherFlashSpecial value. For example,Movieclip, true, String, undefinedIs not allowed
Variable names, because they areActionScript.
5. The name must be unique.(In its scope). If two variables with the same name are created in the same scope
One will overwrite the previous one.
OKWith this knowledge, let's take a look at the correctedActionScriptHungarian naming law:
PrefixData Type
AArray
BMPBitmapdata
BBoolean
BTButton
CColor
CamCamera
CmContextmenu
CMIContextmenuitem
DDate
LCLocalconnection
LVLoadvars
MMovieclip
MCLMovi1_loader
MicMicrophone
NNumber
NCNetconnection
NSNetstream
OObject
PJPrintjob
RSRecordset
SString
SNDSound
SoSharedobject
TTextfield
TFTextformat
VidVideo
XMLXML
XmlsXmlsocket
When naming variables, try to be considerate. To indicate the number of items to be discussed,NquantityIt is very clear. Because space is not allowed when naming variables, we often use underscores.(_)To replace it, such:VaR sfirst_name: String = "Joey ";If you do not like this alternative space method, we have another option: Internal upper case method. It requires that the first letter of each word after the first letter is capitalized, without spaces or underscores, such: Var sfirstname: String = "Joey ";
Of course, the standards are set by people. during development, you can make choices based on your programming habits. I wish you a pleasant coding experience.!