Name the variables in ActionScript.

Source: Internet
Author: User

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.!

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.